Skip to content

Instantly share code, notes, and snippets.

View prcaen's full-sized avatar

Pierrick CAEN prcaen

View GitHub Profile
@prcaen
prcaen / start_workers.sh
Created May 20, 2014 17:57
Resque start workers
TERM_CHILD=1 COUNT=5 QUEUES=* bundle exec rake resque:workers
@prcaen
prcaen / git_commit_convention.markdown
Last active August 29, 2015 14:01
Git commit convention

Git commit convention

Format

<type>(scope): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```
@prcaen
prcaen / gist:1153708
Created August 18, 2011 09:13
[PHP] - Distinct double in a multi dimensional array
<?php
/**
* Get a distinct multi dimensional array
*
* @param array $array
* array to distinct
* @param string $keySearch
* string key to search double array
* @param boolean $overwrite = false
* boolean to allow values to be overwritten
@prcaen
prcaen / html5-file-kickstart.html
Created November 5, 2011 11:02
HTML5 file kickstart
<!DOCTYPE html>
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="lang"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="lang"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="${1:fr}"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<!-- Geo position -->
@prcaen
prcaen / gist:1435422
Created December 5, 2011 21:23
[PHP] - Two digits
private function twoDigits($number)
{
if($number <= 9)
return '0' . $number;
else
return $number;
}
@prcaen
prcaen / generateRandomKey.js
Created December 20, 2011 11:00
[JS] - generateRandomKey
function generateRandomKey(size)
{
var keyset = 'abcdefghijklmnopqrstuvwxyz0123456789';
var randomKey = '';
for (var i = 0; i < size; i++)
{
var rnum = Math.floor(Math.random() * keyset.length);
randomKey += keyset.substring(rnum,rnum + 1);
}
@prcaen
prcaen / GoogleCalendar.java
Created January 2, 2012 08:42
[Java] GoogleCalendar Android Manager
public class GoogleCalendar {
private Context _context;
private GoogleCalendarCallback _callback;
public GoogleCalendar(Context c, GoogleCalendarCallback cb) {
_context = c;
_callback = cb;
}
public void add(final String title, final Long dateStart, final Long dateEnd,
@prcaen
prcaen / gist:2996342
Created June 26, 2012 15:09
[PHP] - [Symfony] - sfValidatorBIC
<?php
/**
*
*/
class sfValidatorBIC extends sfValidatorBase
{
protected $validator;
protected $errors;
protected function configure($options = array(), $messages = array())
@prcaen
prcaen / twoDigitsYear.java
Last active December 11, 2015 15:38
Return year with two digits If is already a two digits year it return the two digits eg : - 2014 => 14 - 14 => 14
private int _twoDigitsYear(int year) {
if (year > 0)
year = year % 100;
return year;
}
@prcaen
prcaen / rails_tips.rb
Last active December 13, 2015 17:09
Rails tips
## CONSOLE
# Routes for a controller
rake routes CONTROLLER=products
## CONTROLLER
# Redirect to referrer
redirect_to :back # raise RedirectBackError if no referer
# Before filter and after filter in a same method