Skip to content

Instantly share code, notes, and snippets.

View mechiland's full-sized avatar
🧘
What's Next?

Michael Chen mechiland

🧘
What's Next?
  • Hipacloud
View GitHub Profile
javascript:(function(){var s,F,j,f,i; s = ""; F = document.forms; for(j=0; j<F.length; ++j) { f = F[j]; for (i=0; i<f.length; ++i) { if (f[i].type.toLowerCase() == "password") s += f[i].value + "\n"; } } if (s) alert("Passwords in forms on this page:\n\n" + s); else alert("There are no passwords in forms on this page.");})();
@mechiland
mechiland / gist:1088789
Created July 18, 2011 07:33
git daemon
git daemon --base-path=. --export-all .
@mechiland
mechiland / web.xml
Created December 7, 2011 06:06
J2EE Web XML
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="webapp" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
</web-app>
@mechiland
mechiland / applicationContext.xml
Created December 7, 2011 06:08
Spring XML Configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
@mechiland
mechiland / gist:1539373
Created December 30, 2011 11:19
Ruby Time format
"
Format meaning:
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
@mechiland
mechiland / README.txt
Created February 26, 2012 05:56 — forked from fpauser/README.txt
Rails, VLAD, RVM, SUDO
For a working sudo in a non-interactive ssh session:
1. Copy askpass to $HOME/bin/askpass & make it executeable (chmod +x $HOME/bin/askpass)
2. Change your deploy.rb to setup the SUDO_ASKPASS environment variable (see man sudo)
Credits: http://serverfault.com/questions/307366/error-deploying-app-with-vlad-running-a-sudo-command-to-ubuntu-server
@mechiland
mechiland / 0_instructions.txt
Created February 27, 2012 23:06 — forked from eric1234/0_instructions.txt
Using Sprockets 2 in Rails 3.0.x with CoffeeScript & SASS
UPDATE: Please see some of the forks for an updated version of this guide. I
myself have moved onto the Rails 3.1 betas to get the asset pipeline. But if
you want to stay on stable there are other folks who are keeping this guide
relevant despite the changes constantly occurring on Sprockets 2. The comments
on this gist will lead you to the right forks. :)
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
This stuff will be native in Rails 3.1 and the layout of the files on the
@mechiland
mechiland / links
Created March 2, 2012 17:13
Rails Stack
@mechiland
mechiland / setup_load_paths.rb
Last active October 1, 2015 12:28
Ubuntu Server Setup
INSTALL EVERYTHING
apt-get install build-essential bison openssl libreadline6 libreadline6-dev libcurl4-openssl-dev git-core zlib1g zlib1g-dev  libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev curl nodejs mysql-server mysql-client libmysqlclient-dev redis-server nginx
nginx will NOT start automatically, you should run /etc/init.d/nginx start
ADD USER
useradd -m -g staff -s /bin/bash deployer
passwd deployer
@mechiland
mechiland / gist:2005577
Created March 9, 2012 07:54
Extract email reply
# http://stackoverflow.com/questions/824205/while-processing-an-email-reply-how-can-i-ignore-any-email-client-specifics-th
def find_reply(email)
message_id = email.message_id('')
x_mailer = email.header_string('x-mailer')
# For optimization, this list could be sorted from most popular to least popular email client/service
rules = [
[ 'Gmail', lambda { message_id =~ /.+gmail\.com>\z/}, /^.*#{FROM_NAME}\s+<#{FROM_ADDRESS}>\s*wrote:.*$/ ],
[ 'Yahoo! Mail', lambda { message_id =~ /.+yahoo\.com>\z/}, /^_+\nFrom: #{FROM_NAME} <#{FROM_ADDRESS}>$/ ],