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
require 'date' | |
class Weeks | |
def initialize(number) | |
@number = number | |
end | |
def ago | |
return Date.today - (@number * 7) | |
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
# undo a commit (file changes and index changes preserved) | |
git reset --soft HEAD^ | |
# undo a commit (file changes preserved, index changes are rolled back) | |
git reset HEAD^ | |
# undo a commit (file changes and index changes rolled back) | |
git reset --hard HEAD^ |
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
# create a new post | |
rake new_post["title"] | |
# re-build the site including any recent changes | |
rake generate | |
# run WEBrick server locally on port 4000 | |
rake preview | |
# push changes to github (master branch) |
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
# create dump file from database | |
mysqldump wp_blog > 2012.1.7.mysql.dump.sql | |
# apply dump file to database wp_blog with user as root | |
mysql -u root wp_blog < 2012.1.7.mysql.dump.sql |
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
-- create database | |
create database wp_blog; | |
-- create user | |
create user uwp_blog@localhost identified by 'pass123'; | |
-- grant access | |
grant all privileges on wp_blog.* to uwp_blog@localhost; | |
-- list databases user has access to |
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
function getTwitterFollowersCount($screen_name) { | |
$url = 'http://api.twitter.com/1/users/show.json?screen_name='.$screen_name; | |
$session = curl_init($url); | |
curl_setopt($session, CURLOPT_HEADER, false); | |
curl_setopt($session, CURLOPT_RETURNTRANSFER, true); | |
$response = curl_exec($session); | |
curl_close($session); | |
$user = json_decode($response); | |
return $user->followers_count; | |
} |