Skip to content

Instantly share code, notes, and snippets.

View ourway's full-sized avatar
🏆

Farshid Ashouri ourway

🏆
View GitHub Profile
@ourway
ourway / stalker_test
Created October 27, 2014 23:05
Stalker_test_error
#!st_test_env/bin/python
from stalker import db
db.setup()
db.init()
import datetime
from stalker import Studio
my_studio = Studio(
@ourway
ourway / bottle_and_gunicorn.py
Last active June 8, 2016 01:10
Running a bottle app with gunicorn
from bottle import route, run
@route('/')
def index():
'''test me'''
return '<h1>Hello Bottle!</h1>'
run(host='localhost', port=8080, server='gunicorn',
reload=True, workers=4, debug=True)
@ourway
ourway / ipadVideo.sh
Last active August 29, 2015 14:15 — forked from jamiecurran/gist:8271908
Convert a movie for ipad
ffmpeg -i movie.mkv -r 30 -strict -2 -async 1 -acodec aac -ac 2 -ab 160k -threads 0 -preset slower -profile:v high -level 4.1 -f mp4 -refs 4 ipadVideo.mp4
import nltk
import sys
import string
import re
text = open('test.txt').read()
text = ' '.join(re.findall('[%s]+' % string.ascii_letters, text))
# Used when tokenizing words
sentence_re = r'''(?x) # set flag to allow verbose regexps
([A-Z])(\.[A-Z])+\.? # abbreviations, e.g. U.S.A.
@ourway
ourway / spHelloWorld.py
Created March 7, 2015 12:17
Maya scripted command plug-in
import sys
import maya.OpenMaya as OpenMaya
import maya.OpenMayaMPx as OpenMayaMPx
kPluginCmdName = "spHelloWorld"
# Command
class scriptedCommand(OpenMayaMPx.MPxCommand):
def __init__(self):
OpenMayaMPx.MPxCommand.__init__(self)
@ourway
ourway / macka.py
Created March 7, 2015 12:36
maya scripted node plugin example
import maya.OpenMayaMPx as OpenMayaMPx
import maya.OpenMaya as OpenMaya
class MeasureNode(OpenMayaMPx.MPxNode):
kPluginNodeId = OpenMaya.MTypeId(0x00000120)
pos1 = OpenMaya.MObject()
pos2 = OpenMaya.MObject()
midpoint = OpenMaya.MObject()
@ourway
ourway / squid.conf
Last active August 29, 2015 14:17
Squid example config file for working with default provixy
#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 192.168.2.0/24
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
@ourway
ourway / polyalphabetic-cipher.py
Created March 28, 2015 21:05
poly-alphabetic cipher implementation in Python
""" This programme implements a polyalphabetic cipher. """
import string
ALPHABET = string.ascii_lowercase
CHARACTERS_THAT_MUST_REMAIN_THE_SAME = string.digits + string.punctuation + string.whitespace
def cycle_get(lst,index):
"""
sudo yum -y update
sudo yum -y groupinstall "Development Tools"
sudo yum -y install git libcurl-devel libcurl
# jansson C json library
sudo yum -y install jansson
sudo yum -y install jansson-devel
# install cpuminer
git clone --recursive https://github.com/pooler/cpuminer.git
@ourway
ourway / get_ip.py
Created April 13, 2015 12:59
Get Server IP in unix system via python
import socket, struct, fcntl
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sockfd = sock.fileno()
SIOCGIFADDR = 0x8915
def get_ip(iface = 'eth0'):
ifreq = struct.pack('16sH14s', iface, socket.AF_INET, '\x00'*14)
try:
res = fcntl.ioctl(sockfd, SIOCGIFADDR, ifreq)
except: