Skip to content

Instantly share code, notes, and snippets.

Avatar

Mathieu Robardey m4tm4t

View GitHub Profile
View foo.bash
#!/bin/bash
baseip=`echo $5 | cut -d'.' -f1-3`
ip route add $baseip.0/24 dev ppp0
View resque_retry_spec.rb
# spec/support/resque_helper.rb
module ResqueHelper
def create_worker( queue_name )
Resque.redis.flushall
@worker = Resque::Worker.new( queue_name )
@worker.register_worker
return @worker
end
def perform_next_job(worker, &block)
@m4tm4t
m4tm4t / gist:2a65ac6caf7e31aa5069
Created Oct 29, 2014
Gruntfile for Titanium ( jade, coffee, stss, tishadow )
View gist:2a65ac6caf7e31aa5069
module.exports = ( grunt ) ->
grunt.initConfig
# Compile coffeescript
coffee:
options:
bare: true
sourceMap: false
compile:
files: [
expand: true
@m4tm4t
m4tm4t / gist:8470086
Last active Jan 3, 2016
Zend 2 crazy flash notices with namespaces
View gist:8470086
<?php
// Set message
$this->flashMessenger()
->setNamespace("success")
->addMessage("You've been logged out");
return $this->redirect()->toUrl('/');
// Retrieve message
$notice = null;
$flash = $this->flashMessenger();
View gist:7696811
/**
* Server Side
*/
var players = [];
var count = 0;
sails.io.on('connection', function (socket) {
var player = {};
socket.on('register', function (uuid) {
View Handle ctrl key jquery
$(window).on('keydown', function(event) {
if (event.ctrlKey && event.which != 17) {
if (event.which == 80) {
event.preventDefault();
alert('CTRL + P !');
}
}
})
@m4tm4t
m4tm4t / gist:7335782
Last active Dec 27, 2015
Better var_dump output
View gist:7335782
<?php
//=> https://github.com/foohey/bar_dump
View gist:7252234
/*
* CSS Editor
* Author: robard_m
*/
// Page load event
window.addEventListener('load', function load(event) {
window.removeEventListener('load', load, false);
CSSeditor.init();
});
@m4tm4t
m4tm4t / gist:7251843
Last active Dec 27, 2015
code found in a school project
View gist:7251843
function test(){
if((document.getElementById('pupupuce').style.height == '0px') && (document.getElementById('acceuilpuce').style.opacity == '0') && (document.getElementById('acceuilpuce1').style.opacity == '0') && (document.getElementById('acceuilpuce2').style.opacity == '0')){
document.getElementById('acceuilpuce').style.opacity = '1';
document.getElementById('acceuilpuce1').style.opacity = '1';
document.getElementById('acceuilpuce2').style.opacity = '1';
document.getElementById('acceuilpuce').style.transitionDuration = '1s';
document.getElementById('acceuilpuce1').style.transitionDuration = '1s';
document.getElementById('acceuilpuce2').style.transitionDuration = '1s';
document.getElementById('pupupuce').style.height = '85px';
document.getElementById('pupupuce').style.transitionDuration = '1s';
View gist:6917570
function download(links, id) {
setTimeout(function() {
link = $(links[id]).attr('href');
id = link.split("id=")[1];
window.location = '/torrents/download/?id=' + id;
}, 2000*id);
}
(function() {
links = $("a[href*='/nfo/']");
for (var i = links.length - 1; i >= 0; i--) {
You can’t perform that action at this time.