Skip to content

Instantly share code, notes, and snippets.

Avatar

Philipp Bosch philippbosch

View GitHub Profile
@RobertKolner
RobertKolner / disable_signals.py
Last active Aug 15, 2018
[Note: for a better version, visit here: https://github.com/RobertKolner/django-signal-disabler] Temporarily disable all signals in django
View disable_signals.py
from collections import defaultdict
from django.db.models.signals import *
class DisableSignals(object):
def __init__(self, disabled_signals=None):
self.stashed_signals = defaultdict(list)
self.disabled_signals = disabled_signals or [
pre_init, post_init,
pre_save, post_save,
@rnorth
rnorth / per_app_postgres.sh
Last active Dec 18, 2015
A 'predeploy' script for dokku to automatically create an empty postgres database for new apps. Would require pre/post deploy hook support in dokku.
View per_app_postgres.sh
#!/bin/bash
set -e
export APP_NAME=$1
export PGHOST=$(< $HOME/predeploy.d/postgres_host)
export PGUSER=admin
if [ -f $HOME/$APP_NAME/DATABASE_URL ]; then
# Database URL is already set - DB must exist
DATABASE_URL=$(cat $HOME/$APP_NAME/DATABASE_URL)
@thbar
thbar / Guardfile
Last active Dec 15, 2015
How to automatically restart the simulator in RubyMotion when code is updated (beta version!)
View Guardfile
require 'childprocess'
guard 'shell' do
watch %r{^app/(.+)\.rb$} do |m|
`killall rake`
# Why this:
# - spawn a child process to avoid locking Guard
# - make sure that the child process has stdout and stdin otherwise it crashes
# - bonus point: get REPL access in the simulator!
@philippbosch
philippbosch / _animations.scss
Last active Aug 29, 2019
Compass mixins for CSS keyframe animations
View _animations.scss
@import "compass/css3/shared";
@mixin keyframes($name) {
@-webkit-keyframes $name {
@content;
}
@-moz-keyframes $name {
@content;
}
@mattlenz
mattlenz / image_with_color.rb
Created Aug 20, 2012
Solid-color (stretchable) UIImage generator for RubyMotion
View image_with_color.rb
# require 'bubble-wrap'
class UIImage
def self.imageWithColor(color)
if color.is_a?(String)
color = color.to_color
end
rect = CGRectMake(0, 0, 1, 1)
View ios-8-web-app.html
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@puppybits
puppybits / image64.sh
Created Jan 5, 2012
Create data URI image from Terminal command
View image64.sh
#!/bin/sh
# Examples:
# ./image64.sh myImage.png
# outputs: data:image/png;base64,xxxxx
# ./image64.sh myImage.png -img
# outputs: <img src="data:image/png;base64,xxxxx">
filename=$(basename $1)
xtype=${filename##*.}
append=""
@velocityzen
velocityzen / auth.py
Created Sep 26, 2011
This script take pictures from directory and post it to tumblr blog and then delete it. Tumblr API v2! This example for oath file upload.
View auth.py
import urlparse
import oauth2 as oauth
consumer_key = ''
consumer_secret = ''
request_token_url = 'http://www.tumblr.com/oauth/request_token'
access_token_url = 'http://www.tumblr.com/oauth/access_token'
authorize_url = 'http://www.tumblr.com/oauth/authorize'
@pamelafox
pamelafox / views.py
Created Sep 5, 2011
CORS on Python/Flask
View views.py
from flask import request, make_response,
def any_response(data):
ALLOWED = ['http://localhost:8888']
response = make_response(data)
origin = request.headers['Origin']
if origin in ALLOWED:
response.headers['Access-Control-Allow-Origin'] = origin
return response
View _more.scss
$less-column-width: 68px;
$less-gutter-width: 24px;
@function column-width($columns) {
@return ($less-column-width * $columns) + ($less-gutter-width * ($columns - 1));
}
@function grid-padding-px($columns) {
@if $columns == 10 {
@return 48px;