Skip to content

Instantly share code, notes, and snippets.

require 'twitter'
Twitter.configure do |config|
config.consumer_key = 'xxx'
config.consumer_secret = 'xxx'
config.oauth_token = 'xxx'
config.oauth_token_secret = 'xxx'
end
threads = []
@codeincontext
codeincontext / gist:3033933
Created July 2, 2012 15:56
Konami code using the Gamepad API
<!DOCTYPE html>
<html>
<head>
<title>Gamepad Shit</title>
<script type="text/javascript"></script>
<style type="text/css"></style>
</head>
<body>
<h1>Gamepad Shit</h1>
@codeincontext
codeincontext / gist:3046692
Created July 4, 2012 10:45
How long does it take you to retweet things from Hacker News?
<!DOCTYPE html>
<html>
<head>
<title>How Old Was That?</title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
var username = "";
$.xhrPool = [];
@codeincontext
codeincontext / deletweet.rb
Created July 23, 2012 20:47
Keep a log of every tweet deleted by people you follow
require 'daemons'
require 'tweetstream'
$output_file = '???/deleted_tweets.txt'
Daemons.run_proc(
'deletweet',
log_output: true,
dir_mode: :script
) do
@codeincontext
codeincontext / gist:3190716
Created July 27, 2012 22:12
how much have you spammed your friends today?
require 'rubygems'
require 'twitter'
require 'active_support/core_ext'
timeline = Twitter.user_timeline("skattyadz", count: 200, include_rts: true)
puts timeline.select{|t| t.created_at > 1.day.ago}.count
@codeincontext
codeincontext / gist:3482669
Created August 26, 2012 19:05
canvas demo
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<h1>canvas</h1>
<canvas width="400" height="400" id="canvasElement"></canvas>
@codeincontext
codeincontext / gist:3694924
Created September 10, 2012 23:59
because meh. Let's not block the ui for too long in one go
var i = 0;
var addPhotoInterval = setInterval(function() {
instawall.renderImage(data.data[i++]);
if (i == data.data.length) clearInterval(addPhotoInterval);
}, 10);
@codeincontext
codeincontext / gist:3707167
Created September 12, 2012 14:53
Facebook and Twitter login with Sinatra
require 'rubygems'
require 'sinatra'
require 'json'
require 'omniauth'
require 'omniauth-facebook'
require 'omniauth-twitter'
class SinatraApp < Sinatra::Base
configure do
set :sessions, true
@codeincontext
codeincontext / gist:3852976
Created October 8, 2012 14:59
Generate a thumbnail with imagemagick, maintining aspect ratio and cropping as needed
convert 1.jpg -scale '225x225^' -gravity center -extent 225x225 1-square.jpg
@codeincontext
codeincontext / gist:3862543
Created October 10, 2012 01:11
Photo capture, manipulation, and upload in iOS6 Safari
<!DOCTYPE html>
<html>
<head>
<title>iOS6 Safari Photo Capture Demo</title>
<script type="text/javascript">
window.onload = function() {
var input = document.getElementById("input");
input.addEventListener("change", handleFile);
}