Skip to content

Instantly share code, notes, and snippets.

View chanmix51's full-sized avatar

Grégoire HUBERT chanmix51

View GitHub Profile
@chanmix51
chanmix51 / htaccess
Created April 4, 2011 09:09
Redirect in new if file does not exist in old
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(old|new)
RewriteRule ^.*$ - [L]
RewriteRule ^(.*) old/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^old(.*) new/index.php$1 [QSA]
@chanmix51
chanmix51 / vhost.conf
Created April 4, 2011 09:15
VirtualHost configuration to use php4 and php5
ScriptAlias /php4/ /home/developpeur/src/php4/bin/
<Directory /home/developpeur/src/php4/bin>
AllowOverride None
Options none
Order allow,deny
Allow from all
</Directory>
ScriptAlias /php5/ /home/developpeur/src/php5/bin/
<Directory /home/developpeur/src/php5/bin>
@chanmix51
chanmix51 / pomm_scan_schema.php
Created April 4, 2011 21:52
Few lines of PHP to scan a ph schema to create model files with Silex
<?php
require __DIR__.'/vendor/pomm/test/autoload.php';
$service = new Pomm\Service(array('default' => array('dsn' => 'pgsql://nss_user:nss_password@localhost/nss_db')));
$scan = new Pomm\Tools\ScanSchemaTool(array(
'dir'=> __DIR__,
'schema' => 'transfo',
'connection' => $service->getDatabase(),
@chanmix51
chanmix51 / UniversalClassLoaderChecker.php
Created April 28, 2011 07:51 — forked from docteurklein/UniversalClassLoaderChecker.php
a class to check classLoader configuration
<?php
namespace Symfony\Component\ClassLoader;
class UniversalClassLoaderChecker
{
public function check(UniversalClassLoader $classLoader)
{
return array_merge(
$this->checkNamespaces($classLoader),
@chanmix51
chanmix51 / DAC_IV_converter.textile.txt
Created May 10, 2011 09:23
Super common grid DAC I/V converter Blog article
h3. Original goal
I had a previous experience building a 6N8S powered pre-amp. I took directly the signal after the opamp of an enter level CD player (I don't even remember the brandt). I must say I was quite impressed by the result. The main idea was to do quite the same thing. As soon as I submitted the idea to the Audiyoan forum lot of people reacted and my post became the new incarnation of all old threads covering DACs and how to extract signal from them.
Some of the most famous DACS for DIYers are Phillips'TDA1541 and the cheaper one TDA1543. Both are 16bits DAC and both convert digital signal to analogic current. The main problem is: we know how to amplify voltage but not current. The first step is to "convert the DAC output current to a voltage signal":http://en.wikipedia.org/wiki/Current-to-voltage_converter .
h2. The ugly passive way
The first idea most have (I had) is to use a resistor, U = R∙I so we convert the output current of the DAC to voltage. Well, understanding a bit the internals of
@chanmix51
chanmix51 / app.nginx.conf
Created August 2, 2011 13:46
Nginx vhost proxy configuration
server {
listen 80;
server_name my_host;
location / {
proxy_pass http://10.0.2.101;
proxy_set_header Host $http_host;
}
}
@chanmix51
chanmix51 / app.nginx.conf
Created August 17, 2011 08:45
nginx vhost conf silex & symfony
server {
listen 80;
server_name server.mydomain.net
root /var/www/app/web;
index index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
@chanmix51
chanmix51 / bashlib.sh
Created September 18, 2011 16:46
Bash library to develop scripts
. $LIB_DIR/colors.sh
error_msg() {
echo -e "${COLOR_RED}ERROR:${COLOR_RESET} $1 " >&2;
}
notice() {
echo -e "${COLOR_BOLD}notice:${COLOR_RESET} $1" >&2;
}
@chanmix51
chanmix51 / wget_symfony2_doc.sh
Created October 18, 2011 08:16
Retrieving symfony2's documention and make it local
wget -r -p -k -w 1 -D symfony.com -I /doc/current/book,/images,/css,/js 'http://symfony.com/doc/current/book/index.html'
@chanmix51
chanmix51 / services.yml
Created October 20, 2011 16:23
Registering twig sandbox in SF2
parameters:
policy.tags: [if]
policy.filters: [upper]
policy.methods: { Article: [getTitle]}
policy.properties: { Article: [excerpt]}
policy.function: [range]
services:
twig.extension.sandbox.policy:
class: Twig_Sandbox_SecurityPolicy