Skip to content

Instantly share code, notes, and snippets.

View cnicodeme's full-sized avatar

Cyril Nicodème cnicodeme

View GitHub Profile
@cnicodeme
cnicodeme / gist:892200
Last active September 25, 2015 08:27
Format seconds in h:m:s (output can be changed)
<?php
/**
* Create a DateTime object with the number of seconds
* Since the date starts at year 0, the returned time will be in year/month/day/hour/minute/second
*
* @param Integer $iTime : Timestamp in seconds
* @param String $sFormat (optional) : The date format to return
*
* @return String : The well formatted date.
*/
@cnicodeme
cnicodeme / showdates_bm.js
Created March 30, 2012 11:38
ShowDates.me improving script.
var oCouchLis = $('#section-watchlist>li'), oSeriesLis = $('#main>div .list-episodes>ul>li');
function processCouch() {
var $this = $(this),
title = $this.find ('>p>a:first-of-type').text(),
cleanTitle = title.replace (/( )/g, '_').replace(/:/g, ''),
code = $this.find ('>p>span.episode-code').text().substring(1),
season = code.substring(0, code.indexOf("E")).replace(/^[0]+/g,""),
episode = code.substring(code.indexOf("E") + 1).replace(/^[0]+/g,""),
@cnicodeme
cnicodeme / materiel.net.js
Last active December 10, 2015 12:29
Améliore le visuel pour la section *Autres vues du produit* sur Materiel.net
/** Testé uniquement sur Chrome et Firefox **/
jQuery(function ($) {
var isOpened = false,
imageQuantity = $('.ProdThumbnails>dl').length;
$('.ProdThumbnails')
.css({
'position': 'absolute',
'height': 145,
'width': 280,
@cnicodeme
cnicodeme / server.sh
Last active June 30, 2019 00:36
This script automatically set up a new *Debian* server with Apache, Mysql, Php and ProFTPd, and secures all of the previous + SSH.
#!/bin/bash
#
# --------------------------------------------------------------------
# This is a free shell script under GNU GPL version 3.0 or above
# Copyright (C) 2005 ReFlectiv project.
# Feedback/comment/suggestions : http://www.reflectiv.net/
# -------------------------------------------------------------------------
#
# This script automatically set up a new *Debian* server (IMPORTANT : Debian!), by doing these actions :
#
@cnicodeme
cnicodeme / vhost.sh
Last active December 11, 2015 22:58
This scripts aims to create everything needed to have an environment for any Apache websites : Folder, Logs, VirtualHost and FTP Access
#!/bin/bash
#
# --------------------------------------------------------------------
# This is a free shell script under GNU GPL version 3.0 or above
# Copyright (C) 2005 ReFlectiv project.
# Feedback/comment/suggestions : http://www.reflectiv.net/
# -------------------------------------------------------------------------
#
# This scripts aims to create everything needed to have an environment
# for any Apache websites : Folder, Logs, VirtualHost and FTP Access
@cnicodeme
cnicodeme / Recursive Database Backup
Last active December 19, 2015 05:59
Saves database listed in each databases.bk files located in all the folders starting from a base path.
#!/bin/bash
#
# --------------------------------------------------------------------
# This is a free shell script under GNU GPL version 3.0 or above
# Copyright (C) 2005 ReFlectiv project.
# Feedback/comment/suggestions : http://www.reflectiv.net/
# -------------------------------------------------------------------------
#
# This script automatically backups the database based on each folder
# on the given path and the directive for which db to save
@cnicodeme
cnicodeme / cryptocat.js
Last active December 24, 2015 01:39
Switch the Cryptocat discussion page from fixed layout to full width layout :)
// Inject css rules in Cryptocat conversation for a full width display
// Also add a "body click to text focus" action (using jQuery, already embedded in Cryptocat)
// Note: Only tested on IE 6 ! (Ok, I'm kidding, only Chrome)
// Author : Cyril N.
(function (){
var newcss = "#userInput>#userInputText {width : 84%;} body>div#bubble {width : auto; margin : 0 auto; position : absolute; top : 0; bottom : 0; left : 0; right : 0; height : auto; border-radius: 0}";
newcss += "div#conversationWindow .line1, div#conversationWindow .line2, div#conversationWindow .line3, div#conversationWindow .line4 {max-width : 96%;}";
newcss += "div#buddyWrapper {width : 14%;}";
@cnicodeme
cnicodeme / playserver.sh
Created October 10, 2013 12:09
This shell script start/stop/restart/update a Play Framework project (> 2.0) and manage GIT versioning (via the update/ force-restart).
#!/bin/bash
#
# --------------------------------------------------------------------
# This is a free shell script under GNU GPL version 3.0 or above
# Copyright (C) 2005 ReFlectiv project.
# Feedback/comment/suggestions : http://www.reflectiv.net/
# -------------------------------------------------------------------------
#
# This scripts do the start/stop/restart of a PlayFramework project with GIT Support
#
@cnicodeme
cnicodeme / Twilio.java
Last active December 26, 2015 12:28
Easily send an SMS using the Twilio API
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
"""
The Pool module provides some classes for managing a fixed-size thread-safe pool of functionally identical objects. One use for this is database connections, which tend to take awhile to create.
Pool
class that manages the pool of objects.
Constructor
class used to create new instances of items in the Pool.
For more details, use pydoc or read the docstrings in the code.