Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
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.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 / 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 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>