Skip to content

Instantly share code, notes, and snippets.

View danriti's full-sized avatar

Dan Riti danriti

View GitHub Profile
@farazdagi
farazdagi / jsonp-in-flask.py
Created July 18, 2011 15:54
JSONP in Flask
import json
from functools import wraps
from flask import redirect, request, current_app
def support_jsonp(f):
"""Wraps JSONified output for JSONP"""
@wraps(f)
def decorated_function(*args, **kwargs):
callback = request.args.get('callback', False)
if callback:
@pbertera
pbertera / freshdesk-sso.py
Last active March 14, 2019 13:05
Freshdesk Single sign-on in Python
import time
import hashlib
import hmac
import urllib
def get_sso_url(email, name, base_url, key, redirect_url=None, phone=None, company=None):
"""This function returns the Freshdesk SSO URL.
For more info look at https://goo.gl/NISgpr
"""
utctime = int(time.time())
@hawkup
hawkup / Install etcd On Ubuntu 14.04.md
Created July 4, 2015 22:06
Install etcd On Ubuntu 14.04
  • Install
curl -L  https://github.com/coreos/etcd/releases/download/v2.1.0-rc.0/etcd-v2.1.0-rc.0-linux-amd64.tar.gz -o etcd-v2.1.0-rc.0-linux-amd64.tar.gz
tar xzvf etcd-v2.1.0-rc.0-linux-amd64.tar.gz
cd etcd-v2.1.0-rc.0-linux-amd64
./etcd
  • by default etcd listening on port 2379 for client communication and on port 2380 for server to server communication

  • Test

@danriti
danriti / comments.js
Last active April 30, 2018 20:50
Display all hidden inline comments on a Github issue/pull request. Just copy+pasta into your JS console or make a bookmarklet.
$('.outdated-diff-comment-container').addClass('open');
@miku
miku / fdups.py
Created August 20, 2011 04:53
Find duplicate files in python.
# http://stackoverflow.com/questions/748675/finding-duplicate-files-and-removing-them/748908#748908
import sys
import os
import hashlib
def chunk_reader(fobj, chunk_size=1024):
"""Generator that reads a file in chunks of bytes"""
while True:
chunk = fobj.read(chunk_size)
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
# Download the compiled elasticsearch rather than the source.
wget http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.2.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
@zabirauf
zabirauf / gulpfile.js
Created October 19, 2015 00:11
Gulpfile for a frontend in React + ES6
var gulp = require('gulp'),
gutil = require('gulp-util'),
babelify = require('babelify'),
source = require('vinyl-source-stream'),
browserify = require('browserify'),
watchify = require('watchify'),
browserSync = require('browser-sync').create();
var paths = {
HTML: 'src/index.html',
@jimdoescode
jimdoescode / DateFromNow.js
Last active December 22, 2015 08:19
Easily format a past date with this object. It has two public methods one that will give a rough estimate with the largest part of time. Something like: 2 hours ago. The second will give you all the parts of time that have elapsed as an object. Parts that are too large are returned as null. Check the comments for more information.
/*
License: MIT
Easily formattable date difference.
DateFromNow(someDate).simple(); //ex. returns '3 days ago';
DateFromNow(someDate).parts(); //ex. returns {years: null, months: null, days: 3, hours: 8, minutes: 52, seconds: 43};
*/
# coding: utf-8
# Can ruby have method names have newlines/be crazy?
class BadKitty
FACE = "
|\\_/|
/ @ @ \\
( > º < )
`>>x<<´
@pglombardo
pglombardo / unicorn.rb
Created June 28, 2013 14:08
TraceView and the Unicorn Webserver: Disconnect/Reconnect Example
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 15
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end