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> | |
typedef struct { | |
char* haystack; | |
char* needle; | |
int found; | |
} unitTest; | |
int strstr(char* haystack, char* needle) { | |
int 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
String.prototype.toCamelCase = function() { | |
return this.toLowerCase() | |
.replace(/[^\w\s]/g, '') | |
.replace(/\s+(\w)/g, function(match, $1) { return $1.toUpperCase(); }); | |
}; |
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() { | |
var isWord = function(word) { return /^[a-z]+$/i.test(word); }, | |
exceptions = { | |
man: 'men', | |
woman: 'women', | |
child: 'children', | |
mouse: 'mice', | |
tooth: 'teeth', | |
goose: 'geese', |
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
// The easy way to get unique items from an array | |
Array.prototype.unique = function() { | |
return this.filter(function(s, i, a){ return i == a.lastIndexOf(s); }); | |
}; | |
// Translated into jQuery, so it works in IE8 :P | |
Array.prototype.unique = function() { | |
var array = this; | |
return $.grep(array, function(v, i) { return $.inArray(v, array, i + 1) == -1; }); | |
}; |
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
-- We have a table (ip_log) of proper IPv4 addresses (ip) | |
select bitand(ip / 16777216, 255) || '.' || bitand(ip / 65536, 255) || '.' || bitand(ip / 256, 255) || '.' || bitand(ip, 255) ip | |
from ip_log; | |
-- ...or a function to do the same: | |
create or replace function long2ip(ip in number) | |
return varchar2 deterministic | |
as | |
begin | |
return bitand(ip / 16777216, 255) || '.' || |
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
select level p | |
from dual | |
where not regexp_like(rpad('#', level, '#'), '^#?$|^(##+?)\1+$') | |
connect by level <= 1000; |
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
sumPairs :: [Integer] -> [Integer] | |
sumPairs (x:y:s) = (x + y) : sumPairs (y:s) | |
sumPairs _ = [] | |
pascal :: Integer -> [Integer] | |
pascal 0 = [1] | |
pascal n = sumPairs $ [0] ++ (pascal $ n - 1) ++ [0] | |
sierpinski :: Integer -> String | |
sierpinski n = concat $ map (ascii . odd) $ pascal 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
abnormal -> abnor.ml | |
abysmal -> abys.ml | |
acetylthymol -> acetylthy.ml | |
actinostomal -> actinosto.ml | |
adiathermal -> adiather.ml | |
alemmal -> alem.ml | |
alismal -> alis.ml | |
Alumel -> Alu.ml | |
Alvissmal -> Alviss.ml | |
amil -> a.ml |
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
create or replace procedure email( | |
sender in varchar2, | |
recipients in varchar2, | |
carbon in varchar2, | |
subject in varchar2, | |
text in clob, | |
html in clob default null) | |
as | |
connection utl_smtp.connection; | |
smtpHost varchar2(30) := 'mail.example.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 ldap | |
# *Really* simple Python-LDAP wrapper for query and authentication | |
# myLDAPServer = LDAP('ldap://ldap.example.com', 'o=foo') | |
# me = myLDAPServer.person('jbloggs') | |
# | |
# try: | |
# me.authenticate('abc123') | |
# except: |