Skip to content

Instantly share code, notes, and snippets.

@nicolasH
nicolasH / DevCenter.py
Created July 24, 2014 22:36
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"
@nicolasH
nicolasH / apple system status.py
Last active December 8, 2016 19:59
apple system status
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
#
@nicolasH
nicolasH / FlickrSnippets.py
Created March 30, 2013 07:50
FlickrSnippets
# 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
@nicolasH
nicolasH / FlickrSnippets.py
Created March 30, 2013 07:42
FlickrSnippets
# 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 January 17, 2012 12:41
This is the script I used to create a virtual environment for testing mezzanine + django-modeltranslation
#!/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 October 9, 2011 05:41
Compiling py2cairo for Snow Leopard and python 2.6.7
#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
/**
* 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"));
//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 March 28, 2010 15:14
A Quine in java, created from the definition in Wikipedia.
/** @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 })));}}