Skip to content

Instantly share code, notes, and snippets.

View dtran320's full-sized avatar
🌊
Come co-work with us virtually! https://www.flow.club

David Tran dtran320

🌊
Come co-work with us virtually! https://www.flow.club
View GitHub Profile
#!/bin/bash
# Use apt-get to install necessary packages for installing from source
set -e
sudo apt-get install libncurses5-dev gcc g++ make
cd ~/
wget http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.36.tar.gz
tar -zxf mysql-5.1.36.tar.gz
@dtran320
dtran320 / simple_redis_profile.rb
Created April 25, 2012 00:50 — forked from joeyAghion/simple_redis_profile.rb
By sampling keys from your redis databases, this script tries to identify what types of keys are occupying the most memory.
#!/usr/bin/env ruby
# Evaluates a sample of keys/values from each redis database, computing statistics for each key pattern:
# keys: number of keys matching the given pattern
# size: approximation of the associated memory occupied (based on size/length of value)
# percent: the proportion of this 'size' relative to the sample's total
#
# Copyright Weplay, Inc. 2010. Available for use under the MIT license.
@dtran320
dtran320 / redis_session_backend.py
Created April 25, 2012 00:39 — forked from mikeyk/redis_session_backend.py
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(
@dtran320
dtran320 / gist:1106059
Created July 26, 2011 05:45
Extract referrer domain name in javascript
function getReferrerDomain() {
var url = document.createElement('a');
url.href = document.referrer;
return url.hostname;
}
@dtran320
dtran320 / overlay.html
Created May 13, 2011 07:45
Some CSS overlay stuff
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<style>
.container1, .container2 {
width: 300px; height: 200px; float: left;
padding: 10px; margin-right: 10px; margin-bottom: 10px;
}
.container1 {