Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
baseip=`echo $5 | cut -d'.' -f1-3`
ip route add $baseip.0/24 dev ppp0
# 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 October 29, 2014 18:15
Gruntfile for Titanium ( jade, coffee, stss, tishadow )
module.exports = ( grunt ) ->
grunt.initConfig
# Compile coffeescript
coffee:
options:
bare: true
sourceMap: false
compile:
files: [
expand: true
@m4tm4t
m4tm4t / gist:8470086
Last active January 3, 2016 13:29
Zend 2 crazy flash notices with namespaces
<?php
// Set message
$this->flashMessenger()
->setNamespace("success")
->addMessage("You've been logged out");
return $this->redirect()->toUrl('/');
// Retrieve message
$notice = null;
$flash = $this->flashMessenger();
/**
* Server Side
*/
var players = [];
var count = 0;
sails.io.on('connection', function (socket) {
var player = {};
socket.on('register', function (uuid) {
$(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 December 27, 2015 13:49
Better var_dump output
<?php
//=> https://github.com/foohey/bar_dump
/*
* 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 December 27, 2015 02:19
code found in a school project
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';
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--) {