Skip to content

Instantly share code, notes, and snippets.

View Caaz's full-sized avatar

Daniel Cavazos Caaz

View GitHub Profile
@Caaz
Caaz / game.rb
Created February 10, 2017 01:04 — forked from mbartlet/game.rb
require_relative 'nim.rb'
nim = Nim.new
print "Please select board configuration: (0: [4,3,7], 1: [1,3,5,7]): "
choice = Integer(gets.chomp) rescue nil
while !(choice.match(/0|1/))
puts "Invalid input"
puts "Please select board configuration: (0: [4,3,7], 1: [1,3,5,7]): "
choice = Integer(gets.chomp) rescue nil
end
@Caaz
Caaz / nim.pl
Last active February 10, 2017 01:59
#!/usr/bin/perl
use warnings;
use strict;
my $board = 12;
sub board($) {
print "There are $board board pieces left.\n";
print "\n".$_[0]." Wins!\n\n" if($board <= 0);
}
sub take($$) {
my ($p,$t) = @_;
@Caaz
Caaz / swifty
Created February 21, 2017 21:53
$(document).scroll(function(e){
var $window = $(window)
var $authors = $('.author')
if($authors.length > 0) {
$authors.each(function(i, e) {
var $author = $(e)
var $container = $author.parent().parent()
var offset = Math.max(0, $window.scrollTop() - $container.offset().top + 50)
offset = Math.min($container.height() + $container.offset().top - $author.outerHeight() - 50, offset)
#!/usr/bin/perl
use warnings;
use strict;
my $rounds = 1000;
my $wins;
my @initialDoors = (0..100);
for(my $round = 0; $round < $rounds; $round++) {
my @doors = @initialDoors;
for my $door (@doors) { $door = 0; }
my $choice = int rand @doors;
@Caaz
Caaz / oo.lua
Created June 19, 2017 20:20
Fancy object oriented way to load stuff into pico games
function particle_module()
local particles, particle_default =
{}, { position = {0,0}, decay = .5, color = 7, size = 4 }
return {
add = function(particle)
for k,v in pairs(particle_default) do particle[k] = particle[k] or v end
if particle.jitter then
particle.position[1] += rnd()*particle.jitter-particle.jitter/2
particle.position[2] += rnd()*particle.jitter-particle.jitter/2
end
@Caaz
Caaz / Navi.go
Created July 17, 2017 05:45
An alarm system! Thing.
package main
import (
"time"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
@Caaz
Caaz / main.go
Created July 17, 2017 05:46
Alarm thing less tab
package main
import (
"time"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
@Caaz
Caaz / base64shit.go
Created September 5, 2017 00:23
Shit of base64 integer conversions
package main
import (
"fmt"
)
func main() {
fmt.Println(i_to_base64(500))
}
func i_to_base64(num int) string {
@Caaz
Caaz / index.pug
Created September 12, 2017 04:23
simple pug index to test out navbars
doctype html
html
head
link(rel='stylesheet' href='/css/main.css')
script(src='/js/main.js')
body
div(uk-sticky="sel-target: .uk-navbar-container; cls-active: uk-navbar-sticky")
nav.uk-navbar-container(uk-navbar)
.uk-navbar-center
ul.uk-navbar-nav
@Caaz
Caaz / compile.pl
Created September 12, 2017 05:46
Markdown compiler for simple variable substitution
#!/usr/bin/perl
use warnings;
use strict;
use Caaz::Prompt;
if($ARGV[0]) {
my (@lines, %map);
open FILE, "<$ARGV[0]";
chomp(@lines = <FILE>);
close FILE;