This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/home/greg/.rvm/rubies/default/bin/ruby | |
require 'rmagick' | |
# monkeypatch string to convert bases | |
class String | |
def convert_base(from, to) | |
to_i(from).to_s(to) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/home/greg/.rvm/rubies/default/bin/ruby | |
require 'gosu' | |
# main class for the laser element in game | |
class Laser | |
attr_reader :created_at, :x, :y, :created_by | |
def initialize(window_size, angle, player) | |
@window_size = window_size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.flatten = function () { | |
var flat_arr = []; | |
var dirty = false; | |
for (var i = 0; i < this.length; i++) { | |
if (typeOf(this[i]) == "array") { | |
flat_arr = flat_arr.concat(this[i]); | |
dirty = true; | |
} else { | |
flat_arr.push(this[i]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Euclidean distance in ruby (2-dimensional) | |
# The points have to be in the format [x, y] | |
def euclidean_distance(point1, point2) | |
# First; group the x's and y's, then sum the squared difference in x's and y's | |
Math.sqrt(point1.zip(point2).reduce(0) { |sum, p| sum + (p[0] - p[1]) ** 2 }) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
xev | grep -Po '\(keysym\s[^)]+,\s\K([^\)]+)' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p 'Would you like to play a game?' | |
abort 'I hope to play sometime' unless gets.chomp.upcase.ord==89 | |
p 'Rock, paper or scissors?' | |
p (s=(a={82=>83,80=>82,83=>80}).keys.sample)==(i=gets.upcase.ord) ? 'Tie' : (a[i]==s ? 'Win' : 'Loss') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
wget https://source.unsplash.com/random/1920x1080 -O ~/.wallpaper.jpg | |
feh --bg-fill ~/.wallpaper.jpg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/fogleman/gg" | |
"math/rand" | |
) | |
func randomFromDistribution(distribution []float64) int { | |
randFloat := rand.Float64() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function $(value) { | |
return document.querySelector(value); | |
} | |
const canvas = $('canvas'); | |
const sets = [ | |
[-0.4, 0.0, 0.0, -0.4, -1.0, 0.1], | |
[0.76, -0.4, 0.4, 0.76, 0.0, 0.0] | |
]; |