This file contains hidden or 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
/** | |
* Read a ISO string | |
*/ | |
export const fromISOString = (str: string) => { | |
return Date.parse(str); | |
}; | |
/** Convert from MilliTimestamp (javascript default) to unix */ | |
export const toUnixTimestamp = (milliTimestamp: number): UnixTimestamp => { | |
return (milliTimestamp / 1000) as UnixTimestamp; |
This file contains hidden or 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 os | |
from jinja2 import FileSystemLoader, Environment | |
template_path = os.getcwd() | |
# Load jinja | |
jinja_loader = FileSystemLoader( template_path ) | |
jinja_env = Environment( loader=jinja_loader ) | |
# Get the template and render it using `myvars` |
This file contains hidden or 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 locawebJSON(data): | |
_pdata = [] | |
for k,v in data.iteritems(): | |
if type(v) in [str, unicode]: | |
v = ('"%s"' % (v)) | |
elif isinstance(v, bool): | |
v = (v and 'true' or 'false') | |
_pdata.append('%s=%s' % (k,v)) | |
This file contains hidden or 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
$('#paywall').hide(); | |
$('body').css({'overflow': 'scroll'}); | |
window.scroll = undefined; | |
window.resize = undefined; |
This file contains hidden or 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> | |
char* cycle(int start, int next, int repeatafter, int windowsize){ | |
int j; | |
char *str = malloc( sizeof(char) * windowsize + 1); | |
for(j=0;j < windowsize; ++j) | |
str[j] = 0x30 + ((start + next*j) % (repeatafter+1)); | |
str[j] = '\0'; |
This file contains hidden or 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/bin/env python | |
def crange(tup, i=0, windowsize=3): | |
l = len(tup) | |
return "".join([ str(tup[(i+p)%l]) for p in range(0,windowsize)]) | |
r = range(0,6) | |
for i in range(0,10): | |
print crange( r, i , 3 ) |
This file contains hidden or 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
(define 2ndorder-markov | |
(lambda (:phrase) | |
(if (= (length :phrase) 1) (list (first :phrase)) | |
(list (second :phrase))))) | |
(define 3ndorder-markov | |
(lambda (:phrase) | |
(cond | |
((= (length :phrase) 1) (list (first :phrase))) | |
((= (length :phrase) 2) (list (second :phrase))) |
This file contains hidden or 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 re | |
from django.utils.text import compress_string | |
from django.utils.cache import patch_vary_headers | |
from django import http | |
try: | |
import settings | |
XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS |
This file contains hidden or 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/bin/python | |
import re,sys | |
def searchInArray( shit, likeStr ): | |
escape_chars = list( '.^$*+?()[{\\' ) | |
op_chars = list( '%_' ) | |
safe_re = "".join( map( lambda c: c in escape_chars and ('\\' +c) or c , likeStr ) ) | |
match_re = "".join( map( lambda c: c == op_chars[0] and ('.*?') or (c == op_chars[1] and '.' or c) , safe_re ) ) | |