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 Lgz = function(lgStr) { | |
var fn, msg, console = window.console || null; | |
var splitPos = lgStr.indexOf(':'), len = lgStr.length; | |
var fnMap = { | |
'i' : 'info', | |
'e' : 'error', | |
'w' : 'warn', | |
'l' : 'log' |
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> | |
char *my_strcpy(char *strDest, const char *strSrc) | |
{ | |
if (strSrc == NULL || strDest == NULL) | |
return NULL; | |
char *dest = strDest; |
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> | |
int main(int argc, char *argv[]) | |
{ | |
int input_var = 0; | |
int count; | |
do { | |
printf("Enter a number (-1 = quit): "); | |
count = scanf("%d", &input_var); |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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/bin/env python2 | |
def fib(max): | |
a, b = 0, 1 | |
for _ in xrange(n): | |
yield b | |
a, b = b, a+b | |
for i in fib(10): | |
print 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
#!/usr/bin/env python2 | |
def palindrome(s): | |
length = len(s) | |
barrier = length / 2 | |
head2tail = (c for c in s) | |
tail2head = (s[i] for i in xrange(length-1, -1, -1)) | |
for _ in xrange(barrier): | |
if head2tail.next() != tail2head.next(): |
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
# -*- coding: utf-8 -*- | |
def palindrome(s): | |
a = 0 | |
b = len(s) - 1 | |
while a < b: | |
if s[a] != s[b]: | |
return False | |
a, b = a+1, b-1 | |
return 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
def parlindrome(s): | |
splitter = len(s)/2 | |
return s[:splitter] == s[-1:-1-splitter:-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
palindrome = lambda s: s == s[::-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
import signal | |
import functools | |
class TimeoutError(Exception): pass | |
def timeout(seconds, error_message='Function called timed out!'): | |
def _handle_timeout(signum, frame): | |
raise TimeoutError(error_message) |
OlderNewer