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
int lastEmptyString(char **strings, int n) { | |
if (n == 0) return -1; | |
if (!strcmp(strings[0], "")) return 0; | |
return 1 + lastEmptyString(strings + 1, n - 1); | |
} |
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
int lowest_alpha_string(char **strings, int n) { | |
if (n == 0) return -1; | |
int next = lowest_alpha_string(strings + 1, n - 1); | |
if (next == -1 || strings[0] < strings[next]) | |
return 0; | |
else | |
return 1 + next; | |
} |
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
// CODE FOR REFERENCE: | |
int lowest_alpha_string(char **strings, int n) { | |
if (n == 0) return -1; | |
int next = 1 + lowest_alpha_string(strings + 1, n - 1); | |
if (next == -1 || strings[0] < strings[next]) | |
return 0; | |
else | |
return next; | |
} |
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
# Allow the "type" field to be mass assigned. This is useful | |
# for, in my case, nested model forms. It IS dangerous but | |
# with proper form validation on this type field, it should be | |
# safe. | |
class Friend < ActiveRecord::Base | |
# Basic validation of the type field | |
validates_format_of inheritance_column, :with => /^Friend::([A-Z][a-zA-Z]+)$/ | |
# More validation for the type field to be safe | |
def validate |
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
Book.find_in_batches(:batch_size => 100) do |results| | |
# Do something with results | |
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
-- Startupper | |
-- By Mitchell Hashimoto | |
-- | |
-- A startup script tailored for my own personal use | |
-- to startup all my applications and set their proper | |
-- size based on the screen dimension (which changes | |
-- depending on if my laptop is connected to my 24" | |
-- monitor or not) | |
set _scriptName to "AppleScript: Startupper" |
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
-- ch14/Logger.hs | |
type Log = [String] | |
newtype Logger a = Logger { execLogger :: (a, Log) } | |
instance Monad Logger where | |
return a = Logger (a, []) | |
m >>= k = let (a, s) = execLogger m | |
mb = k a | |
(b, s') = execLogger mb | |
in Logger (b, s ++ s') |
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
FB.Event.subscribe('auth.sessionChange', function(response) { | |
// The cookies we need to set for Facebooker, and the | |
// associated key into the Mu session object | |
var cookies = { | |
session_key: 'session_key', | |
user: 'uid', | |
expires: 'expires', | |
ss: 'secret' | |
}; | |
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/bash | |
CLASSPATH=something.jar | |
for f in lib/*.jar; do | |
CLASSPATH=$CLASSPATH:$f | |
done | |
# Debugging: echo $CLASSPATH | |
rlwrap java -cp $CLASSPATH clojure.main |
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
948a949 | |
> struct INATEngine; | |
997a999 | |
> typedef struct INATEngine INATEngine; | |
1019c1021,1022 | |
< SettingsVersion_Future = 12 | |
--- | |
> SettingsVersion_v1_10 = 12, | |
> SettingsVersion_Future = 13 | |
1039c1042 |
OlderNewer