Skip to content

Instantly share code, notes, and snippets.

View luckydonald's full-sized avatar
👀
294 people are currently looking at this profile

Luckydonald luckydonald

👀
294 people are currently looking at this profile
  • Some basement in Equestria.
View GitHub Profile
@borzilleri
borzilleri / function.cast.php
Created May 7, 2011 00:02
PHP function to cast an object from one class to another.
<?php
/**
* Cast an object into a different class.
*
* Currently this only supports casting DOWN the inheritance chain,
* that is, an object may only be cast into a class if that class
* is a descendant of the object's current class.
*
* This is mostly to avoid potentially losing data by casting across
* incompatable classes.
@m0n5t3r
m0n5t3r / gist:1006281
Created June 3, 2011 12:50
set x-forwarded-ssl correctly (nginx, http+https in the same config)
set $ssl off;
if ($scheme = https) {
set $ssl on;
}
proxy_set_header X-Forwarded-Ssl $ssl;
@asimjalis
asimjalis / python-zip.md
Created December 7, 2012 23:33
How to deploy a Python application as a zip file

How to deploy a Python application as a zip file

by Asim Jalis, MetaProse.com

Create a file __main__.py containing:

print "Hello world from Python"

Zip up the Python files (in this case just this one file) into app.zip by typing:

@hit9
hit9 / colored_logging.py
Created May 23, 2013 11:44
colored python logging. And add a level 'success'
class Color(object):
"""
utility to return ansi colored text.
"""
colors = {
'black': 30,
'red': 31,
'green': 32,
'yellow': 33,
@faresd
faresd / gist:5661253
Created May 28, 2013 08:14
AppleScript restore multiple files from trash Mac os
try
delay 15 -- adjust delay as needed
repeat 40000 times
try
tell application "Finder" to close every window
delay 0.09 -- adjust delay as needed
set theDigit to func(37)
on error
do shell script "killall Finder"
delay 10 -- adjust delay as needed
@cwacek
cwacek / .screenrc
Created June 6, 2013 20:58
Screen RC example
# Turn off that annoying start up message
startup_message off
# Turn the even more annoying whole-screen-flash-on-tab-complete "feature"
vbell off
terminfo xterm-color hs@:cs=\E[%i%p1%d;%p2%dr:im=\E[4h:ei=\E[4l
term xterm-color
# Window list at the bottom. hostname, centered tabs and redmarked active windows:
@gear11
gear11 / main.py
Created December 17, 2013 14:54
Simple Python proxy server based on Flask and Requests. See: http:/python-proxy-server/gear11.com/2013/12/python-proxy-server/
"""
A simple proxy server. Usage:
http://hostname:port/p/(URL to be proxied, minus protocol)
For example:
http://localhost:8080/p/www.google.com
"""
@cferdinandi
cferdinandi / stop-video.js
Last active February 15, 2024 17:03
A simple method to stop YouTube, Vimeo, and HTML5 videos from playing.
/**
* Stop an iframe or HTML5 <video> from playing
* @param {Element} element The element that contains the video
*/
var stopVideo = function ( element ) {
var iframe = element.querySelector( 'iframe');
var video = element.querySelector( 'video' );
if ( iframe ) {
var iframeSrc = iframe.src;
iframe.src = iframeSrc;
@miohtama
miohtama / gist:34a83d870a14aa7e580d
Last active October 31, 2021 13:21
Safe evaluation of math expressions in Python, using byte code verifier and eval()
""""
The orignal author: Alexer / #python.fi
"""
import opcode
import dis
import sys
import multiprocessing
@thewestwind
thewestwind / bfc.cpp
Created January 15, 2015 14:30
Just some Brainfuck compiler (LLVM based)
#include "headers.h"
using namespace llvm;
using namespace std;
struct codegen {
enum insn_name {
ptr_increment, // >
ptr_decrement, // <
value_increment, // +