This file contains hidden or 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
| @implementation NSArray(Ext) | |
| -(NSArray*)subarrayWithSize:(int)returnSize | |
| { | |
| int count = self.count; | |
| if (returnSize >= 0 && returnSize <= count) | |
| { | |
| NSMutableArray *result = [[NSMutableArray alloc] init]; | |
| NSMutableArray *indexes = [NSMutableArray arrayWithCapacity:count]; | |
| for (int i = 0; i < returnSize; i++) |
This file contains hidden or 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
| #import "NSDictionary+Ext.h" | |
| @implementation NSDictionary(Ext) | |
| -(float)floatForKey:(NSString*)key | |
| { | |
| return [[self objectForKey:key] floatValue]; | |
| } |
This file contains hidden or 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
| module MyAttributes | |
| def self.included base | |
| base.extend ClassMethods | |
| base.send :include, InstanceMethods | |
| end | |
| module ClassMethods | |
| def has_attributes attrs | |
| attrs.each do |attr| | |
| attr = attr.to_s |
This file contains hidden or 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
| var SpeakEnglish = { | |
| db: { | |
| name: 'speakEnglishDB', | |
| displayName: 'Speak English DB', | |
| version: '1.0', | |
| size: 1000000, | |
| categories: { | |
| name: 'categories', | |
| columns: ['name'] | |
| }, |
This file contains hidden or 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
| # .gitignore for eclipse android project, source: http://stackoverflow.com/a/4130635/1039194 | |
| # built application files | |
| *.apk | |
| *.ap_ | |
| # files for the dex VM | |
| *.dex | |
| # Java class files | |
| *.class |
This file contains hidden or 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
| String.prototype.capitalize = function() { | |
| return this.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); }); | |
| }; | |
| String.prototype.contains = function(subStr) { | |
| return this.indexOf(subStr) !== -1; | |
| }; | |
| String.prototype.containsWord = function(word) { | |
| var expStr = Mustache.render(" {{word}} |^{{word}} | {{word}}$|^{{word}}$", {word: word}); |
This file contains hidden or 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
| class Fixnum | |
| def divisors | |
| ceil = Math.sqrt(self).ceil | |
| (1..ceil).select {|i| self % i == 0 } | |
| end | |
| end | |
This file contains hidden or 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
| function createCookie(value) { | |
| var name = 'sessionid'; | |
| var days = 3; | |
| if (days) { | |
| var date = new Date(); | |
| date.setTime(date.getTime()+(days*24*60*60*1000)); | |
| var expires = "; expires="+date.toGMTString(); | |
| } | |
| else var expires = ""; | |
| document.cookie = name+"="+value+expires+";"; |
This file contains hidden or 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
| pg_restore --host localhost --port 5432 --username "postgres" --dbname "my_dev" --no-password --verbose "server.dump" |
This file contains hidden or 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
| SELECT nspname || '.' || relname AS "relation", | |
| pg_size_pretty(pg_relation_size(C.oid)) AS "size" | |
| FROM pg_class C | |
| LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) | |
| WHERE nspname NOT IN ('pg_catalog', 'information_schema') | |
| ORDER BY pg_relation_size(C.oid) DESC | |
| LIMIT 20; | |
| Example output (from a database created with pgbench, scale=25): |
OlderNewer