Skip to content

Instantly share code, notes, and snippets.

View wolfiestyle's full-sized avatar

wolfiestyle

  • Chile
View GitHub Profile
#!/usr/bin/gsl-shell -i
function clamp(n, min, max)
if n < min then return min end
if n > max then return max end
return n
end
ap = 420
-- Micro web framework for writing REST applications.
-- Made by @wolfiestyle
-- Last modified: 2015-02-01
-- License: MIT/X11
local error, ipairs, math_random, next, pairs, require, select, setmetatable, string_char, table_concat, tonumber, tostring, type, unpack =
error, ipairs, math.random, next, pairs, require, select, setmetatable, string.char, table.concat, tonumber, tostring, type, unpack
local stderr = io.stderr
local Request = require "wsapi.request"
local Response = require "wsapi.response"
#!/usr/bin/env wsapi.cgi
local fw = require "framework"
local app = fw.app.new()
app:setup_session("s3cret key")
local page_home = [[
<!DOCTYPE html>
<html>
@wolfiestyle
wolfiestyle / sleep.c
Created March 26, 2015 02:41
lua sleep
#include <lua.h>
#include <lauxlib.h>
#ifdef _WIN32
#include <windows.h>
#define EXPORT __declspec(dllexport)
#else
#include <sys/time.h>
#include <unistd.h>
#define EXPORT
diff --git a/src/openssl.c b/src/openssl.c
index 99a1ec0..7dc19e2 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -2988,7 +2988,7 @@ static int xc_getVersion(lua_State *L) {
static int xc_setVersion(lua_State *L) {
X509 *crt = checksimple(L, 1, X509_CERT_CLASS);
- int version = luaL_checkint(L, 2);
+ int version = luaL_checkinteger(L, 2);
@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
@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 / 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 / gist:2039291
Created March 14, 2012 20:30
assign all views on R.id to member variables of the same name using reflection
/** assign all views on R.id to member variables of the same name using reflection */
private void findAllViews()
{
Field[] r_fields = R.id.class.getDeclaredFields();
for (Field f: r_fields)
{
String name = f.getName();
Field v;
try
{
@wolfiestyle
wolfiestyle / markov1.d
Created April 23, 2012 01:45
generates a random string from stdin text input using a Nth order markov chain
import std.stdio, std.array, std.string, std.conv, std.random;
enum { ORDER = 2, MAX_RESULT_WORDS = 20 }
void main()
{
uint[string][string] dict;
string[] prev;
foreach (line; stdin.byLine())
foreach (word; split(to!string(toLower(line))))