Skip to content

Instantly share code, notes, and snippets.

View juliend2's full-sized avatar

Julien Desrosiers juliend2

View GitHub Profile
/*
Expanding color pixels on the current (and only loaded image)
*/
var doc = app.documents[0];
doc.colorSamplers.removeAll(); // otherwise it will create an error if there is already a colorSampler on this point
var offset = 4;
for (var w=0; w < doc.width; w+=offset) {
for (var h=0; h < doc.height; h+=offset) {
// ==UserScript==
// @name passwordsafe formatting
// @namespace jdesrosiers
// @description newlines to BR tags
// @include https://www.passwordsafe.com/secure/main.html
// ==/UserScript==
var nl2br = function(value) {
return value.replace(/\n/g, "<br />");
}
// ==UserScript==
// @name Layout Overlay
// @namespace jdesrosiers
// @include http://localhost/projectname/*
// ==/UserScript==
switch ( window.location.href.match(/([^\/]+\.html)$/i)[0] ) {
case 'index.html':
var mockupImg = 'indexlayout.jpg'; break;
case 'about.html':
require 'rubygems'
require 'anemone'
load 'global.rb' # contains the skip_links_like regex
# get all the html files that we need
Anemone.crawl("http://codex.wordpress.org/Function_Reference/") do |anemone|
anemone.skip_links_like $regex
anemone.on_pages_like /http\:\/\/codex.wordpress.org\/Function_Reference\// do |page|
puts page.url
matched = page.url.to_s.match /http\:\/\/codex.wordpress.org\/Function_Reference\/([_a-zA-Z0-9]+)$/
@juliend2
juliend2 / gist:757422
Created December 28, 2010 17:10
Photoshop Javascript to increment text layer value and save for Web (in a loop)
function sfwPNG24(saveFile){
var pngOpts = new ExportOptionsSaveForWeb;
pngOpts.format = SaveDocumentType.PNG
pngOpts.PNG8 = false;
pngOpts.transparency = true;
pngOpts.interlaced = false;
pngOpts.quality = 100;
activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts);
}
@juliend2
juliend2 / gist:761269
Created December 31, 2010 19:25
youtube video without a yt:statistics tag
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:yt="http://gdata.youtube.com/schemas/2007">
<id>http://gdata.youtube.com/feeds/api/videos/NpJMQ6Vebbw</id>
<published>2010-12-31T17:12:01.000Z</published>
<updated>2010-12-31T17:14:55.000Z</updated>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://gdata.youtube.com/schemas/2007#video"/>
<category scheme="http://gdata.youtube.com/schemas/2007/categories.cat" term="People" label="People"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="jus"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="orange"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="oasis"/>
@juliend2
juliend2 / gist:774905
Created January 11, 2011 18:52
video info spec with VCR
# at the end of video_info_spec.rb ...
context "vcr recorded request" do
use_vcr_cassette "fixtures/vcr_cassettes/youtube_recorded", :record => :new_episodes
it "should have no views to it" do
video = VideoInfo.new('http://www.youtube.com/watch?v=oQ49W_xKzKA')
video.view_count.should == 0
end
end
@juliend2
juliend2 / gist:774920
Created January 11, 2011 18:57
youtube_recorded.yml
---
- !ruby/struct:VCR::HTTPInteraction
request: !ruby/struct:VCR::Request
method: :get
uri: http://gdata.youtube.com:80/feeds/api/videos/oQ49W_xKzKA
body:
headers:
response: !ruby/struct:VCR::Response
status: !ruby/struct:VCR::ResponseStatus
code: 200
@juliend2
juliend2 / .vimrc
Created January 15, 2011 19:06
mon vimrc
if has("terminfo")
set t_Co=16
set t_AB=[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
set t_AF=[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
else
set t_Co=16
set t_Sf=[3%dm
set t_Sb=[4%dm
endif
@juliend2
juliend2 / gist:794918
Created January 25, 2011 13:36
Quebec sales taxes
montant = ARGV[0].to_f
TPSpercent = 5
TVQpercent = 8.5
myTPS = montant * TPSpercent / 100
myTVQ = (montant + myTPS) * TVQpercent / 100
total = montant + myTPS + myTVQ
puts total.round(2)