Skip to content

Instantly share code, notes, and snippets.

View wolfiestyle's full-sized avatar

wolfiestyle

  • Chile
View GitHub Profile
@wolfiestyle
wolfiestyle / awoo_tool.lua
Created August 20, 2016 22:23
the Awoo Tool™
#!/usr/bin/env lua
-- Awoo Tool by @wolfiestyle
-- license: MIT/X11
-- demo: https://twitter.com/wolfiestyle/status/767124329461084161
local lgi = require "lgi"
local Gtk = lgi.Gtk
local GLib = lgi.GLib
local window = Gtk.Window{
title = "awoo tool v0.1-alpha",
@wolfiestyle
wolfiestyle / 01_animals.cpp
Created August 10, 2016 04:42
the classic Animal class example in C++ and Rust
// the OOP version in C++
#include <iostream>
// base abstract class. that is what we use as the interface
class Animal
{
public:
Animal(char const* name): m_name(name) {}
// this is required to properly delete virtual classes
@wolfiestyle
wolfiestyle / deepdream.py
Created August 5, 2016 07:04
deep dream command line utility
#!/usr/bin/env python2
# based on the code from: https://github.com/google/deepdream
import argparse
parser = argparse.ArgumentParser(description='Deep dreams an image.')
parser.add_argument('image', type=open, help='image file to process')
parser.add_argument('-g', '--gpu', action='store_true', help='enable GPU acceleration')
parser.add_argument('-o', '--out', type=argparse.FileType('w'), default='out.png', help='output image file')
args = parser.parse_args()
from cStringIO import StringIO
@wolfiestyle
wolfiestyle / gdb_lua
Created November 13, 2015 21:40
gdb script to get bracktraces from Lua core dumps
set $p = L->ci
while ($p > L->base_ci )
if ( $p->func->value.gc->cl.c.isC == 1 )
printf "0x%x C FUNCTION ", $p
output $p->func->value.gc->cl.c.f
printf "\n"
else
if ($p->func.tt==6)
set $proto = $p->func->value.gc->cl.l.p
set $filename = (char*)(&($proto->source->tsv) + 1)
@wolfiestyle
wolfiestyle / sphtrace.rs
Last active October 9, 2015 03:29
raytracer in Rust
extern crate num;
extern crate nalgebra as na;
use std::io::{self, Write};
use std::fs::File;
use std::f64::consts;
use num::complex::Complex64;
use num::{Zero, One};
use na::{Vec2, Vec3, Mat3, Dot, Cross, Norm};
@wolfiestyle
wolfiestyle / sphtrace.hs
Last active February 22, 2016 00:31
raytracer in haskell
{-# LANGUAGE BangPatterns #-}
import Control.Applicative
import System.IO
import Data.Maybe
import Data.Complex
import Data.Word
import qualified Data.ByteString as B
data Vec a = Vec { vecx, vecy, vecz :: !a }
@wolfiestyle
wolfiestyle / mandel.rs
Created September 15, 2015 04:42
mandelbrot renderer in Rust
extern crate num;
use num::complex::Complex64;
use num::traits::{Zero, One};
use std::env;
use std::io::{self, Write};
use std::fs::File;
fn viewport(width: usize, height: usize, size: f64, center: Complex64) -> (f64, f64, f64, f64)
{
let (w, h, s) = (width as f64, height as f64, size * 0.5);
@wolfiestyle
wolfiestyle / mandel.hs
Last active October 3, 2015 23:36
mandelbrot generator in haskell
import Data.Complex
import qualified Data.ByteString as B
import qualified Data.ByteString.Char8 as C
viewport :: RealFloat a => Int -> Int -> a -> Complex a -> (Complex a, Complex a)
viewport width height size center = (p0, p1 - p0)
where s = size * 0.5
(w, h) = (fromIntegral width, fromIntegral height)
dist = if w > h then (s :+ s * h / w) else (s * w / h :+ s)
(p0, p1) = (center - dist, center + dist)
@wolfiestyle
wolfiestyle / error.cpp
Created July 28, 2015 02:30
Typical C++ error
template<class T>struct W{T v;W(T v):v(v){}}; template<class T>int f(T x){f(W<T>(x));} main(){f(0);}
@wolfiestyle
wolfiestyle / lisp.lua
Created May 24, 2015 18:05
my first attempt at implementing Lisp
#!/usr/bin/env lua
local eval
local global = {
["+"] = function(args)
local acc = 0
for i = 1, #args do
acc = acc + args[i]
end
return acc