Skip to content

Instantly share code, notes, and snippets.

View taddeimania's full-sized avatar
☄️
Hi!

Joel Taddei taddeimania

☄️
Hi!
View GitHub Profile
@taddeimania
taddeimania / async.py
Last active October 7, 2015 16:10
New Async syntax in python 3.5 example
import asyncio
class AsyncIterator:
def __init__(self, data):
self.data = data
async def __aiter__(self):
return self
@taddeimania
taddeimania / main.c
Last active October 6, 2015 19:06
Reading Home / Away team from Tecmo Super Bowl savestate in C
include<stdio.h>
int main()
{
unsigned char buffer[10000];
char home[2];
FILE *ptr;
ptr = fopen("1.nst","rb");
@taddeimania
taddeimania / mat_mul_fun.py
Last active December 22, 2015 02:25
__matmul__ abuse for the greater good
# __matmul__ abuse for the greater good
"""One thing that caught my eye when learning more about the new Matrix / Matrix
multiplication operator was that it itself was not batteries included.
Having the wind taken out of my sails, it dawned on me I was looking
at the missing implentation the wrong way. What we have on our hands is an
operator with an ambiguously open ended realm of opportunities.
@taddeimania
taddeimania / views.py
Last active August 29, 2015 14:25
Bokeh Graph to context object in Template
from bokeh.embed import components
from bokeh.plotting import figure
from django.shortcuts import render_to_response
def graph_view(request):
x_data, y_data = ([1, 2, 3, 4], [10, 1, 5, 3])
plot = figure()
plot.line(x_data, y_data)
script, div = components(plot)
return render_to_response("base.html", {"bokeh_script": script, "bokeh_graph": div})
@taddeimania
taddeimania / views.py
Created July 21, 2015 14:55
Graph to HttpResponse - django
from django.http import HttpResponse
import matplotlib.pyplot as plt
import io
def graph_view(request):
plt.scatter([1, 2, 3, 4], [6, 10, 12, 1])
image_file = io.BytesIO()
plt.savefig(image_file, format="png")
@taddeimania
taddeimania / client.py
Created July 15, 2015 15:44
Python API Client
import requests
API_HOST = "http://localhost:8000/api3/"
AUTH_TOKEN = "ebea682e0ff80c453fb179b042c22d11d8e6179f"
def get_movie_list():
return [movie['title'] for movie in requests.get(API_HOST + "movie/").json()]
@taddeimania
taddeimania / many_to_many.py
Created July 9, 2015 18:51
Many to Many description
class Genre(models.Model):
name = models.CharField(max_length=15)
class Movie(models.Model):
title = models.CharField(max_length=40)
genres = models.ManyToManyField(Genre)
import random
class Bike:
speed = 0
moving = False
location = 0
top_speed = 14
name = ""
def __init__(self, name="Unknown Racer", top_speed=14):
@taddeimania
taddeimania / bikeRaceOOP.js
Last active August 29, 2015 14:22
Bike Race OOP JS
var Bike = (function () {
var _bike;
_bike = function(opts) {
this.name = opts.name;
this.topSpeed = opts.topSpeed;
this.location = 0;
this.speed = 0;
};
@taddeimania
taddeimania / scraper.hy
Last active August 29, 2015 14:17
Not really a scraper, just a complicated replacer
(import requests)
(defn replacer []
(setv content
(. (requests.get "https://asciinema.org/api/asciicasts/17675" ) text))
(setv replaced-content (.replace content "/assets" "https://asciinema.org/assets"))
replaced-content)
(replacer)