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 | |
# -*- coding: utf-8 -*- | |
# recode a file from arabic windows(windows-1256) to utf8 | |
import sys, os | |
def winArabicToUtf8(s, ar2fa=True): | |
u = s.decode('windows-1256') | |
if ar2fa: | |
for item in [ | |
(u'ي',u'ی'), | |
(u'ك',u'ک'), |
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
*.py[oc] | |
*~ | |
#.Trash* | |
#.trash* | |
.hidden | |
*.patch* | |
*.bak | |
*.save | |
.hg | |
.bzr* |
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
''' | |
jd - ordinal = 1721425 | |
jd = ordinal + 1721425 | |
ordinal = jd - 1721425 | |
>>> date=(2015, 12, 19) ; gregorian.to_jd(*date) - datetime(*date).toordinal() | |
1721425 | |
''' |
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
<?php | |
include('Crypt/RSA.php'); | |
$rsa = new Crypt_RSA(); | |
$rsa->loadKey('<RSAKeyValue> | |
<Modulus> | |
... | |
</Modulus> | |
<Exponent>AQAB</Exponent> | |
<P> |
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 random | |
def weighted_choice(choices): | |
if isinstance(choices, dict): | |
choices = choices.items() | |
total = sum(w for c, w in choices) | |
r = random.uniform(0, total) | |
upto = 0 | |
for c, w in choices: | |
if upto + w >= r: |
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 | |
git show-ref --abbrev --heads | sed 's/refs\/heads\///g' | sort | uniq -w 7 -D |
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
## https://gist.github.com/ilius/71cfdeb004b568ecd40c | |
from heapq import heappush, heappop | |
def hsortStream(stream, maxHeapSize, key=None): | |
""" | |
stream: a generator or iterable | |
maxHeapSize: int, maximum size of heap | |
key: a key function, as in `list.sort` method, or `sorted` function |
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 | |
import os, sys | |
def getDateTime(imPath):## output sample: '2005:01:01_12:02:16' | |
if not os.path.exists(imPath): | |
print 'Error: Image file \''+imPath+'\' dose not exit!' | |
sys.exit(1) | |
if os.path.isdir(imPath): | |
print 'Error: \''+imPath+'\' is a directory!' | |
sys.exit(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
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
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 perl | |
=dependencies: | |
sudo cpan get Mojolicious | |
sudo cpan get MongoDB | |
sudo cpan get Set::Light | |
sudo cpan get Log::Log4perl | |
sudo cpan get DateTime::Format::Strptime | |
sudo cpan get File::HomeDir | |
sudo cpan get Digest::SHA1 |
OlderNewer