Skip to content

Instantly share code, notes, and snippets.

View joelthelion's full-sized avatar

Joel Schaerer joelthelion

  • Bioclinica
  • Lyon, France
View GitHub Profile
#!/usr/bin/env python3
from itertools import islice
import re
import requests
from bs4 import BeautifulSoup
if __name__ == '__main__':
stat_soup = BeautifulSoup(requests.get("https://stats.lineageos.org/").content, "lxml")
code_soup = BeautifulSoup(requests.get("https://wiki.lineageos.org/devices/").content, "lxml")
@joelthelion
joelthelion / boxes.py
Last active May 31, 2016 09:35
Find solutions for the n-box problem
#!/usr/bin/env python3
""" Find solutions for the n-box problem. Solutions are represented as
a list of box indices for each integer. Partial sums are cached and
passed around. """
from copy import copy
from sys import argv,stderr
import random
n_boxes = int(argv[1])
#!/bin/python3
""" Optimize redundant predictions on hypermind """
import numpy
from collections import namedtuple
from itertools import product
Proba = namedtuple("Proba", ["hollande", "sarkozy"])
possibilities = [Proba(h, s) for (h, s) in product(numpy.linspace(0, 1, 101),
numpy.linspace(0, 1, 101))]
@joelthelion
joelthelion / gist:7d4d4b44120607b63035
Created July 9, 2015 23:18
Streaming JSON array downsampler written in (probably bad) Haskell
import Data.JsonStream.Parser
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy.Char8 as BL
import qualified Data.Aeson.Types as AT
import qualified Data.Aeson.Encode as AE
import Pipes
import qualified Pipes.Prelude as P
import System.IO (isEOF, stdin)
import System.Random
@joelthelion
joelthelion / weather_notifications.py
Created March 27, 2013 20:27
Simple prototype for weather notifications based on the Yahoo! weather API. Needs support for multiple locations and a way for people to subscribe.
#!/usr/bin/env python3
# coding: utf-8
import yweather
import shelve
import datetime
from conditions import conditions
def send_plain_mail(subject, body, from_mail, to):
import smtplib
@joelthelion
joelthelion / quicksave.py
Last active December 15, 2015 07:59
Simple script for quick and dirty backups
#!/usr/bin/env python3
# coding: utf-8
# Copyright Joel Schaerer, 2013. Licensed under the GPL, version 3
from datetime import datetime
from sys import argv
import os, shutil
from itertools import count
""" Simple script for quick and dirty backups.
@joelthelion
joelthelion / languages.py
Created December 7, 2011 21:22
What language do the best AI programmers use?
#!/usr/bin/env python2
# coding: utf-8
import json
a=json.load(open("ranking_json.php")) # get at http://aichallenge.org/ranking_json.php
print a.keys()
#print a["values"][8]
#print a["values"][8][18] # skill
#print a["values"][8][22] # games
#print a["values"][8][7] # language
@joelthelion
joelthelion / get_liked.py
Created December 6, 2011 12:19
Get liked items on reddit
#!/usr/bin/env python2
# coding: utf-8
import json
import gzip
from StringIO import StringIO
from getpass import getpass
# Install http://docs.python-requests.org/en/latest/
import requests
@joelthelion
joelthelion / HelloDartTest.dart
Created November 22, 2011 13:01 — forked from munificent/HelloDartTest.dart
Dart Compilation
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Simple test program invoked with an option to eagerly
// compile all code that is loaded in the isolate.
// Compiled using frog, the in-progress self-hosted compiler:
// dart/frog$ ./frogsh --out=hello.js --compile-only samples/hello.dart
class HelloDartTest {
static testMain() {
#perform histogram equalization with numpy, without explicitly computing the histogram
#im is a numpy array, of any dimension
im2 = numpy.sort(im.ravel()).searchsorted(im)