Skip to content

Instantly share code, notes, and snippets.

View pwnall's full-sized avatar
🎯
Currently focused on the needs of Fuchsia

Victor Costan pwnall

🎯
Currently focused on the needs of Fuchsia
View GitHub Profile
# Backs up all the photos from Google Picasa Web Albums.
#
# The script downloads the original version of the photos, and is not limited to
# 1600x1200 thumbnails.
#
# Author:: Victor Costan
# Copyright:: Copyright (C) 2010 Victor Costan
# License:: MIT
require 'yaml'
#!/usr/bin/ruby
# Prints the number of cores on your system.
# Requires the ohai rubygem.
require 'rubygems'
require 'ohai'
ohai = Ohai::System.new
ohai.all_plugins
# Wraps an OAuth2 access token for Facebook.
class FacebookToken < ActiveRecord::Base
# The user whose token this is.
belongs_to :user
validates :user, :presence => true
# A unique ID on the Facebook site for the user owning this token.
validates :external_uid, :length => 1..32, :presence => true
# The OAuth2 access token.
@pwnall
pwnall / gist:2519877
Created April 28, 2012 15:42
Multiple HTTP requests in a single Rails controller action

Whenever users sign into my application, or access its homepage, I check to see if I have recent Facebook data for them. If not, I synchronously fetch the data from Facebook. I'd do it asynchronously, but I don't want to add logic for rendering the homepage with incomplete information.

The controller code is the if statement that starts here: https://github.com/pwnall/mit_hack_2012/blob/master/app/controllers/session_controller.rb#L17

Facebook data is cached in the Profile model (each user has a profile), and in the UserFriendship model.

The model code that does the fetches is here: https://github.com/pwnall/mit_hack_2012/blob/master/app/models/profile.rb#L38

The code calls some code in the fbgraph gem to fetch profile information. It also calls the method below, which uses curl to follow redirects:

@pwnall
pwnall / build_coffeescript.sh
Created June 29, 2012 11:22
Builder for encap packages for Ruby, the Sass compiler, Node.js and the CoffeeScript compiler
#### node-coffeescript-1.3.3 encap package
## Requires: nodejs-0.8.0
## Set up the encap cage.
# NOTE: this dance ensures that the build process is properly contained
sudo mkdir /usr/local/encap/node-coffeescript-1.3.3
sudo chown $USER:$USER /usr/local/encap/node-coffeescript-1.3.3
## Build and install in the encap cage.
@pwnall
pwnall / config.log
Created August 11, 2012 05:17
config.log after attempting to install Inkscape
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by inkscape configure 0.48.3.1, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ ./configure --disable-dependency-tracking --enable-lcms --disable-poppler-cairo --prefix=/usr/local/Cellar/inkscape/0.48.3.1
## --------- ##
## Platform. ##
@pwnall
pwnall / Gemfile
Created October 18, 2012 19:47
Grader sample code
source :rubygems
gem 'sinatra', '>= 1.3.1', require: 'sinatra/base'
gem 'shotgun', '>= 0.9'
gem 'thin', '>= 1.3.1'
@pwnall
pwnall / fedora_kernel37.sh
Created December 1, 2012 03:51 — forked from mikefaille/Fed_install_3.7_rc6_krnl
Fedora install kernel 3.7 rc7 x64
sudo yum install http://kojipkgs.fedoraproject.org/packages/kernel/3.7.0/0.rc7.git0.1.fc19/x86_64/kernel-3.7.0-0.rc7.git0.1.fc19.x86_64.rpm http://kojipkgs.fedoraproject.org/packages/kernel/3.7.0/0.rc7.git0.1.fc19/x86_64/kernel-devel-3.7.0-0.rc7.git0.1.fc19.x86_64.rpm http://kojipkgs.fedoraproject.org/packages/kernel/3.7.0/0.rc7.git0.1.fc19/x86_64/kernel-headers-3.7.0-0.rc7.git0.1.fc19.x86_64.rpm http://kojipkgs.fedoraproject.org/packages/kernel/3.7.0/0.rc7.git0.1.fc19/x86_64/kernel-modules-extra-3.7.0-0.rc7.git0.1.fc19.x86_64.rpm --nogpg
@pwnall
pwnall / chrome_android_buid.md
Last active December 14, 2015 11:09
Step-by-step instructions for setting up a VM that builds Chrome for Android

Build Instructions for libchromewebview.so

This document contains step-by-step instructions for building a Chromium-powered Android WebView.

Chromium's build process is a bit fussy, and the Android target is even more fussy, so the least painful way of getting it done is to set up a VM with the exact software that the build process was designed for. The steps below accomplish this.

@pwnall
pwnall / 00-mapnik_failed_1082.md
Last active December 14, 2015 12:09
mapnik failed to build on 10.8.2

The output from HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install mapnik

  • stdout is in brew_install_stdout.log
  • stderr is in brew_install_stderr.log

The contents of ~/Library/Logs/Homebrew/mapnik/config.log is in library_logs_homebrew_mapnik_config.log

The output from brew doctor is in brew_doctor_output.log