Skip to content

Instantly share code, notes, and snippets.

🚲

Jérôme Tamarelle GromNaN

🚲
View GitHub Profile
@GromNaN
GromNaN / latency.txt
Created Jul 5, 2012 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
View latency.txt
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
View composer.json
{
"name": "jerometamarelle/redirect",
"require": {
"silex/silex": "dev-master"
},
"authors": [
{
"name": "Jérôme Tamarelle",
"email": "jerome@tamarelle.net"
}
View iframeHeight.js
function refreshIframeHeight(id) {
parent.window.document.getElementById(id).height = document.body.offsetHeight ;
}
@GromNaN
GromNaN / gist:1560785
Created Jan 4, 2012
Track GIT changes into SVN
View gist:1560785
# Track changes from a GIT repository as snapshots into SVN
SVN_REPOS=<svn_repos>
GIT_REPOS=<git_repos>
GIT_BRANCH=<branch>
git svn clone $SVN_REPOS repos
cd repos
git remote add origin $GIT_REPOS
git fetch origin
@GromNaN
GromNaN / git.md
Created Dec 15, 2011
My Git Commands
View git.md

Initialize a repository without working directory

git init --bare --shared=0700

Undo last commit

git reset --hard HEAD~1

Review changes going to be committed

View console-colors.md

Characters Codes to get color in your console

Reset

  • reset \033[0

Text Colors

@GromNaN
GromNaN / detect-utf8.php
Created Dec 1, 2011
How to detect UTF-8 string in PHP
View detect-utf8.php
<?php
function isUtf8($string)
{
return preg_match('%(?:'
. '[\xC2-\xDF][\x80-\xBF]' // non-overlong 2-byte
. '|\xE0[\xA0-\xBF][\x80-\xBF]' // excluding overlongs
. '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}' // straight 3-byte
. '|\xED[\x80-\x9F][\x80-\xBF]' // excluding surrogates
. '|\xF0[\x90-\xBF][\x80-\xBF]{2}' // planes 1-3
@GromNaN
GromNaN / autoload.php
Created Nov 29, 2011
PSR-0 autoload.php
View autoload.php
<?php
/**
* Simple autoloader that follow the PHP Standards Recommendation #0 (PSR-0)
* @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md for more informations.
*
* Code inspired from the SplClassLoader RFC
* @see https://wiki.php.net/rfc/splclassloader#example_implementation
*/
spl_autoload_register(function($className) {
@GromNaN
GromNaN / Doctrine_Connection_Mssql.php
Created Nov 10, 2011
Doctrine_Connection_Mssql with optimized modifyLimitQuery()
View Doctrine_Connection_Mssql.php
<?php
/*
* $Id: Mssql.php 5804 2009-06-02 19:52:42Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
View gist:1342799
# Find the process ID
ps -ax | grep Safari
# Pause the process
kill -STOP 1234
# Resume the process
kill -CONT 1234
You can’t perform that action at this time.