Skip to content

Instantly share code, notes, and snippets.

View ourway's full-sized avatar
🏆

Farshid Ashouri ourway

🏆
View GitHub Profile
@ourway
ourway / Dijsktra
Last active August 29, 2015 14:01 — forked from econchick/gist:4666413
Dijesktra algorithm
class Graph:
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
self.nodes.add(value)
def add_edge(self, from_node, to_node, distance):

Gitlab Gmail configuration

In Gitlab 2.6 you must edit the following files in order to send messages through a Gmail account (also applicable to Google Apps accounts).

config/environments/production.rb

config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
from __future__ import unicode_literals
from bottle import Bottle, request, response
from mypkg import analyse_data
# http://www.reddit.com/r/learnpython/comments/1037g5/whats_the_best_lightweight_web_framework_for/
# http://bottlepy.org/docs/dev/tutorial.html
app = Bottle()
@ourway
ourway / websse.py
Last active August 29, 2015 14:07 — forked from werediver/websse.py
"""
Simple demonstration of how to implement Server-sent events (SSE) in Python
using Bottle micro web-framework.
SSE require asynchronous request handling, but it's tricky with WSGI. One way
to achieve that is to use gevent library as shown here.
Usage: just start the script and open http://localhost:8080/ in your browser.
Based on:
@ourway
ourway / aggs.sh
Last active August 29, 2015 14:07 — forked from jprante/aggs.sh
curl -XDELETE 'localhost:9200/test'
curl -XPUT 'localhost:9200/test' -d '
{
"mappings" : {
"_default_": {
"properties" : {
"name" : { "type" : "string" },
"age" : { "type" : "integer" },
@ourway
ourway / falcon_patch.py
Created October 19, 2014 10:34
Falcon append_header fix
class Response(falcon.response.Response):
def __init__(self):
super(Response, self).__init__()
self.extra_headers = list()
def append_header(self, name, value):
'''Fixes the problem of multiple Cookie headers.
@input
name, value
@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 / 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)