Skip to content

Instantly share code, notes, and snippets.

View MonkeyIsNull's full-sized avatar

Adam Guyot MonkeyIsNull

View GitHub Profile
@MonkeyIsNull
MonkeyIsNull / gist:865814c4f92783025d9a
Last active August 29, 2015 14:17
Nginx redirect to local
server {
listen 80;
server_name www.demoit.io;
underscores_in_headers on;
listen 443 ssl;
client_max_body_size 500M;
ssl_certificate /etc/nginx/ssl/api_demoit_io.crt;
ssl_certificate_key /etc/nginx/ssl/api_demoit_io.key;
@MonkeyIsNull
MonkeyIsNull / Preso.exs
Created February 11, 2015 01:43
Presenter
defmodule Preso do
# shows what was passed in and then evals it and shoves the
# lhs back into the current context
defmacro show(stuff) do
{op, _, [{lhs,_, _}, rhs]} = stuff
IO.write "#{IO.ANSI.blue}#{IO.ANSI.bright}"
IO.write "#{lhs} #{op} "
IO.inspect rhs
IO.puts "#{IO.ANSI.reset}"
quote do
@MonkeyIsNull
MonkeyIsNull / war.exs
Last active August 29, 2015 14:10
War - Battle System
defmodule Die do
def init(), do: :random.seed(:erlang.now)
def d6(), do: :random.uniform(6)
def d100(), do: :random.uniform(100)
end
defmodule War do
def create_player(name, skill, hp) do
[ name: name, skill: skill, hp: hp ]
end
@MonkeyIsNull
MonkeyIsNull / lispwar.clj
Last active August 29, 2015 14:04
Simple Battle System
;; Die Roll stuff
(defn die-roll [numSides]
(int (+ 1 (rand numSides))))
(defn d4 []
(die-roll 4))
(defn d6 []
(die-roll 6))
@MonkeyIsNull
MonkeyIsNull / war.factor
Created June 29, 2014 20:51
Simple Battle System
USING: kernel random math accessors sequences prettyprint io ;
USING: io.encodings.binary io.files serialize math.parser ;
IN: examples.war
TUPLE: player name hitpoints acc ;
! We're starting w/ Two sample players on the stack
! The rule is to always keep them there
"Urg" 20 70 player boa
"Conan" 25 65 player boa
! "Gwent" 18 95 player boa
% Monkey problem in Prolog -- Taken from PPAI
% Before reading this code: http://www.youtube.com/watch?v=WnlIWpZSPXU
%
% First up is the move to the final spot we want
move(state(middle, onbox, middle, hasnot), %Before
grasp, %Action
state(middle, onbox, middle, has)). %After -- monkey wins motherfucker!
% Action climb
@MonkeyIsNull
MonkeyIsNull / dpdlFiles.go
Last active January 1, 2016 06:59
Download the MP3s from a DropBox server using Channels with 10 workers, handles the nasty redirects
package main
import (
"time"
"fmt"
"io"
"net/http"
"os"
"strings"
"github.com/PuerkitoBio/goquery"
@MonkeyIsNull
MonkeyIsNull / urlBuff.go
Created December 24, 2013 02:56
urlBuff simulates downloads with timers. It has four workers that continuously pull from the urlChannel until everything is done
package main
import (
"time"
"math/rand"
"fmt"
"strconv"
)
func randInt(min int, max int) int {
@MonkeyIsNull
MonkeyIsNull / acls.pl
Last active December 28, 2015 22:59
Experimental work on a Vertical and Horizontal Access system
% Here's our set of users
% Mind you, fred has no access_levels, he's a user
% but he can't even logon
user(jon).
user(mary).
user(ed).
user(fred).
% access_level(rankNumber, name, create, read, modify)
@MonkeyIsNull
MonkeyIsNull / harn.pl
Created October 1, 2013 00:11
Harn Master Skills setup in Prolog
% str(ulf, 19).
% intell(ulf, 12).
% dex(ulf, 10).
%str(gar, 12).
%intell(gar, 18).
%dex(gar, 13).
% calc_stats(X,N):-
% str(X,Y),