Skip to content

Instantly share code, notes, and snippets.

@issackelly
issackelly / gist:928783
Created April 19, 2011 16:48
Django Template {{ block.super }} example
# Template: A.html
<html>
<head></head>
<body>
{% block hello %}
HELLO
{% endblock %}
</body>
</html>
@alsam
alsam / FArray.jl
Last active April 13, 2016 16:47
Julia implementation Fortran-like array with arbitrary starting indices, negative or zero. Incurs a reasonable overhead vs. Base.Array, expected performance degradation should be strictly less than 2x.
# Fortran-like array with arbitrary starting indices
#
# usage:
#
# julia> include("FArray.jl")
# size (generic function with 51 methods)
#
# julia> y = FArray(Float64, -1:1, -7:7, -128:512, -5:5, -1:1, -3:3, -2:2, -1:1);
#
# julia> y[-1,-7,-128,-5,-1,-3,-2,-1] = 14
@lbruder
lbruder / lbForth.c
Created April 6, 2014 15:21
A minimal Forth compiler in ANSI C
/*******************************************************************************
*
* A minimal Forth compiler in C
* By Leif Bruder <leifbruder@gmail.com> http://defineanswer42.wordpress.com
* Release 2014-04-04
*
* Based on Richard W.M. Jones' excellent Jonesforth sources/tutorial
*
* PUBLIC DOMAIN
*
@knkillname
knkillname / caminos.py
Last active May 5, 2020 17:39
Algoritmos de optimización combinatoria
## Algoritmos de caminos más cortos
from estructuras import Cola, ColaMin
from conectividad import ordenamiento_topologico
inf = float('inf') #Tratar infinito como un numero
def recorrido_a_lo_ancho(G, s):
dist, padre = {v:inf for v in G}, {v:v for v in G}
dist[s] = 0
@Ismael-VC
Ismael-VC / caminos.py
Last active August 29, 2015 14:17 — forked from knkillname/caminos.py
## Algoritmos de caminos más cortos
from estructuras import Cola, ColaMin
from conectividad import ordenamiento_topologico
inf = float('inf') #Tratar infinito como un numero
def recorrido_a_lo_ancho(G, s):
dist, padre = {v:inf for v in G}, {v:v for v in G}
dist[s] = 0
@kimwalisch
kimwalisch / segmented_sieve.cpp
Last active July 31, 2020 08:33
Simple segmented sieve of Eratosthenes implementation
/// @file segmented_sieve.cpp
/// @author Kim Walisch, <kim.walisch@gmail.com>
/// @brief This is a simple implementation of the segmented sieve of
/// Eratosthenes with a few optimizations. It generates the
/// primes below 10^9 in 0.8 seconds (single-threaded) on an
/// Intel Core i7-6700 3.4 GHz CPU.
/// @license Public domain.
#include <iostream>
#include <algorithm>
@nrshrivatsan
nrshrivatsan / httpGetJSON.jl
Last active November 28, 2016 21:26
Julia lang - Read JSON from URL
#Importing Requests package
Pkg.add("Requests")
using Requests.get;
import JSON;
url = "http://query.yahooapis.com/v1/public/yql?q=select%20DaysRange%20from%20yahoo.finance.quotes%20where%20symbol%20in%20%28%22EBAY%22,%22GOOG%22%29%20&env=http://datatables.org/alltables.env&format=json";
#Reads the data from HTTP URL
es = get(url);
@Andy-P
Andy-P / StreamAnalytics.jl
Last active August 29, 2023 00:57
High Performance Streaming Analytics in Julia
# This code is part of a presentation on streaming analytics in Julia
# It was inspired by a number of individuals and makes use of some of their ideas
# 1. FastML.com got me thinking about inline processing after
# reading his great Vowpal Wabbit posts
# 2. John Lanford and his fantastic Vowpal Wabbit library.
# Check out his NYU video course to learn more (see below)
# 3. John Myles White's presentation on online SDG and his StreamStats.jl library
# Thank you all!
@meggart
meggart / .juliarc.jl
Created July 16, 2015 15:26
Macroexpand shortcut in the REPL
if VERSION > v"0.4.0-dev+4268"
const marcoexpandkeys = Dict{Any,Any}("^I" => function (s,o...)
if !isempty(s)
line = parse(Base.LineEdit.input_string(s))
s.kill_buffer=Base.LineEdit.input_string(s)
Base.LineEdit.edit_clear(s)
Base.LineEdit.edit_insert(s,string(macroexpand(line)))
end
@jbn
jbn / julia_type_hierarchy.jl
Created July 17, 2015 22:44
Julia Type Hierarchy
# Requested gist of code to produce:
# https://www.scribd.com/doc/271871142/Julia-Type-Hierarchy
#
# I just redirected the output to a dot file, then executed:
# dot -Tpdf julia.dot -o julia.pdf
function print_type_tree(t, parent=Any, seen=Set{DataType}())
# Avoid redundant edges.
t ∈ seen && return
push!(seen, t)