Skip to content

Instantly share code, notes, and snippets.

View tuttinator's full-sized avatar

Caleb Tutty tuttinator

  • Jakarta, Indonesia
  • 05:31 (UTC +07:00)
View GitHub Profile
@tuttinator
tuttinator / Main.as
Created March 12, 2011 01:26
Gist to play music / sound in an ActionScript / Flash file
package {
import flash.net.URLRequest;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
public class Main extends MovieClip {
// timer for sound fade out
@tuttinator
tuttinator / pdf-search.rb
Created September 11, 2011 14:28
Fulltext search and highlight - and return a jpeg
require 'poppler'
require 'gdk_pixbuf2'
SCALE = 2
filename = "source.pdf"
doc = Poppler::Document.new(filename)
page = doc.get_page(0)
# render the page to an in-memory buffer
@tuttinator
tuttinator / grittest.rb
Created September 21, 2011 13:21
Grit example methods
require 'grit'
repo = Grit::Repo.new("/Users/Caleb/Documents/Rails Projects/welcomemat")
# loop through all git commits
puts repo.commits.each do |commit|
puts commit.author #author
puts commit.authored_date #datestamp
puts commit.message #git commit message
@tuttinator
tuttinator / scraper.rb
Last active December 10, 2015 18:58 — forked from anonymous/gist:4478191
Rough parliamentary questions scraper - just the list of links to actual questions
require 'capybara'
require 'capybara/dsl'
require 'capybara/mechanize'
module Parliament
class Question
attr_accessor :date, :number, :topic, :mp, :minister, :url
end
@tuttinator
tuttinator / gist:5894420
Created June 30, 2013 08:50
Constant definition in initialize method
[2] pry(main)> class Foo
[2] pry(main)* def initialize
[2] pry(main)* BAR = "something"
[2] pry(main)* end
[2] pry(main)* end
SyntaxError: (eval):4: dynamic constant assignment
BAR = "something"
^
@tuttinator
tuttinator / 0002400.geojson
Created July 16, 2014 08:57
Meshblock 0002400
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
require 'capybara'
require 'capybara/dsl'
require 'capybara/mechanize'
module Parliament
class Question
attr_accessor :date, :number, :topic, :mp, :minister, :url
end
;; chruby
(require 'chruby)
(chruby "ruby-2.1.3")
;; copy envs
(require 'exec-path-from-shell)
(let ((envs '("PATH" "GOPATH" "GEM_HOME" "GEM_ROOT" "BUNDLE_PATH")))
(exec-path-from-shell-copy-envs envs))
@tuttinator
tuttinator / gist:9ad0ccccc7ed9e7de377
Last active August 29, 2015 14:11
CSV dumping ground?
How's this for an idea - we build a crowd sourced community sandbox to upload
a CSV using a web form. Using a NoSQL database like MongoDB we could read the
header row of the CSV to create a collection with those fields. This means we
can get a basic JSON API for free (maybe paginated, etc) and with format
specifiers be able to download the original CSV again too. This would be
a set of URLs with a unique ID.
Maybe someone has already done something similar?
@tuttinator
tuttinator / [email protected]
Created April 26, 2015 10:55
Alaveteli SystemD unit files
[Unit]
Description=Alaveteli Sidekiq (%i)
After=docker.service
Requires=docker.service
[Service]
Restart=on-failure
RestartSec=10s