Skip to content

Instantly share code, notes, and snippets.

View greut's full-sized avatar
:shipit:
setting up that new work laptop

Yoan Blanc greut

:shipit:
setting up that new work laptop
View GitHub Profile
@greut
greut / 0_before
Created May 23, 2014 14:57
before vs after greut:sphinx-warnings
running build_sphinx
creating /home/vagrant/invenio/docs/_build/doctrees
Running Sphinx v1.2.2
Please run: `pip install sphinx_rtd_theme`
/home/vagrant/.virtualenvs/pu/local/lib/python2.7/site-packages/pyparsing.py:3546: DeprecationWarning: Operator '<<' is deprecated, use '<<=' instead
ret << Group( Suppress(opener) + ZeroOrMore( ignoreExpr | ret | content ) + Suppress(closer) )
/home/vagrant/.virtualenvs/pu/local/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py:392: SADeprecationWarning: Passing arguments to type object constructor <class 'sqlalchemy.dialects.mysql.base.INTEGER'> is deprecated
super(_NumericType, self).__init__(**kw)
from functools import wraps
class Resource(object):
pass
class OAuth(object):
def __init__(self):
@greut
greut / gist:7a8da44f1e91d187fbdc
Created June 7, 2014 17:30
profiling of `inveniomanage version` using pyinstrument
$ python -m pyinstrument bin/inveniomanage version
6.927 <module> inveniomanage:3
|- 6.122 load_entry_point pkg_resources.py:354
| `- 6.121 load_entry_point pkg_resources.py:2434
| `- 6.119 load pkg_resources.py:2152
| `- 6.048 <module> invenio/base/manage.py:20
| |- 5.862 create_app invenio/base/factory.py:154
| | |- 3.583 __init__ flask_registry/registries/appdiscovery.py:150
| | | `- 3.583 register flask_registry/registries/appdiscovery.py:155
@greut
greut / master.txt
Created June 11, 2014 08:34
python -m pyinstrument bin/bibindex --help
0.482 <module> bibindex:57
`- 0.477 <module> invenio/bibindex_engine.py:24
|- 0.391 <module> invenio/bibauthority_engine.py:19
| |- 0.251 <module> invenio/search_engine.py:22
| | |- 0.106 <module> invenio/bibrank_record_sorter.py:21
| | | `- 0.100 <module> invenio/webpage.py:18
| | | |- 0.060 <module> invenio/webuser.py:30
| | | | |- 0.033 <module> invenio/session.py:25
| | | | | `- 0.027 <module> invenio/redisutils.py:1
| | | | | `- 0.026 <module> nydus/__init__.py:7
# -*- coding: utf-8 -*-
## This file is part of Invenio.
## Copyright (C) 2014 CERN.
##
## Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## Invenio is distributed in the hope that it will be useful, but
@greut
greut / pytest.diff
Created August 27, 2014 08:28
dictdiffer pytest.ini
diff --git a/setup.py b/setup.py
index 7336daa..74cd954 100644
--- a/setup.py
+++ b/setup.py
@@ -5,9 +5,14 @@ from setuptools.command.test import test as TestCommand
class PyTest(TestCommand):
+ user_options = [('pytest-args=', 'a', 'Arguments to pass to py.test')]
+
@greut
greut / Huffmann.cs
Last active August 29, 2015 14:21
Huffman coding in c# without any priority heap.
using System;
using System.Collections.Generic;
using System.Linq;
namespace Huffmann
{
class Program
{
const int MAX = 255;
static void Main(string[] args)
@greut
greut / reading_data.py
Created August 24, 2015 13:53
Loading swiss municipalities.
#!/bin/python3
import csv
with open("PLZO_CSV_WGS84.csv", encoding="iso-8859-15") as f:
reader = csv.reader(f, delimiter=";")
next(reader) # skip headers
for row in reader:
ort, plz, _, gemeinde, kanton, east, north = row
print ("{} {} ({}) {}, {}".format(plz, ort, kanton, north, east))
@greut
greut / geo.sql
Created August 24, 2015 14:02
Inserting Neuchâtel into a spatial index.
CREATE TABLE cities (
id INT AUTO_INCREMENT,
code INT NOT NULL,
name VARCHAR(127) NOT NULL,
kanton CHAR(2) NOt NULL,
g GEOMETRY NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY (code),
UNIQUE KEY (name),
SPATIAL INDEX (g)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
if (navigator.appName == 'Netscape')
var language = navigator.language;
else if (navigator.appName == 'Microsoft Internet Explorer')
var language = navigator.browserLanguage;
if (language.indexOf('en') > -1) document.location.href = '/en/index.jsp';