Skip to content

Instantly share code, notes, and snippets.

bundle install
Fetching source index from http://rubygems.org/
Using rake 10.1.0
Using i18n 0.6.5
Using minitest 4.7.5
Using multi_json 1.8.1
Using atomic 1.1.14
Using thread_safe 0.1.3
Using tzinfo 0.3.38
Using activesupport 4.0.0
@andrewwho
andrewwho / APIController.cs
Created May 2, 2014 16:24
MVC Unit Test with Mock
public class HomeController : Controller
{
public ActionResult Index()
{
return Json(true, JsonRequestBehavior.AllowGet);
}
}
var connect = require('connect');
var querystring = require('querystring');
var utils = require('util');
connect.createServer(
connect.static(__dirname)
).use(function(req, res){
if (req.method == 'POST') {
console.log("[200] " + req.method + " to " + req.url);
var fullBody = '';
@andrewwho
andrewwho / user.rb
Created June 21, 2012 18:16 — forked from jlogsdon/user.rb
hurray
class User < ActiveRecord::Base
def fetch_facebook_image
return false if authentications.blank?
auth = authentications.find_by_provider('facebook')
remote_image_url = "https://graph.facebook.com/#{auth.uid}/picture?type=large"
self.save
end
end
namespace :images do
desc "populating user.image"
task :pull => :environment do
print "This task will pull FB images into user.image if user has fb authentications. Confirm? [y/n]: "
answer = $stdin.gets.chomp()
if answer == 'y'
# User.all.each do |u|
u = User.find(50)
if !u.authentications.blank?
# grab the image from facebook and store it in the cloud.