Skip to content

Instantly share code, notes, and snippets.

View abraham's full-sized avatar
thanks a latte

Abraham Williams abraham

thanks a latte
View GitHub Profile
@abraham
abraham / annotations.php
Created May 29, 2010 20:21
Simple PHP example of adding annotations to tweets using TwitterOAuth
<?php
/**
* Note: Only select accounts have annotations enabled.
*
* If you have questions or comments please let me know. - @abraham
*
* Read about annotations:
* https://apiwiki.twitter.com/Annotations-Overview
*
* Get the TwitterOAuth source code:
@abraham
abraham / chat.txt
Created June 28, 2010 22:47
Funny https://t.imo.im exchange with spammer @julian080
@julian: @abraham I would like to start a chat with you on https://t.imo.im/?u=julian080
----------
me : hello?
julian080: hi
julian080: asl pls
julian080: yuo there?
me : asl? why did you @reply me on twitter?
julian080: k
julian080: My name is garvins julian
julian080: frm nig
@abraham
abraham / blog.abrah.am
Created June 29, 2010 04:21
Custom <head> code for http://blog.abrah.am
<!-- Custom -->
<link href='http://a3.twimg.com/profile_images/54160223/chart-black-small_mini.png' rel='icon' type='image/png'/>
<meta content='Young idealistic thoughts on #twitter, #google, #drupal, and #minimalism.' name='description'/>
<!-- Twitter Anywhere -->
<script src='http://platform.twitter.com/anywhere.js?id=412DNHegCUTUSZ67NnrQ&amp;v=1'>
</script>
<script type='text/javascript'>
@abraham
abraham / migrate.markdown
Created August 10, 2010 02:17
Terminal commands for migrating sites

Dump a MySQL database to a file

mysqldump -h example.com -u username -p database > file.sql

Import sql file into MySQL

mysql -u username -p
mysql: source file.sql

Compress a directory into a tar file and maintain permissions

@abraham
abraham / chargify-require-phone.js
Created August 20, 2010 02:43
Require phone numbers on Chargify hosted pages.
// Past into the custom javascript field for your hosted page to use javascript to require phone numbers.
var phoneLabel = jQuery('[for=subscription_customer_attributes_phone]');
phoneLabel.text('* Phone')
phoneInput = jQuery('#subscription_customer_attributes_phone');
jQuery('#hosted-payment-form').submit(function(){
if(phoneInput.val() == '') {
phoneLabel.text('* Phone: cannot be blank.')
phoneLabel.css('color', 'red');
phoneInput.click(function(){
@abraham
abraham / access_token.js
Created August 20, 2010 08:53
OAuth 2 with the Twitter API
localStorage.getItem("twttr_anywhere");
// "9436992-QKOV6cNsfeRe9Kagyy4AmQF7WX2efs3rRDgyEy7Bvsfeaf"
function fillAnywhereTweetBox(url) {
twttr.anywhere("1", function (twitter) {
var name = getBloggerPageName();
if (name == "the.hackerConundrum") {
var content = "Reading \"" + name +"\" - " + url + " by @abraham"
} else {
var content = "Reading \"" + name +"\" - " + url + " by @abraham"
}
twitter("#twitter-anywhere-gadget").tweetBox({
counter: 0,
@abraham
abraham / twitter.php
Created September 4, 2010 03:40
How to tweet with OAuth in three lines
<?php
// Download the latest version of TwitterOAuth from http://github.com/abraham/twitteroauth/downloads
// Unpack the download and place the twitteroauth.php and OAuth.php files in the same directory as this file.
// Register an application at http://dev.twitter.com/apps and from your new apps page get "my access token".
require_once('twitteroauth.php');
$connection = new TwitterOAuth('app consumer key', 'app consumer secret', 'my access token', 'my access token secret');
$status = $connection->post('statuses/update', array('status' => 'text to be tweeted'));
@abraham
abraham / recent-comments.js
Created September 5, 2010 05:43
Display recent comments from a blogger site.
<dl id="recentComments"></dl>
<script type="text/javascript">
function renderComments (json) {
var list = document.getElementById("recentComments");
for (var i = 0; i < json.feed.entry.length; ++i) {
var entry = json.feed.entry[i];
var dt = document.createElement("DT");
var dd = document.createElement("DD");
var href;
@abraham
abraham / install.sh
Created September 8, 2010 04:02
user-data script to setup ec2 ubuntu servers
#!/bin/bash
set -e -x
export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get upgrade -y
tasksel install lamp-server
apt-get install git-core
echo "Please remember to set the MySQL root password!"