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
var http = require('http'); | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World\n'); | |
}).listen(3000, '127.0.0.1'); | |
console.log('Server running at http://127.0.0.1:3000/'); |
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
var http = require('http'); | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World\n'); | |
}).listen(3000, '127.0.0.1'); | |
console.log('Server running at http://127.0.0.1:3000/'); |
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
function wordWrap(text){ | |
var words = text.split(' '); | |
var charWidth = 6; // and then suddenly a charWidth appeared. | |
var horizotalLimit = 200; | |
var lines = []; | |
var currentLine = 0; | |
lines.push({line : '', text_length : 0}); | |
var i = 0; |
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
#include <iostream> | |
#include <queue> | |
using namespace std; | |
void merge(int s[], int low, int middle, int high){ | |
int i; | |
queue<int> buffer1, buffer2; | |
for(i=low; i<=middle; i++) buffer1.push(s[i]); |
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
var _ = require('underscore'); | |
function sortObject(obj){ | |
var oNew = {}; | |
if(typeof obj === 'object'){ | |
var aKeys = _.keys(obj); | |
aKeys.sort(); | |
_.each(aKeys, function(sKey, oVal){ | |
oNew[sKey] = sortObject(obj[sKey]); | |
}); |
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
/* Swift notes */ | |
import Cocoa | |
/* Use let to make a contant and var to make a variable, implicitly infer the type */ | |
var cheesyVariable = 100 | |
let cheesyConstant = 666 | |
let implicitDouble = 70.0 |
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
Graph.prototype.forces = function(){ | |
for(var i=0; i<this.nodesList.length; i++){ | |
netForceX = 0; | |
netForceY = 0; | |
var dsq; | |
var a = this.nodesList[i]; | |
/*calculate repulsion*/ | |
for(var j=0; j<this.nodesList.length; j++){ | |
var b = this.nodesList[j]; |
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
import UIKit | |
import Security | |
let serviceIdentifier = "com.Test.KeychainTest" | |
let kSecClassValue = kSecClass as NSString | |
let kSecAttrAccountValue = kSecAttrAccount as NSString | |
let kSecValueDataValue = kSecValueData as NSString | |
let kSecClassGenericPasswordValue = kSecClassGenericPassword as NSString | |
let kSecAttrServiceValue = kSecAttrService as NSString |
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
extension NSURL { | |
func queryParams() -> Dictionary<String, String> { | |
var params = Dictionary<String, String>() | |
if let queryParams = self.query?.componentsSeparatedByString("&") { | |
for param in queryParams { | |
var parts = param.componentsSeparatedByString("=") | |
params[parts[0]] = parts[1] | |
} | |
} |
OlderNewer