This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):001:0> A = [1,2,3].freeze | |
=> [1, 2, 3] | |
irb(main):002:0> A[2] = 5 | |
TypeError: can't modify frozen array | |
from (irb):2:in `[]=' | |
from (irb):2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Monkey-patch link_to (when called with method "delete") to use the authenticity token | |
# from the current page (in the #authenticity_token element), as opposed to hard-coding it. | |
# Rails' hard-coding breaks the app when using fragment caching because users get authenticity | |
# tokens that are old and/or not their own. | |
# | |
# To make the JavaScript less complicated, assumes that you have an element (like a DIV) | |
# on the page with id="authenticity_token" that contains the authenticity token. | |
# It could also be adapted to use the authenticity token from the the csrf-token meta tag. | |
# | |
# See https://github.com/cheerful/freckle/issues/743 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(BOOL)appIsPresentInLoginItems | |
{ | |
NSString *bundleID = @"blah"; | |
NSArray * jobDicts = nil; | |
jobDicts = (NSArray *)SMCopyAllJobDictionaries( kSMDomainUserLaunchd ); | |
if ( (jobDicts != nil) && [jobDicts count] > 0 ) { | |
BOOL bOnDemand = NO; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a single method signature in AppKit | |
initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel: | |
# a JavaScript unit testing framework | |
function(a,b,c,d,e,f){c=d=e=0;for(f in a)try{a[f](function(g,h){g?c++:(d++,b(f,'F',h))})}catch(i){e++;b(f,'E',i)}b(c+'A',d+'F',e+'E')} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isHardwareAccelerationIsAGoodIdea | |
/[0-9]+\.[0-9]+/.match(NSProcessInfo.processInfo.operatingSystemVersionString) | |
.to_s.split('.').map(&:to_i)[1] >= 9 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def decideIfHardwareAccelerationIsAGoodIdea | |
version = NSProcessInfo.processInfo.operatingSystemVersionString | |
begin | |
version = /[0-9]+\.[0-9]+/.match(version).to_s.split('.').map(&:to_i) | |
NSLog "Turning hardware acceleration on (#{version})" | |
@hw_accel = version[1] >= 9 | |
rescue | |
NSLog "Couldn't parse operatingSystemVersionString: #{version}" | |
@hw_accel = false | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rake test:run | |
(in /Users/thomasfuchs/Projects/prototype) | |
Started tests in Google Chrome. | |
Finished in 2.0e-06 seconds. | |
0 tests, 0 assertions, 0 failures, 0 errors. | |
Started tests in Chromium. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# File: /etc/init.d/unicorn | |
### BEGIN INIT INFO | |
# Provides: unicorn | |
# Required-Start: $local_fs $remote_fs $network $syslog | |
# Required-Stop: $local_fs $remote_fs $network $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Add PostgreSQL repository | |
apt_repository: repo='deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' state=present | |
sudo: yes | |
- name: Add PostgreSQL repository key | |
apt_key: url=https://www.postgresql.org/media/keys/ACCC4CF8.asc state=present | |
sudo: yes | |
- name: Update apt cache | |
apt: update_cache=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -H 'Authorization: token INSERTACCESSTOKENHERE' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/owner/repo/contents/path |