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 cv2 | |
import tkinter | |
from PIL import Image, ImageTk | |
def inter_evo(solutions, geometry=None, load=False, to_pil=False): | |
"""Ask user to select one image among the set. | |
Will open a window with some buttons and images over those buttons, | |
returns the index of the clicked image (button). |
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 asyncio | |
class AsyncClass: | |
async def __new__(cls, *args, **kwargs): | |
o = super().__new__(cls) | |
# Explicit async call | |
await o.__init__(*args, **kwargs) | |
return o # __init__ will be called anyway | |
async def __init__(self, *args, **kwargs): |
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
#!/usr/bin/env python3 | |
import pandas as pd | |
import io | |
# Make up some data | |
example_csv = '''Birthday,Name,Surname | |
1643-01-04,Isaac,Newton | |
1879-03-14,Albert,Einsten | |
1942-01-08,Stephen,Hawking |
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 extend(old, new): | |
for p in old: | |
cand = [] | |
for n in new: | |
if n % p != 0: | |
cand.append(n) | |
if not cand: | |
return old | |
old.append(cand[0]) | |
new = cand[1:] |
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
// Approximation of Pi using a simple, and not optimized, CUDA program | |
// Copyleft Alessandro Re | |
// | |
// GCC 6.x not supported by CUDA 8, I used compat version | |
// | |
// nvcc -std=c++11 -ccbin=gcc5 pigreco.cu -c | |
// g++5 pigreco.o -lcudart -L/usr/local/cuda/lib64 -o pigreco | |
// | |
// This code is basically equivalent to the following Python code: | |
// |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/usr/bin/env python3 | |
'''So, I entered the Google Hash Code 2017 competition with a team named PiedPiper, | |
with a guy from UK and a girl from Palestine, but in the end each one of us worked | |
in her/his own. I came up with a solution using Genetic Algorithms (via DEAP). | |
I used the score function to build an algorithm that used 1-bit encodings to represent | |
the presence of a video over a certain cache server. | |
I wasted some time during the competition, so I managed to run briefly the algo on the |
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
# Setup python virtual environment in a given directory subtree | |
function chpwd_auto_pyvenv() { | |
local MAGIC=".zsh_pyvenv" | |
# Check if we encountered a magic previously | |
if [[ -z ${ZSH_PYVENV_PARENT+x} ]]; then | |
# Check if this directory contains a MAGIC | |
if [[ -a "$PWD/$MAGIC" ]]; then | |
echo "Activating virtual environment" | |
# Activate the environment specified |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.