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
@interface UIColor (Hex) | |
+ (UIColor *)colorWithHex:(uint)rgbValue; | |
@end | |
@implementation UIColor (Hex) | |
+ (UIColor *)colorWithHex:(uint)rgbValue { | |
float redValue = ((rgbValue & 0xFF0000) >> 16) / 255.0; |
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
int main (int argc, const char *argv[]) { | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
NSUserDefaults *args = [NSUserDefaults standardUserDefaults]; | |
NSString *hexValue = [args stringForKey:@"hex"]; | |
if (hexValue && [hexValue length] == 6) { | |
NSString *hexPart; | |
float red, green, blue; | |
for (int i=0; i<[hexValue length]; 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
#!/usr/bin/python | |
def collatz(n,i): | |
while n > 1: | |
n = n % 2 == 0 and n / 2 or n * 3 + 1 | |
i += 1 | |
return i | |
def main(): | |
n = 1 # starting number |
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
#!/usr/bin/python | |
import os, sys, time, uuid | |
# get self code | |
self_content = file(sys.argv[0]).read() | |
while True: | |
# wait 10 seconds | |
time.sleep(10) |
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
find src -type f \( -name '*.java' -o -name '*.jspx' \) \ | |
-exec wc -l {} \; | awk '{sum+=$1} END {print sum}' |
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
public class Base62 { | |
public static final String ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; | |
public static final int BASE = ALPHABET.length(); | |
private Base62() {} | |
public static String fromBase10(int i) { | |
StringBuilder sb = new StringBuilder(""); |
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 sweetAlert = require('sweetalert2'); | |
sweetAlert('Hello World!', 'It works!', 'success'); |
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
/** | |
* Compares String concatenation performance vs StringBuilder. | |
* At around 21000 iterations, actual time spent is nearly identical. At higher iterations, | |
* StringBuilder comes out ahead in less actual time spent and with lower CPU usage. However in | |
* lower iterations, concatenation wins both measurements. | |
* | |
* Another consideration is that the StringBuilder pattern does not seem to affect the heap | |
* size limit at all, which could be a bug with Apex profiling. | |
*/ |
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
const streamBuffers = require('stream-buffers'); | |
const archiver = require('archiver'); | |
const zipDir = (dir) => { | |
const output = new streamBuffers.WritableStreamBuffer({ | |
initialSize: (100 * 1024), // start at 100 kilobytes. | |
incrementAmount: (10 * 1024), // grow by 10 kilobytes each time buffer overflows.); | |
}); | |
const archive = archiver('zip'); | |
archive.on('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
@RestResource(urlMapping = '/LimitProfiling/*') | |
global with sharing class LimitProfilingCallout { | |
@HttpPost | |
global static void callMeMaybe() { | |
RestRequest req = RestContext.request; | |
RestResponse res = RestContext.response; | |
Map<String, Object> data = (Map<String, Object>) JSON.deserializeUntyped(req.requestBody.toString()); | |
OlderNewer