Skip to content

Instantly share code, notes, and snippets.

View MatthewCallis's full-sized avatar
🍖
Hungry Goriya

Matthew Callis MatthewCallis

🍖
Hungry Goriya
View GitHub Profile
@paulofierro
paulofierro / s3_gzip.rb
Last active August 29, 2015 13:57
Compressing JSON on S3
require 'zlib'
require 'stringio'
# Connect to the bucket and create the file
s3 = AWS::S3.new(access_key_id: 'S3_ACCESS_KEY', secret_access_key: 'S3_SECRET_KEY', region: 'S3_REGION')
bucket = s3.buckets['S3_BUCKET']
file = bucket.objects.create('S3_FILE_NAME', '')
# Set the content type and encoding. This is the important bit
options = {:acl => :public_read, :content_type => 'application/json', :content_encoding => 'gzip'}
#!/usr/bin/env ruby
$KCODE = 'utf8'
# 漢数字を数値に変換する
#
# * http://ja.wikipedia.org/wiki/%E6%BC%A2%E6%95%B0%E5%AD%97
# * http://www.akatsukinishisu.net/kanji/kansuji.html
module Kansuji
# -*- coding: utf-8 -*-
require 'open-uri'
require 'kconv'
#
#= SKK の人名辞書ファイルから架空の氏名を生成する (Ruby version)
#
# Authors:: 宮國 渡
# Copyright:: Copyright (c) 2009 Wataru MIYAGUNI <gonngo@gmail.com>
# URL:: http://github.com/gongo
@nebiros
nebiros / App_Thumb.php
Created February 23, 2010 15:06
Thumbnails lib
<?php
class App_Thumb
{
protected $_width = null;
protected $_oldWidth = null;
protected $_height = null;
protected $_oldHeight = null;
protected $_imagePath = null;
protected $_resource = null;
#!/usr/local/bin/ruby
# -*- coding: utf-8 -*-
require "cgi"
cgi = CGI.new
$KCODE = "UTF8"
class String
def fragments(n)
/*
To avoid polluting the global namespace this uses an anonymous
function which is called with either the URL for an external
JavaScript file or a function. In either case jQuery will be loaded
from the Google CDN before your code is executed so it's free to
depend on jQuery without checking for it and can do things like
jQuery.getScript() to load other components (e.g. jQuery UI),
stylesheets, etc.
*/
(function (target, msg) {
@Solvalou
Solvalou / Space Invaders - NES Assembly
Created May 17, 2010 18:13
Space Invaders NES Reconstruction
; iNES - Header
.inesprg 1 ; size of PRG-ROM, 16kB
.ineschr 1 ; size of CHR-ROM/RAM, 8kB
.inesmir 0 ; type of mirroring, 0 = horizontal, 1 = vertical
.inesmap 0 ; used mapper, 0 = no mapper
.bank 1
.org $FFFA
.dw int_return ; NMI_Routine($FFFA)
#!/usr/bin/ruby -w
require 'benchmark'
require 'set'
array = (1..1_000_000).to_a
hash = {}
array.map {|x| hash[x] = nil}
a_set = array.to_set
Benchmark.bm(15) do |x|
@nebiros
nebiros / Mysql.php
Created October 3, 2010 04:10
Mysql ala OOP, wrapper for some mysql_* functions
<?php
/**
* Mysql wrapper, to handle some mysql_* functions in a OOP way.
*
*/
class App_Db_Mysql {
const DEFAULT_ROW_COUNT = 10;
const DEFAULT_PAGE = 1;
@tobynet
tobynet / supermario_progress_bar_formatter.rb
Created January 25, 2011 18:59
SuperMarioSoundFormatter,it's one of supporting tools for EDD(Enjoyment Driven Development)
# -*- encoding: utf-8 -*-
# $ cat spec/spec.opts
# --require ~/lib/supermario_progress_bar_formatter.rb
# --format Spec::Runner::Formatter::SuperMarioProgressBarFormatter
require 'spec/runner/formatter/base_text_formatter'
require 'spec/runner/formatter/no_op_method_missing'
module Spec::Runner::Formatter