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
from sqlalchemy.types import TypeDecorator, CHAR | |
from sqlalchemy.dialects.postgresql import UUID | |
import uuid | |
class GUID(TypeDecorator): | |
"""Platform-independent GUID type. | |
Uses PostgreSQL's UUID type, otherwise uses | |
CHAR(36), storing as stringified hex values. |
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
redis-cli -h <host> -p <port> -n <db> KEYS "*pattern*" | xargs -L1 -I '$' echo '"$"'| xargs redis-cli -h <host> -p <port> -n <db> DEL |
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 uuid | |
o_u = uuid.uuid4() | |
u = str(o_u) | |
cf = u.split('-') | |
cf[-2] = cf[-2] + cf[-1] | |
cf.pop(-1) | |
cf = '-'.join(cf).upper() | |
h = o_u.hex |
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
set wildmode=list:longest | |
set paste | |
set wildignore=*.pyc,__pycache_,node_modules/*,bower_components/* | |
set ts=4 | |
set sw=4 | |
set ls=2 | |
set ai | |
set si | |
set incsearch | |
set expandtab |
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
""" | |
Author: Mohamed Hendawy | |
Last edited: Feb 24 2015 | |
Description: A simple in-memory Redis-like data store | |
HOW-TO: $ /path/to/python /path/to/simpledb.py < input.file > output.file | |
To Consider: The output alwas ends with enforced newline, but sometimes text | |
editors also add a newline to the end of the file | |
""" |
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
""" | |
Given a list on integers (positive and negative), return the sum of the | |
continues subsequence with largest sum | |
""" | |
def largest_subsequence(sequence): | |
""" | |
The solution depends on ignoring the sum sequence(j -> i) | |
if sequence[i+1] > sum sequence(j -> i+1) where j < i and 0 <= i, j < 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
""" | |
How many ways to climb n numbers of stairs if you could climb them 1, 2, 3 | |
flights at a time | |
""" | |
def stairs(num): | |
""" | |
This solution depends on how many ways I could get to any flight of staits. | |
When I could reach a flight (i) with n ways and I could reach flight (i + 1) |