Skip to content

Instantly share code, notes, and snippets.

View zbrox's full-sized avatar

Rostislav zbrox

View GitHub Profile

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@mikeyk
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
@kylebarrow
kylebarrow / example.html
Created June 23, 2011 06:30
Prevent links in standalone web apps opening Mobile Safari
<!DOCTYPE html>
<head>
<title>Stay Standalone</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<script src="stay_standalone.js" type="text/javascript"></script>
</head>
<body>
<ul>
<li><a href="http://google.com/">Remote Link (Google)</a></li>
@omz
omz / gist:1102091
Created July 24, 2011 01:40
Creating arbitrarily-colored icons from a black-with-alpha master image (iOS)
// Usage example:
// input image: http://f.cl.ly/items/3v0S3w2B3N0p3e0I082d/Image%202011.07.22%2011:29:25%20PM.png
//
// UIImage *buttonImage = [UIImage ipMaskedImageNamed:@"UIButtonBarAction.png" color:[UIColor redColor]];
// .h
@interface UIImage (IPImageUtils)
+ (UIImage *)ipMaskedImageNamed:(NSString *)name color:(UIColor *)color;
@end
@esfand
esfand / Deploy
Created April 5, 2012 15:11
WebFaction Deploy Apps using Git
I've tried now for several hours understanding how to use Git with webfaction.
And even with the documentation I cannot get it to work.
I have a Django app at: webapps/django_app/project_name/
I have a Git repo at: webapps/git_app/repos/my_repo.git
I assume the following workflow:
Make som local changes
@moonhouse
moonhouse / geo_conv.rb
Created May 5, 2012 14:15
Convert RT90 to WGS84
def convert_rt90_to_wgs84(geopos)
# from http://mellifica.se/geodesi/gausskruger.js
geopos=geopos.first
x = geopos['x'].to_i
y = geopos['y'].to_i
axis = 6378137.0 # GRS 80.
flattening = 1.0 / 298.257222101 # GRS 80.
central_meridian = 15.0 + 48.0/60.0 + 22.624306/3600.0
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active November 15, 2025 02:35
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@macobo
macobo / palin.py
Last active December 16, 2015 11:49
Google code jam 2013, warmup. Palindrome task. https://code.google.com/codejam/contest/2270488/dashboard#s=p2
from bisect import bisect_left
from sys import stdin
def is_palin(n):
s = str(n)
return s == s[::-1]
def fair(n):
return is_palin(n) and is_palin(n**2)
@msurguy
msurguy / eloquent.md
Last active February 8, 2022 03:13
Laravel 4 Eloquent Cheat Sheet.

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

@willurd
willurd / web-servers.md
Last active November 10, 2025 16:13
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000