Skip to content

Instantly share code, notes, and snippets.

@kwyn
kwyn / jsx.sublime-snippet
Created September 6, 2014 22:36
jsx autocomplete snippet for /** @jsx React.DOM */ declaration
<snippet>
<content><![CDATA[/** @jsx React.DOM */]]></content>
<tabTrigger>jsx</tabTrigger>
<scope>source.js</scope>
<description>jsx declerations</description>
</snippet>
{
"HarleyKwyn": [''shortly-hapi','famous2048', 'barista', 'GalaxyQuestWebsite', 'SSAASS']
}
var nthFibonacci = function(n) {
// Your code here
return n < 2 ? n : nthFibonacci(n-1) + nthFibonacci(n-2);
};
var result = nthFibonacci(4)
var treeMaker = function(value){
//tree code goes here!
var tree = Object.create(treeMaker.methods);
tree.value = value || null;
tree.children = [];
return tree;
};
//methods go here!
var choose = function(list){
return list[Math.floor(list.length * Math.random())];
};
var aHero = function(){
return choose(heroList);
};
var aDeed = function(){
return choose(deedList);
var longestPalindrome = function (string) {
// Your code here
// Sliding window problem.
// If string is palindrom, return string
// else check if substring of length stringLength-n is palindrome.
// As soon as you get a palindrome you've found the longest palindrome
// since you're shrinking the window and you want the longest one.
var stringLength = string.length
var n = 0;
while( n < stringLength){
from HTMLParser import HTMLParser
class MLStripper(HTMLParser):
def __init__(self):
self.reset()
self.fed = []
def handle_data(self, d):
self.fed.append(d)
def get_data(self):
return ''.join(self.fed)
/**
* A prime number is a whole number that has no other divisors other than
* itself and 1. Write a function that accepts a number and returns true if it's
* a prime number, false if it's not.
*/
var primeTester = function(n) {
if( n === 1) return false;
var bubbleSort = function(array){
for(var i = 0; i < array.length-1 ; i++){
for(var j = 0; j < array.length-1 ; j++ ){
if(array[j]>array[j+1]){
var swap = array[j];
array[j] = array[j+1];
array[j+1] = swap;
}
}
}
var trampoline = function(fun){
var args = Array.prototype.slice.call(arguments,1);
var result = fun.apply(this, args);
while(typeof result === 'function') {
result = result();
}
return result;
};
var countDown = function(n){