Skip to content

Instantly share code, notes, and snippets.

Kiran Jonnalagadda jace

Block or report user

Report or block jace

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@danieleds
danieleds / gist:326903084a196055a7c3
Created Sep 4, 2014
CodeMirror: indent with tab or spaces
View gist:326903084a196055a7c3
editor.addKeyMap({
"Tab": function (cm) {
if (cm.somethingSelected()) {
var sel = editor.getSelection("\n");
// Indent only if there are multiple lines selected, or if the selection spans a full line
if (sel.length > 0 && (sel.indexOf("\n") > -1 || sel.length === cm.getLine(cm.getCursor().line).length)) {
cm.indentSelection("add");
return;
}
}
@chadselph
chadselph / flaskwithcron.py
Last active Nov 28, 2019
flask with "cron"-like loop
View flaskwithcron.py
from flask import Flask, render_template, jsonify, request
from threading import Timer, Thread
from time import sleep
app = Flask(__name__)
@app.route("/api/<method>")
def api(method):
data = {
@mdpatrick
mdpatrick / postgresql_9.1_to_9.3_on_ubuntu_12.04
Last active Jun 21, 2018
Upgrade PostgreSQL from 9.1 to 9.3 on Ubuntu 12.04
View postgresql_9.1_to_9.3_on_ubuntu_12.04
# Probably excessive, but it makes these instructions simpler
sudo -i
# Add postgresql repo and update apt listing
echo "deb http://apt.postgresql.org/pub/repos/apt/ squeeze-pgdg main" > /etc/apt/sources.list.d/pgdg.
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
apt-get update
# For some reason this is necessary with PostgreSQL on Ubuntu 12.04
update-alternatives --remove postmaster.1.gz /usr/share/postgresql/9.1/man/man1/postmaster.1.gz
@goldsmith
goldsmith / numpy_os_x_10_9.sh
Last active Nov 30, 2017
How to install Numpy and Scipy on Mac OS X Mavericks (10.9) using Pip.
View numpy_os_x_10_9.sh
# set up flags for Numpy C extentions compiling
export CFLAGS="-arch i386 -arch x86_64"
export FFLAGS="-m32 -m64"
export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch i386 -arch x86_64"
export CC=gcc-4.2
export CXX="g++ -arch i386 -arch x86_64"
pip install numpy
# success!
@trustrachel
trustrachel / config.py
Created Oct 4, 2013
Flask-SQLAlchemy - separating reads and writes
View config.py
# This is not used unless SQLALCHEMY_BINDS is not present
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://{username}:{password}@{hostname}/{database}?charset=utf8'
SQLALCHEMY_BINDS = {
'master': 'mysql+pymysql://{username}:{password}@{hostname}/{database}?charset=utf8',
'slave': 'mysql+pymysql://{username}:{password}@{hostname}/{database}?charset=utf8'
}
@devoncrouse
devoncrouse / clean_audio.sh
Created May 7, 2013
Using Sox (http://sox.sourceforge.net) to remove background noise and/or silence from audio files (individually, or in batch).
View clean_audio.sh
# Create background noise profile from mp3
/usr/bin/sox noise.mp3 -n noiseprof noise.prof
# Remove noise from mp3 using profile
/usr/bin/sox input.mp3 output.mp3 noisered noise.prof 0.21
# Remove silence from mp3
/usr/bin/sox input.mp3 output.mp3 silence -l 1 0.3 5% -1 2.0 5%
# Remove noise and silence in a single command
View gfm.py
import re
from hashlib import md5
def gfm(text):
# Extract pre blocks.
extractions = {}
def pre_extraction_callback(matchobj):
digest = md5(matchobj.group(0).encode('utf-8')).hexdigest()
extractions[digest] = matchobj.group(0)
return "{gfm-extraction-%s}" % digest
View gfm.py
import re
from hashlib import md5
def gfm(text):
# Extract pre blocks.
extractions = {}
def pre_extraction_callback(matchobj):
digest = md5(matchobj.group(0)).hexdigest()
extractions[digest] = matchobj.group(0)
return "{gfm-extraction-%s}" % digest
@christian-oudard
christian-oudard / gfm.py
Created Jun 29, 2010
Github Flavored Markdown in Python
View gfm.py
import re
from hashlib import md5
def gfm(text):
# Extract pre blocks.
extractions = {}
def pre_extraction_callback(matchobj):
digest = md5(matchobj.group(0)).hexdigest()
extractions[digest] = matchobj.group(0)
return "{gfm-extraction-%s}" % digest
You can’t perform that action at this time.