This file contains hidden or 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 AsyncIterator: | |
def __init__(self, data): | |
self.data = data | |
async def __aiter__(self): | |
return self |
This file contains hidden or 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
include<stdio.h> | |
int main() | |
{ | |
unsigned char buffer[10000]; | |
char home[2]; | |
FILE *ptr; | |
ptr = fopen("1.nst","rb"); |
This file contains hidden or 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
# __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. |
This file contains hidden or 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
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}) |
This file contains hidden or 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
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") |
This file contains hidden or 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 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()] | |
This file contains hidden or 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
class Genre(models.Model): | |
name = models.CharField(max_length=15) | |
class Movie(models.Model): | |
title = models.CharField(max_length=40) | |
genres = models.ManyToManyField(Genre) | |
This file contains hidden or 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 random | |
class Bike: | |
speed = 0 | |
moving = False | |
location = 0 | |
top_speed = 14 | |
name = "" | |
def __init__(self, name="Unknown Racer", top_speed=14): |
This file contains hidden or 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
var Bike = (function () { | |
var _bike; | |
_bike = function(opts) { | |
this.name = opts.name; | |
this.topSpeed = opts.topSpeed; | |
this.location = 0; | |
this.speed = 0; | |
}; |
This file contains hidden or 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 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) |