Skip to content

Instantly share code, notes, and snippets.

@Simounet
Simounet / index.html
Created February 19, 2012 11:56
Simple JS Popin
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple JS Popin</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="script.js" type="text/javascript"></script>
</head>
<body>
@Simounet
Simounet / git-prompt.sh
Last active September 30, 2015 22:47
my.git
# Prompt
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\[\033[01;34m\]$(__git_ps1 "(%s)")\[\033[00m\]\$ '
git config apply.whitespace=fix
git config apply.ignorewhitespace on
# ~/.gitconfig
[core]
editor = vim
[alias]
@Simounet
Simounet / index.html
Created April 20, 2012 08:23
Navbar menu auto align subitems
<ul>
<li class="opened">
<a href="">Item 1</a>
<ul class="submenu">
<li>Sub item 1</li>
<li>Sub item 2</li>
<li>Sub item 3</li>
<li>Sub item 4</li>
</ul>
</li>
@Simounet
Simounet / index.php
Created July 30, 2012 08:55
mysql date comparison function
<?php
static function mysql_timediff( $datefield, $date_to_compare, $tbl, $cond_field, $cond_value ) {
$db = eZDB::instance();
$sql = "SELECT TIMEDIFF($datefield, $date_to_compare ) FROM $tbl WHERE $cond_field = '$cond_value';";
$rows = $db->arrayQuery( $sql );
return $rows[0];
}
?>
@Simounet
Simounet / index.php
Created July 30, 2012 15:39
subval array sort function
<?php
function subval_sort($array, $subkey) {
foreach($array as $key => $value) {
$new_array[$key] = strtolower($value[$subkey]);
}
asort($new_array);
foreach($new_array as $new_key => $new_val) {
$result[$new_key] = $array[$new_key];
}
@Simounet
Simounet / index.php
Last active October 8, 2015 09:47
Slug class
<?php
class StrUtils {
static function slug($str){
$str = strtolower($str);
$str = self::remove_accent($str);
return preg_replace(array('/[^a-zA-Z0-9 \'-]/', '/[ -\']+/', '/^-|-$/'),
array('', '-', ''), $str);
}
@Simounet
Simounet / consolelog.js
Created August 30, 2012 19:17
IE console log management
var alertFallback = false; // enable it if you wanna see alerts msg
if (typeof console === "undefined" || typeof console.log === "undefined") {
console = {};
if (alertFallback) {
console.log = function(msg) {
alert(msg);
};
} else {
console.log = function() {};
}
@Simounet
Simounet / gist:3911421
Created October 18, 2012 12:13
JS Print_r
function print_r(obj) {
win_print_r = window.open('about:blank', 'win_print_r');
win_print_r.document.write('<html><body>');
r_print_r(obj, win_print_r);
win_print_r.document.write('</body></html>');
}
function r_print_r(theObj, win_print_r) {
if(theObj.constructor == Array || theObj.constructor == Object){
if (win_print_r == null)
@Simounet
Simounet / .bashrc
Created December 3, 2012 22:48
SVN aliases
alias sadd="svn status |grep '\?' |awk '{print $2}'| xargs svn add"
alias grepf="grep --exclude=*.svn-base --exclude-dir=\.svn --exclude=*~ "
svndiff()
{
svn diff "${@}" | colordiff
}
@Simounet
Simounet / snippets.tpl
Last active December 28, 2015 18:49
Snippets for eZ Publish
{* Button to create a new content *}
<form action="/content/action" method="post">
{* set the class identifier to use *}
<input type="hidden" name="ClassIdentifier" value="article">
{* set the language to use *}
<input type="hidden" name="ContentLanguageCode" value="fre-FR">
{* set the parent node id to use *}
<input type="hidden" name="NodeID" value="{$module_result.node_id}">
<input class="button" type="submit" value="Create a new content under this one" name="NewButton">
</form>