Skip to content

Instantly share code, notes, and snippets.

View laurentb's full-sized avatar
🐧
.

Laurent Bachelier laurentb

🐧
.
View GitHub Profile
@clemherreman
clemherreman / 1_Person.class.php
Created April 22, 2011 09:50
PHP WTF of the day
<?php
class Person
{
private $phone;
private $name;
public function __construct($name, $phone)
{
var_dump($name);
var_dump($phone);
# Default, CA Bundle, like browser. Today.
requests.get(..., verify=True)
# No SSL check. Today.
requests.get(..., verify=False)
# Private PEM
requests.get(..., cert='/path/to.pem')
# Private Cert / Key
@marekkalnik
marekkalnik / cleanup_uft8.py
Created March 27, 2012 08:53
Replace utf caracters in file by ASCII equivalents
import os, codecs, unicodedata
def cleanup(directory):
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith('.ktr') or file.endswith('.kjb'):
filename = os.path.join(root, file)
f = codecs.open(filename, 'r', 'utf-8')
text = f.read()
print f
@laurentb
laurentb / gist:2221598
Created March 27, 2012 23:53
lol lxml
a=lxml.html.fromstring(u'<b>coucou</b> <i>héhé</i>')
a.xpath('//b')[0].text # 'coucou'
a.xpath('//i')[0].text # u'h\xc3\xa9h\xc3\xa9'
@ludovig
ludovig / ConvertForm.js
Created March 30, 2012 09:46
Mootools way to retrieve forms values
/**
* Retrieve form values as an object
*
* Inspired by Element.toQueryString
* @see Dimitar Christoff response on http://stackoverflow.com/questions/2166042/how-to-convert-form-data-to-object-using-mootools
*
* @return object form
*
* @author Ludovic Vigouroux <ludovicv@theodo.fr> with the help of Fabrice Bernhard
* @since 2012-02-29
@peikk0
peikk0 / chromium-fix-urlbar.patch
Created July 16, 2012 19:52
chromium-fix-urlbar.patch
This patch restores compliance with IETF RFC 3986 in Chromium:
* fixes the bug introduced in 2010, removing http:// in the URL bar without any option to bring it back: http://code.google.com/p/chromium/issues/detail?id=41467
* reverts the removal of trailing slashes in the URL bar: http://code.google.com/p/chromium/issues/detail?id=43587
--- chrome/browser/autocomplete/autocomplete.cc 2012-07-10 09:48:52.000000000 +0200
+++ chrome/browser/autocomplete/autocomplete.cc 2012-07-16 20:57:19.078551682 +0200
@@ -585,7 +585,7 @@
return net::FormatUrl(
url,
languages,
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: