RobL

How to delete a remote tag in Git.

git tag -d tagtoremove
git push origin :refs/tags/tagtoremove

very clever. messing around with hostnames of routers

Robs-iMac:pledge_core rl$ traceroute 216.81.59.173
traceroute to 216.81.59.173 (216.81.59.173), 64 hops max, 52 byte packets
 1  10.10.140.1 (10.10.140.1)  11.123 ms  15.222 ms  13.561 ms
 2  brig-core-2a-xe-002-0.network.virginmedia.net (80.3.64.225)  11.023 ms  12.461 ms  11.560 ms
 3  brnt-bb-1a-ae19-0.network.virginmedia.net (213.105.159.153)  14.969 ms  13.989 ms  19.439 ms
 4  * * *
 5  * * *
 6  * * *
 7  nrth-bb-1c-ae0-0.network.virginmedia.net (62.254.42.134)  33.405 ms  13.518 ms  17.352 ms
 8  fran-ic-2-ae0-0.network.virginmedia.net (62.254.42.178)  32.933 ms  37.752 ms  33.935 ms
 9  30gigabitethernet4-3.core1.fra1.he.net (80.81.192.172)  38.951 ms  35.417 ms  43.849 ms
10  100ge5-2.core1.par2.he.net (72.52.92.13)  44.133 ms  62.041 ms  46.092 ms
11  10ge15-1.core1.ash1.he.net (184.105.213.93)  106.065 ms  123.027 ms  106.997 ms
12  10ge1-2.core1.atl1.he.net (184.105.213.110)  122.861 ms  125.631 ms  133.370 ms
13  216.66.0.26 (216.66.0.26)  316.928 ms  133.867 ms  119.540 ms
14  * * *
15  episode.iv (206.214.251.1)  158.935 ms  189.852 ms  159.442 ms
16  a.new.hope (206.214.251.6)  160.546 ms  166.501 ms  168.217 ms
17  it.is.a.period.of.civil.war (206.214.251.9)  161.563 ms  172.048 ms  165.151 ms
18  rebel.spaceships (206.214.251.14)  162.032 ms  164.220 ms  182.936 ms
19  striking.from.a.hidden.base (206.214.251.17)  175.150 ms  161.951 ms  163.248 ms
20  have.won.their.first.victory (206.214.251.22)  162.738 ms  163.320 ms  162.650 ms
21  against.the.evil.galactic.empire (206.214.251.25)  161.264 ms  384.746 ms  171.485 ms
22  during.the.battle (206.214.251.30)  357.428 ms  169.686 ms  160.789 ms
23  rebel.spies.managed (206.214.251.33)  159.636 ms  162.306 ms  158.633 ms
24  to.steal.secret.plans (206.214.251.38)  161.400 ms  158.717 ms  157.681 ms
25  to.the.empires.ultimate.weapon (206.214.251.41)  162.642 ms  161.686 ms  163.015 ms
26  the.death.star (206.214.251.46)  162.793 ms  166.526 ms  161.715 ms
27  an.armored.space.station (206.214.251.49)  161.710 ms  162.815 ms  159.922 ms
28  with.enough.power.to (206.214.251.54)  177.850 ms  175.679 ms  161.911 ms
29  destroy.an.entire.planet (206.214.251.57)  160.419 ms  160.928 ms  459.348 ms
30  pursued.by.the.empires (206.214.251.62)  159.853 ms  162.489 ms  211.870 ms
31  sinister.agents (206.214.251.65)  159.998 ms  164.795 ms  162.802 ms
32  princess.leia.races.home (206.214.251.70)  161.321 ms  165.046 ms  160.520 ms
33  aboard.her.starship (206.214.251.73)  161.139 ms  165.795 ms  166.763 ms
34  custodian.of.the.stolen.plans (206.214.251.78)  164.417 ms  164.701 ms  163.949 ms
35  that.can.save.her (206.214.251.81)  172.123 ms  379.719 ms  163.717 ms
36  people.and.restore (206.214.251.86)  162.872 ms  162.311 ms  236.724 ms
37  freedom.to.the.galaxy (206.214.251.89)  172.736 ms  162.064 ms  161.036 ms
38  0-----i-------i-----0 (206.214.251.94)  163.729 ms  178.702 ms  160.082 ms
39  0------------------0 (206.214.251.97)  159.938 ms  171.574 ms  166.623 ms
40  0-----------------0 (206.214.251.102)  162.639 ms  161.415 ms  164.806 ms
41  0----------------0 (206.214.251.105)  167.458 ms  162.318 ms  164.580 ms
42  0---------------0 (206.214.251.110)  169.286 ms  162.726 ms  162.048 ms
43  0--------------0 (206.214.251.113)  162.910 ms  164.204 ms  168.749 ms
44  0-------------0 (206.214.251.118)  166.699 ms  170.351 ms  172.651 ms
45  0------------0 (206.214.251.121)  159.047 ms  161.181 ms  162.952 ms
46  0-----------0 (206.214.251.126)  164.174 ms  173.919 ms  212.134 ms
47  0----------0 (206.214.251.129)  168.123 ms  209.428 ms  163.144 ms
48  0---------0 (206.214.251.134)  168.921 ms  164.755 ms  163.971 ms
49  0--------0 (206.214.251.137)  159.927 ms  207.254 ms  188.687 ms
50  0-------0 (206.214.251.142)  164.872 ms  162.988 ms  162.665 ms
51  0------0 (206.214.251.145)  163.522 ms  303.512 ms  159.782 ms
52  0-----0 (206.214.251.150)  162.139 ms  183.994 ms  193.999 ms
53  0----0 (206.214.251.153)  166.649 ms  165.147 ms  165.782 ms
54  0---0 (206.214.251.158)  167.327 ms  166.019 ms  167.644 ms
55  0--0 (206.214.251.161)  422.569 ms  182.132 ms  168.749 ms
56  0-0 (206.214.251.166)  166.422 ms  166.970 ms  165.926 ms
57  00 (206.214.251.169)  160.421 ms  160.880 ms  162.596 ms
58  i (206.214.251.174)  193.246 ms  165.820 ms  163.162 ms
59  by.ryan.werber (206.214.251.177)  163.115 ms  161.675 ms  347.660 ms
60  blizzards.breed.ccie.creativity (206.214.251.182)  163.674 ms  166.756 ms  163.709 ms
61  please.try.again.tracerote.to.obiwan.scrye.net (206.214.251.185)  165.720 ms  172.367 ms  165.217 ms
62  read.more.at.beaglenetworks.net (206.214.251.190)  178.686 ms *  168.679 ms

