Skip to content

Instantly share code, notes, and snippets.

@frenchtoast747
frenchtoast747 / decorator.py
Last active July 4, 2019 17:13
A Python decorator that preserves everything about the original function being decorated.
import types
class decorator(object):
"""
When using a decorator, the function that is being decorated
loses its __name__, docstring, and signature.
For example, consider the generic decorator ``my_decorator``:
def my_decorator(fn):
@jshaw
jshaw / underscore-template-conditional.js
Created July 19, 2012 13:55
Underscore.js template conditional example
// If URL is available URL link the image
// Otherwise just display the image
<% if ( instagram_link_url ) { %> <a href="<%= instagram_link_url %>" target="_blank"> <% } %>
<img src="<%= url %>" alt="<%= username %>" />
<% if ( instagram_link_url ) { %> </a> <% } %>
// Example 2 - Check if formated date
<% if (typeof(date) != "undefined") { %>
<span class="date"><%= date %></span>
<% } %>
@jamescasbon
jamescasbon / example.py
Created June 20, 2012 21:27
Tornado github API client
import tornado.ioloop
import tornado.web
import tornado.escape
import tornado.options
import tornado.httputil
import jinja2
import pyjade.compiler
import coffeescript
import markdown
@fliphess
fliphess / tornado basic auth
Last active February 22, 2020 22:35
basic auth with "htpasswd" file - auth example for tornado webserver
#!/usr/bin/env python
# also check https://gist.github.com/fliphess/7836479
import tornado.ioloop
import tornado.web
import base64
import netaddr
import bcrypt
def require_basic_auth(handler_class):
@killercup
killercup / Readme.md
Created February 7, 2014 18:34
Image Processing Server: Resizer and Optimizer

Image Resizer and Optimizer

Idea: grunt-contrib-imagemin as a Service

Tech Stack

  • nginx
  • luajit
  • imagemagick
  • OptiPNG, pngquant, jpegtran and gifsicle
@asmallteapot
asmallteapot / brainerd.py
Created January 24, 2011 15:42
Simple Markdown server in Python. Assumes you have Markdown files in ~/Text. Access ~/Text/Hello.mdown at http://localhost:5000/w/Hello.
#!/usr/bin/env python
# -*- coding: utf8 -*-
from flask import Flask, redirect, url_for
from markdown import markdown
import os
import re
# create the app
# TODO: load config/template from files, with fallbacks
function Get-WebFile {
param(
[Parameter(Mandatory=$true)]
$Uri,
[string] $OutFile,
[string] $Hash,
[string] $HashAlgorithm = 'SHA256'
)
if (-not $OutFile) {
@srideepprasad
srideepprasad / ajaxhook.js
Created October 15, 2012 05:21
Ajax Hook.js - A simple Ajax Callback Interceptor
/*
AjaxHook.js - A simple utility library for intercepting Ajax calls.
This may be useful to inject simple interceptors to analyze pr capture Ajax traffic and may be even useful for automation tests to determine when an Ajax response returns.
To use :
1>Create a new AjaxHook object
var hook = new AjaxHook();
@dansku
dansku / geo-distance.py
Created May 31, 2013 01:23
Measuring distance from two Geo-Points in Python
import math
def distance(lat1, long1, lat2, long2):
R = 6371 # Earth Radius in Km
dLat = math.radians(lat2 - lat1) # Convert Degrees 2 Radians
dLong = math.radians(long2 - long1)
lat1 = math.radians(lat1)
lat2 = math.radians(lat2)
a = math.sin(dLat/2) * math.sin(dLat/2) + math.sin(dLong/2) * math.sin(dLong/2) * math.cos(lat1) * math.cos(lat2)
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
@ninhanh
ninhanh / WAHH_Task_Checklist.md
Created June 28, 2019 06:46 — forked from amotmot/WAHH_Task_Checklist.md
The Web Application Hacker's Handbook - Task Checklist - Github-Flavored Markdown