Skip to content

Instantly share code, notes, and snippets.

Bastien Vaucher bastien

  • Zendesk
  • Copenhagen, Denmark
Block or report user

Report or block bastien

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Keybase proof

I hereby claim:

To claim this, I am signing this object:

bastien / gist:4155027
Created Nov 27, 2012
Creating a nested object from nested GET parameters
View gist:4155027
var obj = {};
var param1 = "monkey[foo][bar][test1]";
var param2 = "monkey[foo][foo][test2]";
var keys1 = param1.replace(/\]/g, '').split('[');
var keys2 = param2.replace(/\]/g, '').split('[');
var deserialize = function(obj, keys, value){
var pointer = obj;
var index = 0;
bastien / content.rb
Created Jul 6, 2012
Paperclip processor to convert PDF to JPG to go around problems with the old versions of imagemagick and ghostscript available on Heroku. This file is located in [APP_ROOT]/lib/paperclip_processors/ghostscript.rb
View content.rb
# Model using the ghostscript processor
class Content < ActiveRecord::Base
has_attached_file :resource,
:styles => { :preview => ["725x1200>", :jpg], :thumb => ["100x140>", :jpg] },
:processors => [:ghostscript, :thumbnail],
:convert_options => { :all => '-colorspace RGB -flatten -density 300 -quality 100' },
:path => ":page_path/:class/:id/:resource_token/:style/:filename"
bastien / findThreadedPages.jsx
Created Jun 29, 2012
Script for InDesign to detect on which pages the threaded text frames span to.
View findThreadedPages.jsx
var doc = app.activeDocument;
var page = doc.pages[0];
var page_ids = [];
var text_frames = page.textFrames;
for(var i=1; i<=text_frames.length; i++){
var text_frame = page.textFrames[0];
var threaded_text_frames = text_frame.parentStory.textContainers;
for(var j=1; j<= threaded_text_frames.length; j++){
var threaded_text_frame = threaded_text_frames[j-1];
if(!inArray(, page_ids)){
bastien / indesign_singlepage_replace.jsx
Created Jun 21, 2012
Imports a single page InDesign document into another
View indesign_singlepage_replace.jsx
var doc = app.activeDocument;
var docPath = doc.fullName;
var importDoc ='~/test_extract.indd'), false);
var pageToImport = importDoc.pages.firstItem();
importDoc.pages.add(LocationOptions.AT_END); // Documents must have at least 1 page
pageToImport.move(LocationOptions.AFTER, doc.pages.firstItem());
bastien / indd_page_extract.jsx
Created Jun 21, 2012
Extracting a page from an InDesign document (2 different approaches)
View indd_page_extract.jsx
var doc = app.activeDocument;
if(doc.saved == true)
alert("Save you file.");
bastien / CustomFlattenerPreset.jsx
Created Dec 6, 2011
Script generating custom PDF flattener export presets for InDesign
View CustomFlattenerPreset.jsx
function main(){
var myFlattenerPresetName = "MyCustomFlattenerPreset";
var myPDFExportPresetName = "MyPDFExport";
var tempFlattenerPreset = app.flattenerPresets.itemByName(myFlattenerPresetName);
if(tempFlattenerPreset != null){
var flattenerlevel = FlattenerLevel.LOW;
bastien / input.txt
Created Sep 6, 2011
Trying to write out files in UTF-8 that TextEdit, Pages, Word and open
View input.txt
Danish: æåø
Chinese: 我真累
bastien / gist:1154270
Created Aug 18, 2011
Working S3 Policy
View gist:1154270
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}',
You can’t perform that action at this time.