Skip to content

Instantly share code, notes, and snippets.

@pierre-haessig
pierre-haessig / index.html
Created January 3, 2014 20:22
Energy storage animation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Storage animation</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
body { font-family: sans-serif;}
@pierre-haessig
pierre-haessig / ampl.lang
Last active December 26, 2015 03:19
basic Ampl/GNU MathProg language description for gtksourceview (e.g. syntax highlighting in gedit) Pierre Haessig, 2013
<?xml version="1.0" encoding="UTF-8"?>
<!--
basic Ampl/GNU MathProg language description for gtksourceview
(e.g. syntax highlighting in gedit)
to be placed in /usr/share/gtksourceview-3.0/language-specs/ directory
Pierre Haessig, 2013
-->
<language id="ampl" _name="Ampl" version="2.0" _section="Scientific">
@pierre-haessig
pierre-haessig / add_trait_bug.py
Created October 7, 2013 16:01
A bug with add_trait ? -> is there a need to call a "register" function after adding a trait ?
#!/usr/bin/python
# -*- coding: utf-8 -*-
""" A bug with add_trait ?
-> is there a need to call a "register" function after adding a trait ?
Documentation reference for `add_trait` :
http://docs.enthought.com/traits/traits_user_manual/advanced.html#per-object-trait-attributes
Pierre Haessig — October 2013
"""
@pierre-haessig
pierre-haessig / ipythonhere.desktop
Created October 3, 2013 17:30
a .desktop file to create an entry in KDE Dolphin's Actions menu to lauch IPython in the current directory. File to be placed in ~/.kde/share/kde4/services/ServiceMenus/
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
MimeType=inode/directory;
Actions=openIPythonHere;
X-KDE-AuthorizeAction=shell_access
[Desktop Action openIPythonHere]
# TryExec=ipython
Exec=cd %f; ipython qtconsole --pylab
@pierre-haessig
pierre-haessig / sympy transfer function solving.ipynb
Created September 26, 2013 16:20
An experiment to see how `SymPy` could be used to analyze block diagrams in order to compute transfer functions (Laplace or frequency domain analysis).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pierre-haessig
pierre-haessig / traits_saving.py
Last active December 22, 2015 22:58
Saving and loading Traits in a text file formatusing a minimal amount of formatting and parsing code.
'''Saving and loading Traits in a text file format
using a minimal amount of formatting and parsing code.
Pierre Haessig -- September 2013
'''
from traits.api import HasTraits, Float
class Person(HasTraits):
weight = Float(75.0)
@pierre-haessig
pierre-haessig / daily_power.tsv
Created January 30, 2013 14:33
a first D3js exercise to plot hourly electric power data over one day
hour power
00 5.88
01 5.51
02 5.94
03 6.84
04 6.10
05 5.80
06 6.26
07 4.64
08 3.71
import numpy as n
import random as r
import pylab as p
DIRS = ['up', 'right', 'down', 'left']
def new_guy(seed=0):
r.seed(seed)
dna = [[r.choice(DIRS),
r.randint(1, 40),
@pierre-haessig
pierre-haessig / image_shake.py
Created October 4, 2012 15:51
Shake an image to get kind of XKCD-style lines
#!/usr/bin/python
# -*- coding: UTF-8 -*-
""" Shake an image
in relation to the discussion about xkcd-style graphs on matplotlib-users ML
ref: http://mathematica.stackexchange.com/questions/11350/xkcd-style-graphs
Pierre Haessig — October 2012
"""
from os.path import splitext
@pierre-haessig
pierre-haessig / mpl_big_line.py
Created September 5, 2012 15:30
matplotlib slowdown with big invisible lines
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
# Creates big x and y data:
N = 10**7
t = np.linspace(0,1,N)
x = np.random.normal(size=N)
# Create a plot: