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
// 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): |
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): | |
odd = 0 | |
even = 0 | |
for c in s: | |
if not c==" ": | |
if ord(c)%2==0: | |
even+=math.pow(ord(c),2) | |
else: |
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
def check_range(frm,to,trgt): | |
return 1 if frm<=trgt and to>=trgt else 0 | |
def lower_character(c): | |
comp = check_range(ord('A'),ord('Z'),c) | |
return (comp<<5)|c if comp==1 else c | |
def upper_character(c): | |
comp = check_range(ord('a'),ord('z'),c) | |
return c&((comp<<5)^0x7f) if comp==1 else c |
OlderNewer