C# HTTP API calls from inside Unity

Had to fiddle about a bit to work out how to POST an JSON API with Unity via C#, this example sends raw JSON with the application/json header which Rails will then decode it and turn it into ‘params’.

using UnityEngine;
using System.Collections;

public class ThingAPI : MonoBehaviour {
	// Use this for initialization
	IEnumerator Start () {
		// GET
                var url = "http://localhost:3000/api/posts/1";
		WWW www = new WWW(url);
		yield return www;

                // POST
		url = "http://localhost:3000/api/posts";
		var jsonString = "{\"post\":[{\"title": "Something to post about\": 1, \"body\": \"and maybe someone will listen to my cries.\"}]}";
		
		var encoding = new System.Text.UTF8Encoding();
		var postHeader = new Hashtable();
		
		postHeader.Add("Content-Type", "application/json");
		postHeader.Add("Content-Length", jsonString.Length);

		www = new WWW(url, encoding.GetBytes(jsonString), postHeader);
		yield return www;
	}
}

sublime-text-2-hash-syntax

https://github.com/iltempo/sublime-text-2-hash-syntax (CMD+CTRL+H)
- turns :blah => true to blah: true
- for much rejoicing of time saved twiddling

text_area_tag newline irritation

Yeah, well that’s not very helpful if you’re trying to count the characters in a text area and Rails is putting in a newline when you don’t want one.

2.1.2 :003 > helper.text_area_tag('test','test')
=> "<textarea name=\"test\" id=\"test\">\ntest</textarea>"

HAML doesn’t do this

%textarea string    #=> "<textarea>string</textarea>"
%textarea= 'string' #=> "<textarea>string</textarea>"

Plenty of *not right* going on

I, [2015-01-22T07:15:59.225481 #30041]  INFO -- :   Rendered api/characters/_character.json.jbuilder (0.0ms)
I, [2015-01-22T07:15:59.225700 #30041]  INFO -- :   Rendered api/characters/_character.json.jbuilder (0.0ms)
I, [2015-01-22T07:15:59.225951 #30041]  INFO -- :   Rendered api/characters/_character.json.jbuilder (0.1ms)
I, [2015-01-22T07:16:00.561068 #30041]  INFO -- :   Rendered api/characters/_character.json.jbuilder (1307.7ms)
I, [2015-01-22T07:16:00.561527 #30041]  INFO -- :   Rendered api/characters/_character.json.jbuilder (0.1ms)
I, [2015-01-22T07:16:00.561772 #30041]  INFO -- :   Rendered api/characters/_character.json.jbuilder (0.1ms)
I, [2015-01-22T07:16:00.561993 #30041]  INFO -- :   Rendered api/characters/_character.json.jbuilder (0.1ms)
I, [2015-01-22T07:16:00.562210 #30041]  INFO -- :   Rendered api/characters/_character.json.jbuilder (0.0ms)
I, [2015-01-22T07:16:00.562425 #30041]  INFO -- :   Rendered api/characters/_character.json.jbuilder (0.1ms)

Post # 242

Oh Dear

Completed 200 OK in 4100900.7ms (Views: 3288.4ms | ActiveRecord: 4097424.5ms)

AngularJS and Uglifier don't mix well.

Uglifier’s mangling messes with AngularJS. To turn it off you should do something like…

# config.assets.js_compressor = :uglifier
config.assets.js_compressor = Uglifier.new(mangle: false) if defined? Uglifier

Checkout a single file from a different branch

I totally managed to mess up my Gemfile.lock file setting the versions of many gems to far higher versions than I’d intended. bundle update is bad, even if you set the version in your Gemfile the dependencies of thos gems are not versioned so precisely. I did this in a branch so fortunately the Gemfile.lock in my master branch is accurate.

git checkout master -- Gemfile.lock

That did the job. Then a bundle install puts the changes I’d made to my Gemfile into Gemfile.lock with the correct dependencies as per master. Phew.