Skip to content

Instantly share code, notes, and snippets.

View bastien's full-sized avatar

Bastien Vaucher bastien

  • Zendesk
  • Copenhagen, Denmark
View GitHub Profile
@bastien
bastien / gist:1154270
Created August 18, 2011 15:10
Working S3 Policy
bucket = ENV['S3_BUCKET']
access_key = ENV['S3_KEY']
secret = ENV['S3_SECRET']
key = "temp/"
content_type = "application/pdf"
expiration = 5.hours.from_now.utc.strftime('%Y-%m-%dT%H:%M:%S.000Z')
max_filesize = 500.megabytes
acl = 'public-read'
policy = Base64.encode64(
"{'expiration': '#{expiration}',
@bastien
bastien / gist:1106844
Created July 26, 2011 14:05
Failing to creating the dialog switcher
#include "VCPlugInHeaders.h"
// Interface includes:
#include "ISession.h"
#include "IApplication.h"
#include "IDialogMgr.h"
#include "IDialog.h"
#include "IDialogCreator.h"
#include "IK2ServiceProvider.h"
@bastien
bastien / irbrc.rb
Created July 8, 2009 14:21
To show SQL Statements in the rails console
# To show SQL Statements in the rails console
# copy this code to ~/.irbrc
# code found there http://frozenplague.net/2008/12/showing-sql-statements-in-scriptconsole/
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER')
require 'logger'
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end
# Given a chinese character, fetch its ethymology through http://www.internationalscientific.org/
#
require 'rubygems'
require 'open-uri'
require 'hpricot'
require 'cgi'
def get_ethymology(chinese)
doc = Hpricot(open("http://www.internationalscientific.org/CharacterASP/CharacterEtymology.aspx?characterInput=#{ CGI.escape(chinese) }"))
# Extracts the hexadecimal code from a string and converts it into the corresponding unicode character
#
# code found there -> http://www.nabble.com/Euro-currency-symbol-td22795833.html ( by David Wright )
def convert(code)
return [code.gsub("U+", "").hex].pack("U")
end
puts convert("U+634F") # -> 捏
@bastien
bastien / gist:704
Created July 22, 2008 07:51
Scroll to the bottom of an element using Prototype and Scriptaculous wokrs under Firefox and Safari (not tested under ie)
/* Scroll to the bottom of an element using Prototype and Scriptaculous
wokrs under Firefox and Safari (not tested under ie)
*/
function scrollToBottom(element)
{
var offset= window.innerHeight - $(element).getHeight() -10 ;
Effect.ScrollTo(element, {offset:-offset})
}