Skip to content

Instantly share code, notes, and snippets.

Nicolas Hoibian nicolasH

Block or report user

Report or block nicolasH

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View DevCenter.py
import sys
import console
import requests
from datetime import datetime
import json
# Check the status of the Apple Dev Center systems.
# version 2.0
#
# published information has changed from "web page to parse" to "semi-json file to process"
View apple system status.py
import sys
import console
import requests
from bs4 import BeautifulSoup
from datetime import datetime
#
# Check the status of the Apple Dev Center systems.
# Offline systems appear in orange
# Online systems appear in black
#
View FlickrSnippets.py
# Get the sharing / embed snippets from
# the non-mobile flickr page of an image.
# (if sharing is not restricted on that image).
#
# Usage:
# 1. Copy the flickr photo mobile url to the clipboard
# 2. Run this script
# 3. Copy the snippet you want!
#
# A couple of lines come from get_links.py
View FlickrSnippets.py
# Get the sharing / embed snippets from
# the non-mobile flickr page of an image.
# (if sharing is not restricted on that image).
# A couple of lines come from get_links.py
# https://pythonadventures.wordpress.com/2011/03/10/extract-all-links-from-a-web-page/
#
# Copyright Nicolas Hoibian
# Licence: creative common By-Nc-Sa
#
import sys
@nicolasH
nicolasH / test_mezzanine_modeltranslation.sh
Created Jan 17, 2012
This is the script I used to create a virtual environment for testing mezzanine + django-modeltranslation
View test_mezzanine_modeltranslation.sh
#!/bin/sh
export PROJ_NAME='mezzanine_modeltranslation'
export VENV_NAME=$PROJ_NAME'_env'
#doc for virtualenv -> http://pypi.python.org/pypi/virtualenv
echo "This install the test environment for mezzanine + django-modeltranslation"
#The rest of the instructions at the end so they are not visible when using a target
@nicolasH
nicolasH / compile_py2cairo_osx.sh
Created Oct 9, 2011
Compiling py2cairo for Snow Leopard and python 2.6.7
View compile_py2cairo_osx.sh
#my messy part: add and tweak until it works. Usually followed by remove until it breaks to find the minimal necessary, but not this time.
python waf clean
export PATH=/usr/local/Cellar/python2.6.7/2.6.7/bin:$PATH
export PYTHONPATH=/usr/local/Cellar/python2.6.7/2.6.7
export LD_LIBRARY_PATH=/usr/local/Cellar/python2.6.7/2.6.7:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/Cellar/python2.6.7/2.6.7/lib:$LD_LIBRARY_PATH
export LINKFLAGS='-search_dylibs_first -L /usr/local/Cellar/python2.6.7/2.6.7/lib/'
#from stackoverflow http://stackoverflow.com/questions/6886578/how-to-install-pycairo-1-10-on-mac-osx-with-default-python
export ARCHFLAGS='-arch x86_64'
export CC=/usr/bin/gcc
View fastClip.java
/**
* How to create a BufferedImage from a sub rectangle of another BufferedImage, a.k.a. 'clipping'.
* inspired by :
* http://stackoverflow.com/questions/2825837/java-how-to-do-fast-copy-of-a-bufferedimages-pixels-unit-test-included
*
* Does an arraycopy of the relevant part of the rasters.
*
*/
BufferedImage src = ImageIO.read(new File("SomeFile.png"));
View slowClip.java
//How to create a BufferedImage from a sub rectangle of another BufferedImage, a.k.a. 'clipping'.
BufferedImage src = ImageIO.read(new File("SomeFile.png"));
Rectangle clip = new Rectangle((src.getWidth() - 200) / 2, (src.getHeight() - 200) / 2, 200, 200);
BufferedImage ret = new BufferedImage(clip.width, clip.height, image.getType());
//short but slow clip and paste :
ret.getRaster().setRect(-clip.x, -clip.y, image.getData(clip));
@nicolasH
nicolasH / QuineJava_NicolasHoibian.java
Created Mar 28, 2010
A Quine in java, created from the definition in Wikipedia.
View QuineJava_NicolasHoibian.java
/** @author Nicolas Hoibian */public class QuineJava_NicolasHoibian {public static void main(String[] args) {String src = "/** @author Nicolas Hoibian */public class QuineJava_NicolasHoibian {public static void main(String[] args) {String src = \"#\";src = src.replaceFirst(new String(new char[] { 35 }), src);System.out.println(src.replaceAll(new String(new char[] { 92, 34, 35, 92, 34 }), new String(new char[] { 92, 92, 34, 35, 92, 92, 34 })));}}";src = src.replaceFirst(new String(new char[] { 35 }), src);System.out.println(src.replaceAll(new String(new char[] { 92, 34, 35, 92, 34 }), new String(new char[] { 92, 92, 34, 35, 92, 92, 34 })));}}
You can’t perform that action at this time.