Skip to content

Instantly share code, notes, and snippets.

View philippbosch's full-sized avatar

Philipp Bosch philippbosch

View GitHub Profile
@puppybits
puppybits / image64.sh
Created January 5, 2012 14:18
Create data URI image from Terminal command
#!/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=""
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@velocityzen
velocityzen / auth.py
Created September 26, 2011 16:30
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.
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'
@aaronrussell
aaronrussell / background_noise_function.rb
Created March 5, 2011 18:24
Sass implementation of the Noisy jquery plugin: https://github.com/DanielRapp/Noisy
require "rubygems"
require "chunky_png"
require "base64"
module Sass::Script::Functions
def background_noise(c, noise = 0.5, opacity = 0.08, size = 200, mono = false)
# Convert SASS numbers to Ruby classes
noise = noise.to_s.to_f if noise.is_a? Sass::Script::Number
@philippbosch
philippbosch / _animations.scss
Last active August 29, 2019 00:20
Compass mixins for CSS keyframe animations
@import "compass/css3/shared";
@mixin keyframes($name) {
@-webkit-keyframes $name {
@content;
}
@-moz-keyframes $name {
@content;
}
@RobertKolner
RobertKolner / disable_signals.py
Last active August 15, 2018 10:11
[Note: for a better version, visit here: https://github.com/RobertKolner/django-signal-disabler] Temporarily disable all signals in django
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,
@idan
idan / _more.scss
Created June 6, 2011 08:40
More is Less
$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;
@pamelafox
pamelafox / views.py
Created September 5, 2011 21:26
CORS on Python/Flask
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
@philippbosch
philippbosch / cross-browser-rgba-mixin.scss
Created July 19, 2010 10:49
image-less RGBA backgrounds for real browsers and Internet Explorer
@mixin rgba-background($color, $opacity) {
background-color: $color;
background-color: rgba($color, $opacity);
background-color: transparent\9;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#{'#'+hex(round($opacity*255)) + '' + hex(red($color)) + '' + hex(green($color)) + '' + hex(blue($color))},endColorstr=#{'#'+hex(round($opacity*255)) + '' + hex(red($color)) + '' + hex(green($color)) + '' + hex(blue($color))});
zoom: 1;
}
@rnorth
rnorth / per_app_postgres.sh
Last active December 18, 2015 10:59
A 'predeploy' script for dokku to automatically create an empty postgres database for new apps. Would require pre/post deploy hook support in dokku.
#!/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)