Skip to content

Instantly share code, notes, and snippets.

View juliend2's full-sized avatar

Julien Desrosiers juliend2

View GitHub Profile
def update_cakemail(user,nom,prenom,email,listid,postalcode)
#Find the user in the list to see if he already exist
findPars = CakeLibrary::CakeHash.new()
findPars['client_id'] = CLIENT_ID
findPars["user_key"] = user["user_key"].to_s
findPars["list_id"] = listid
findPars["limit"] = 1
findPars["offset"] = 0
findPars["query"] = '`email` LIKE "%' + email + '"'
res = CakeLibrary::CakeList.Search(findPars)
@juliend2
juliend2 / gist:2820278
Created May 28, 2012 17:49
__() in javascript
window._lang = 'fr';
var translations = {
'String to Translate': 'Chaîne à traduire',
'something': 'quelque chose'
};
var __ = function(msgid) {
if (window._lang === 'fr' && (msgid in translations)) {
return translations[msgid];
@juliend2
juliend2 / get_icon_for_attachment.php
Created May 4, 2012 12:20
Return an icon image path for the given attachment ID
<?php
function get_icon_for_attachment($post_id) {
$base = get_template_directory_uri() . "/images/icons/";
$type = get_post_mime_type($post_id);
switch ($type) {
case 'image/jpeg':
case 'image/png':
case 'image/gif':
return $base . "image.png"; break;
@juliend2
juliend2 / .bash_profile
Created December 17, 2011 00:44
my .bash_profile
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
export DROPBOXDIR="/Users/jdesrosiers/Dropbox"
# add bicycle's cli in the path
export PATH="$PATH:/Applications/XAMPP/htdocs/lib/bicycle/bin:$HOME/.local/bin"
@juliend2
juliend2 / review.rb
Created July 12, 2011 16:34
review model
class Review < ActiveRecord::Base
# ... some other code here ...
def self.form_fields
[
{:name=>:journalist_name,:type=>:text_field},
{:name=>:publication,:type=>:text_field},
{:name=>:city,:type=>:text_field},
{:name=>:title_en,:type=>:text_field},
@juliend2
juliend2 / joiedmin_form_builder.rb
Created July 12, 2011 16:31
Joiedmin Form builder
class Padrino::Helpers::FormBuilder::JoiedminFormBuilder < Padrino::Helpers::FormBuilder::AbstractFormBuilder
# Here we have access to a number of useful variables
#
# ** template (use this to invoke any helpers)(ex. template.hidden_field_tag(...))
# ** object (the record for this form) (ex. object.valid?)
# ** object_name (object's underscored type) (ex. object_name => 'admin_user')
#
# We also have access to self.field_types => [:text_field, :text_area, ...]
# In addition, we have access to all the existing field tag
# helpers (text_field, hidden_field, file_field, ...)
@juliend2
juliend2 / crud_views.haml
Created July 12, 2011 16:25
Sinatra CRUD views
-# new.haml:
- form_for @acclaim, '/admin/acclaims/new', :multipart=>true, :method=>'post' do |f|
= f.error_messages
= f.crud_fields
%p.buttons
= f.submit "Create",:class=>'wymupdate'
= link_to 'Back', '/admin/acclaims'
@juliend2
juliend2 / plugin.js
Created July 1, 2011 17:35
my version of mediaembed's plugin.js
/*
* @example An iframe-based dialog with custom button handling logics.
*/
( function() {
CKEDITOR.plugins.add( 'MediaEmbed',
{
requires: [ 'iframedialog' ],
init: function( editor )
{
var me = this;
@juliend2
juliend2 / gist:865008
Created March 10, 2011 21:52
ooc install
macbook-pro-de-julien-desrosiers:rock juliend2$ make rescue
git pull
Already up-to-date.
rm -rf build/
wget http://commondatastorage.googleapis.com/rock-linux/rock-bootstrap-only.tar.bz2 -O - | tar xjvmp
--2011-03-10 16:47:48-- http://commondatastorage.googleapis.com/rock-linux/rock-bootstrap-only.tar.bz2
Resolving commondatastorage.googleapis.com... 209.85.225.132
Connecting to commondatastorage.googleapis.com|209.85.225.132|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 46 [application/x-bz2]
@juliend2
juliend2 / gist:848390
Created March 1, 2011 00:50
imagescience error
macbook-pro-de-julien-desrosiers:mycarrierwave juliend2$ rake spec --trace
(in /Users/juliend2/Code/Ruby/mycarrierwave)
** Invoke spec (first_time)
** Execute spec
/Users/juliend2/.ruby_inline/Inline_ImageScience_cdab.c:2:23: error: FreeImage.h: No such file or directory
/Users/juliend2/.ruby_inline/Inline_ImageScience_cdab.c: In function ‘unload’:
/Users/juliend2/.ruby_inline/Inline_ImageScience_cdab.c:8: error: ‘FIBITMAP’ undeclared (first use in this function)
/Users/juliend2/.ruby_inline/Inline_ImageScience_cdab.c:8: error: (Each undeclared identifier is reported only once
/Users/juliend2/.ruby_inline/Inline_ImageScience_cdab.c:8: error: for each function it appears in.)
/Users/juliend2/.ruby_inline/Inline_ImageScience_cdab.c:8: error: ‘bitmap’ undeclared (first use in this function)