Skip to content

Instantly share code, notes, and snippets.

Avatar

Cyril Nicodème cnicodeme

View GitHub Profile
@cnicodeme
cnicodeme / gist:892200
Last active Sep 25, 2015
Format seconds in hⓂ️s (output can be changed)
View gist:892200
<?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 Mar 30, 2012
ShowDates.me improving script.
View showdates_bm.js
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 Dec 10, 2015
Améliore le visuel pour la section *Autres vues du produit* sur Materiel.net
View materiel.net.js
/** 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 Jun 30, 2019
This script automatically set up a new *Debian* server with Apache, Mysql, Php and ProFTPd, and secures all of the previous + SSH.
View server.sh
#!/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 Dec 11, 2015
This scripts aims to create everything needed to have an environment for any Apache websites : Folder, Logs, VirtualHost and FTP Access
View vhost.sh
#!/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 Dec 19, 2015
Saves database listed in each databases.bk files located in all the folders starting from a base path.
View Recursive Database Backup
#!/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 Dec 24, 2015
Switch the Cryptocat discussion page from fixed layout to full width layout :)
View cryptocat.js
// 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 Oct 10, 2013
This shell script start/stop/restart/update a Play Framework project (> 2.0) and manage GIT versioning (via the update/ force-restart).
View playserver.sh
#!/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 Dec 26, 2015
Easily send an SMS using the Twilio API
View Twilio.java
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;
View Pool.py
"""
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.