Skip to content

Instantly share code, notes, and snippets.

@cyb3rd4d
cyb3rd4d / webhook
Last active February 13, 2017 15:33
LSB init script for a PHP daemon (a webhook here)
### BEGIN INIT INFO
# Provides: webhook
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: GitHub webhook
# Description: This webhook handles GitHub events.
### END INIT INFO
@cyb3rd4d
cyb3rd4d / ssh-agent.zsh
Created December 16, 2016 08:40
Load ssh keys on MacOS Sierra (Oh My ZSH plugin)
# Load ssh keys
ssh-add -l >> /dev/null
if [ ! $? -eq 0 ]; then
echo "SSH keys loading..."
ssh-add -A
fi
@cyb3rd4d
cyb3rd4d / box-login.html
Created November 16, 2015 14:03
A login box centered horizontally and vertically (thank flexbox)
<html>
<style>
html, body, .container {
height: 100%;
}
body {
margin: 0;
padding: 0;
background-color: #eee;
@cyb3rd4d
cyb3rd4d / oldRegionMapping.php
Created September 22, 2015 10:08
French "old" region mapping per department
<?php
return [
'01' => 'Rhône-Alpes',
'02' => 'Picardie',
'03' => 'Auvergne',
'04' => 'Provence-Alpes-Côte d\'Azur',
'05' => 'Provence-Alpes-Côte d\'Azur',
'06' => 'Provence-Alpes-Côte d\'Azur',
'07' => 'Rhône-Alpes',
@cyb3rd4d
cyb3rd4d / recursiveIterator.php
Created July 17, 2015 13:56
Recursive iterator
class MyFuckingIterator
{
public function __construct()
{
$this->data = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($data));
}
}
@cyb3rd4d
cyb3rd4d / timer.js
Created June 24, 2015 09:42
A timers for Node.js
var now = new Date();
var valuatedAt = new Date();
var maxTime = new Date();
valuatedAt.setMinutes(now.getMinutes() - 1);
maxTime.setMinutes(valuatedAt.getMinutes());
maxTime.setSeconds(valuatedAt.getSeconds() + 80);
console.log('Initialization....');
console.log('now: ' + now);
@cyb3rd4d
cyb3rd4d / mysql_update_data.sh
Created June 22, 2015 09:45
Fetch data from MySQL, send cURL requests and use the API results to update the DB.
#!/bin/bash
urlencode() {
# urlencode <string>
# from https://gist.github.com/cdown/1163649
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
@cyb3rd4d
cyb3rd4d / mysql_fetch_data_and_curl.sh
Last active August 29, 2015 14:22
Fetch data from MySQL and send a cURL request in Bash.
#!/bin/bash
urlencode() {
# urlencode <string>
# from https://gist.github.com/cdown/1163649
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:i:1}"
case $c in
@cyb3rd4d
cyb3rd4d / README.md
Created October 29, 2014 10:25
Init script for Jackrabbit in a Vagrant box (tested on Ubuntu).

JackRabbit Init Script

Init script for Jackrabbit in a Vagrant box (tested on Ubuntu trusty only). I am not an advanced bash developer, so don't hesitate to contribute!

Installation

Copy this script in your /etc/init.d directory:

@cyb3rd4d
cyb3rd4d / DefaultController.php
Created June 21, 2014 20:20
An example of a file upload with Symfony2
<?php
namespace Martial\UploadBundle\Controller;
use Martial\UploadBundle\Entity\Image;
use Martial\UploadBundle\Form\Type\ImageType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{