This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Some sample codes | |
// For more information, see http://pear.php.net/manual/en/package.http.http-request.php | |
require_once "HTTP/Request.php"; | |
// request url | |
$url = "http://www.example.com"; | |
$option = array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### in Terminal | |
# create rails app | |
rails new test_app | |
############ start: edit Gemfile ############## | |
#wrap sqlite3 in | |
group :test, :development do | |
gem 'sqlite3' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mysql_connect.rb - simple MySQL script using Ruby MySQL module | |
require "mysql" | |
begin | |
# connect to the MySQL server | |
dbh = Mysql.real_connect("localhost", "testuser", "testpass", "testdb") | |
# get server version string and display it | |
puts "Server version: " + dbh.get_server_info | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Herodu Dev Center Doc: | |
# http://devcenter.heroku.com/articles/memcache | |
# Dalli gem heroku url: | |
# https://github.com/mperham/dalli | |
####################### | |
# Local Setup memcached | |
####################### | |
sudo port install memcached |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
mkdir -p /Library/Application\ Support/TextMate/ | |
sudo chown -R $(whoami) /Library/Application\ Support/TextMate | |
cd /Library/Application\ Support/TextMate/ | |
if [[ -d Bundles/.svn ]] ; then | |
cd Bundles && svn up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'open-uri' | |
require 'rexml/document' | |
require 'mechanize' | |
# ------------------------ | |
YOUR_GOOGLE_ACCOUNT = 'your@gmail.com' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#--- | |
# Excerpted from "Metaprogramming Ruby", | |
# published by The Pragmatic Bookshelf. | |
# Copyrights apply to this code. It may not be used to create training material, | |
# courses, books, articles, and the like. Contact us if you are in doubt. | |
# We make no guarantees that this code is fit for any purpose. | |
# Visit http://www.pragmaticprogrammer.com/titles/ppmetr for more book information. | |
#--- | |
# the benchmark shows that ghost_reverse( ) is about twice as slow as reverse( ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def sex_code | |
if ["male", "男"].include? self | |
0 | |
elsif self == "女" | |
1 | |
else | |
self | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Disable Rails's static asset server (Apache or nginx will already do this) | |
config.serve_static_assets = false | |
# Compress JavaScripts and CSS | |
config.assets.compress = true | |
# Don't fallback to assets pipeline if a precompiled asset is missed | |
config.assets.compile = false | |
# Generate digests for assets URLs |
OlderNewer