Skip to content

Instantly share code, notes, and snippets.

@baopham
baopham / mobile-redirect.mkd
Created April 11, 2012 22:29
Mobile Redirect js Snippets

Redirect Mobile Devices

<script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "mobile.html";
}
//-->
@baopham
baopham / css-tips.css
Created April 12, 2012 19:16
CSS notes
/* Opacity */
filter:alpha(opacity=95); /* For IE */
-moz-opacity:0.95; /* Older versions of Mozilla */
-khtml-opacity: 0.95; /* For Sarari 1.x */
opacity: 0.95; /* General Usage */
@baopham
baopham / autovivification.py
Created April 18, 2012 17:45
Python Autovivification
class AutoVivification(dict):
"""Implementation of perl's autovivification feature."""
def __getitem__(self, item):
try:
return dict.__getitem__(self, item)
except KeyError:
value = self[item] = type(self)()
return value
a = AutoVivification()
@baopham
baopham / rails-note.md
Created April 22, 2012 02:09
Rails Note

Asset directories

In versions of Rails before 3.0 (including 3.0 itself), static assets lived in the public/ directory, as follows:

public/stylesheets
public/javascripts
public/images

Files in these directories are (even post-3.0) automatically served up via requests to http://example.com/stylesheets, etc.

@baopham
baopham / prompt.sh
Created April 27, 2012 18:10
Glue the bash prompt to the first column
PS1="\[\033[G\]$PS1"
@baopham
baopham / cmd.md
Created May 7, 2012 20:23
Command Line Notes

List Process IDs for a specific port

lsof -w -n -i tcp:8080

Hide/Show file on OSX

chflags hidden ~/Library
chflags nohidden ~/Library

@baopham
baopham / PDFMerger.java
Created May 9, 2012 22:37
Serve merged PDF on servlet
package testPackage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.itextpdf.text.Document;
@baopham
baopham / custom.theme
Created May 23, 2012 05:34
Custom theme for bpython in dark terminal
[syntax]
keyword = y
name = c
comment = m
string = g
error = r
number = G
operator = Y
punctuation = y
token = C
@baopham
baopham / password.module
Created May 25, 2012 22:46
Drupal module to remove forgotten password link
<?php
// $Id$
/**
* @file
* Module to remove the forgotten password link
*/
/**
@baopham
baopham / modal.html
Created May 28, 2012 19:35
Popup form -JQuery UI
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.8.20/themes/base/jquery-ui.css" type="text/css" media="all" />
<link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" />
<style>
body { font-size: 62.5%; }
label, input { display:block; }
input.text { margin-bottom:12px; width:95%; padding: .4em; }
fieldset { padding:0; border:0; margin-top:25px; }