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 imgStr = ""; | |
setInterval(function(){ | |
// Make sure to change the command based on the OS you are using. | |
require('child_process').spawn('screencapture', ['-C', '-x','cme.png']).on('close', function (code) { | |
imgStr = require("fs").readFileSync('cme.png','base64'); | |
}); | |
},1000); | |
require("http").createServer(function(req,res){ |
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
targetList = {n:{n:{n:{v:1},v:2},v:3},v:4}; | |
function reverseLinkedList(n){ | |
if(n.n){ | |
v = reverseLinkedList(n.n); // simply get the child until you hit the end. | |
v.n=n; // in the new Order parent node is the child of its child. | |
}else{ | |
delete targetList.n; // without this line the list will be circuler | |
targetList = n; // replace the head with the tail | |
} | |
return n; |
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
#!/usr/local/bin/node | |
// If the incoming value > then add to left, if the value is < add to right | |
// if the left/right has value will go recursively until empty node is found | |
function addToTree(tree,v){ | |
if(tree["v"] && tree["v"]!=v){ | |
var direction = ""; | |
if(tree["v"]>v) direction = "l"; | |
if(tree["v"]<v) direction = "r"; |
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
////: Playground - noun: a place where people can play | |
// | |
//import Cocoa | |
// | |
//public final class Box<T> | |
//{ | |
// let value : T | |
// | |
// public init(_ value : T) { | |
// self.value = value |
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 Cocoa | |
import XCPlayground | |
// For some reason (May be because Swift is still beta) Xcode goes crazy when I change addTree to generics. | |
// Update Thanks to my friend Shady Said, I forgot to add compareable. | |
class Node<V : Comparable>{ | |
var leftNode:Node?; | |
var rightNode:Node?; | |
var parent:Node?; |
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
// Inspired by the game 2048 :D | |
function merge(left, right) { | |
var result = []; | |
while(left.length || right.length) { | |
if(left.length && right.length) { | |
if(left[0]<right[0]) { | |
result.push(left.shift()); | |
} else { | |
result.push(right.shift()); |
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
#!/usr/local/bin/node | |
var fs = require("fs"); | |
var filenames = fs.readdirSync("."); | |
var a = "a".charCodeAt(0); | |
var z = "z".charCodeAt(0); | |
var c0 = "0".charCodeAt(0); | |
var c9 = "9".charCodeAt(0); | |
var acceptableChars = {"_":true,".":true} |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int lineBreaker = 12; | |
void printInHex(char* file, int length){ | |
char* temp = (char*)malloc(lineBreaker+1); | |
memset(temp,0,lineBreaker+1); | |
for (int i=0;i<length;i++){ | |
printf("0x%02x ",file[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
# Make sure to use this command before using the script | |
# pip install TwitterAPI | |
# The script is part of the demo of Twitter API, so no big deal here. | |
from TwitterAPI import TwitterAPI | |
import json | |
ACCESS_TOKEN_KEY = "GET IT FROM https://apps.twitter.com" |
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 math | |
def stringNorm(s): | |
norm = 0 | |
for c in s: | |
if not c==" ": | |
norm+=math.pow(ord(c),2) | |
return math.sqrt(norm) | |
def anagram_detection(s1,s2): |
OlderNewer