Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/bin/bash | |
# server-jre-8u5-linux-x64.tar.gz | |
DEBIAN_FRONTEND=noninteractive | |
UCF_FORCE_CONFFNEW=true | |
export UCF_FORCE_CONFFNEW DEBIAN_FRONTEND | |
apt-get update | |
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" dist-upgrade |
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/python | |
#By Steve Hanov, 2011. Released to the public domain | |
import time | |
import sys | |
DICTIONARY = "/usr/share/dict/words"; | |
TARGET = sys.argv[1] | |
MAX_COST = int(sys.argv[2]) | |
# read dictionary 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
#! /usr/bin/env python | |
''' | |
Nutshell - make long CLI commands interactive | |
--------------------------------------------- | |
I am lazy. I am forgetful. I often have to write long CLI commands. | |
The shell history does an awesome job of remembering them for me but too often | |
I end up working too hard in trying to find the line I wrote a couple of days | |
back and having to change something simlple e.g. name of a file etc. |
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 xtemplate(toks, str): | |
''' | |
A function that generates templates from given tokens and | |
strings. We are using this to generate email templates: | |
>>> sep = [(',', ','), ('-', '-'), ('_', '_')] | |
>>> ini = [('$fini', 'a'), ('$lini', 'z')] | |
>>> name = [('$fname', 'ali'), ('$lname', 'zaidi')] | |
>>> toks = sep + ini + name | |
>>> xtemplate(toks, 'ali.zaidi') | |
'$fname.$lname' |
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 json | |
class Record(object): | |
""" | |
A simple trick that allows you to do `record.name`, 'record.age' | |
instead of `record['name']`, `record['age']`. | |
>>> import json | |
>>> data = json.dumps([{'name': 'jack', 'user': {'id': 21}}]) | |
>>> recs = Record.make_records(data) |
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
Hello World! | |
============ | |
I am **Ali**. |
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
" @alixedi - My .vimrc based on: | |
" Sample by Martin Brochhaus: github.com/mbrochh/ | |
" Automatic reloading of .vimrc | |
autocmd! bufwritepost .vimrc source % | |
" Better copy & paste | |
" When you want to paste large blocks of code into vim, press F2 before you |
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 functools import lru_cache#python >=3.2 | |
from functools32 import lru_cache#python 2.7 | |
#from repoze.lru import lru_cache#python 2.7 | |
#NOTE: you can use python -m trace --count fibonacci.py | |
#to see how many times each instruction is called | |
#@lru_cache(maxsize=500)#repoze.lru needs maxsize arg | |
@lru_cache()#using functools32 | |
def fibonacci(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
from math import sqrt | |
from random import sample | |
from datetime import datetime | |
def correlation(ser1, ser2): | |
"""Computes Pearson product-moment correlation coefficient for the given 2 | |
time series. See: http://bit.ly/1PHG1jy | |
>>> from correlation import correlation | |
>>> s1 = [random()*100 for i in range(100)] | |
>>> _s1 = [100-s1[i] for i in range(100)] |
NewerOlder