This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import base64 | |
import hashlib | |
import hmac | |
def _prepare_headers(payload, api_key, api_secret): | |
# payload = parameters-dictionary -> JSON encode -> base64 | |
payload_json = json.dumps(payload) | |
payload_encoded = base64.encodestring(payload_json) | |
# signature = HMAC-SHA384(payload, api-secret) as hexadecimal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:5835de2e10cb99253cfa1841c86b02e6b9ee8b2fb21e513bbaec771e6e006c1b" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if is_paginated %} | |
<div class="col-md-offset-4"> | |
<ul class="pagination pagination-centered"> | |
{% if page_obj.has_previous %} | |
<li><a href="?page=1"><<</a></li> | |
<li><a href="?{{queries.urlencode}}&page={{ page_obj.previous_page_number }}"><</a></li> | |
{% endif %} | |
{% for i in paginator.page_range %} | |
<li {% if page_obj.number == i %} class="active" {% endif %}><a href="?{{queries.urlencode}}&page={{i}}">{{i}}</a></li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import time | |
data = [] | |
for n_elements in [100, 1000, 10000, 100000]: | |
a = range(n_elements) | |
sa = set(a) | |
b = np.array(a) + 50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hardstatus alwayslastline '%{= G}[ %{G}%H %{g}][%= %{= w}%?%-Lw%?%{= R}%n*%f %t%?%{= R}(%u)%?%{= w}%+Lw%?%= %{= g}][ %{y}Load: %l %{g}][%{B}%Y-%m-%d %{W}%c:%s %{g}]' | |
startup_message off | |
termcapinfo xterm* ti@:te@ | |
backtick 1 5 5 true | |
termcapinfo rxvt* 'hs:ts=\E]2;:fs=\007:ds=\E]2;\007' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# purge-old-kernels - remove old kernel packages | |
# Copyright (C) 2012 Dustin Kirkland <kirkland@ubuntu.com> | |
# | |
# Authors: Dustin Kirkland <kirkland@ubuntu.com> | |
# Kees Cook <kees@ubuntu.com> | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _save_more_extensions(filename, extensions=['png', 'svg', 'pdf']): | |
for ext in extensions: | |
comp_filename = "{0}.{1}".format(filename, ext) | |
plt.savefig(comp_filename, dpi=300) | |
print "Saved plot: {0}".format(comp_filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Deleting a line in matplot lib | |
fig = figure() | |
ax = fig.add_subplot(111) | |
x = linspace(0,10) | |
plot(x, sin(x), label='sin') | |
plot(x, cos(x), label='cos') | |
# Deleting the last one | |
del ax.lines[1] | |
draw() # updating the fig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_new_dir(self, prefix="./", root="Sims"): | |
""" | |
Create the directory where to put the simulation | |
""" | |
self.dirRoot = os.path.join(prefix, root) | |
today = datetime.date.today() | |
free = False | |
index = 0 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def save_node(self, h5file_holder, group_path, section_name, variables, | |
detail=''): | |
"""Save a node to the h5file. | |
h5file_holder: The holder of the h5file | |
group_path: Where in the hierarchy the leaf has to be saved | |
section_name: The name of the section which the variables belong to | |
variables: The dictionary of the variable | |
""" | |
found = False | |
target_group = None |
OlderNewer