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
def f x; x**2 + 2*x + 1; end | |
def integrate sym, a, b | |
dx = 0.001 | |
fn = method sym | |
dx * (a..b - dx).step(dx).map(&fn).sum | |
end | |
puts integrate :f, 2, 4 |
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
REDACT = %w{ k m v w x z } | |
longest = Array.new | |
def valid? word | |
(REDACT & (word.split '')).empty? | |
end | |
words = (File.read 'words.txt').split /\s/ | |
words.each { |word| longest = word unless word.size <= longest.size || !(valid? word) } |
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
/* | |
* By: josephg - https://github.com/josephg | |
* From: https://github.com/josephg/noisejs/blob/master/perlin.js | |
* Only slight modification from me, so it works as a module. | |
*/ | |
/* | |
* A speed-improved perlin and simplex noise algorithms for 2D. | |
* | |
* Based on example code by Stefan Gustavson ([email protected]). |
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
#!/usr/bin/env ruby | |
$DEBUG = false | |
EOF = "\0" | |
String.class_eval { define_method(:arg?) { ARGV.include? self } } | |
ALLOC = '--alloc'.arg? ? ARGV[(ARGV.index '--alloc') + 1].to_i : 100 | |
PROGRAM = (File.read ARGV.select { |arg| File.file? arg }.first) + EOF |
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
#!/usr/bin/env ruby | |
require 'rmagick' | |
include Magick | |
PRONOUN_DIR = File.expand_path './pronoun_images/' | |
def parse_pronouns file | |
raw = File.read File.expand_path file | |
raw.split("\n").map{ |line| line.split(/--|\//).map(&:strip) } |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/p5.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/addons/p5.dom.min.js"></script> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
<meta charset="utf-8" /> | |
</head> | |
<body> | |
<script src="sketch.js"></script> |
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
def note frequency, volume, chord, octave | |
octaves = [ 'Qj}6jQ6%' '_u}6u_6%' ] # Some good sounding random octaves | |
octave_index = 0 | |
octave_index = (frequency % 4 >> 16) % octaves.size | |
volume += 1 | |
return 0 if volume.zero? | |
choose = frequency * (octaves[octave_index][chord % 8].ord + 51) | |
choose = (choose >> octave) % 4 | |
choose % volume << 4 |
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
require 'net/http' | |
require 'uri' | |
uri = URI.parse 'http://www.mirrorservice.org/sites/ftp.archlinux.org/iso/2017.11.01/archlinux-2017.11.01-x86_64.iso' | |
uri = URI.parse 'http://ipv4.download.thinkbroadband.com/10MB.zip' | |
download = File.basename uri.path | |
#spin_states = %w{ - \\ | / Done! } # Traditional line spinner | |
#spin_states = %w{ /^v^\\ \\^v^/ \\ovo/ } # Happy bats |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#define u64 unsigned long long | |
typedef unsigned short int bool; | |
#define false (unsigned short)0 | |
#define true (unsigned short)1 |
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
alias kill='kill -KILL' | |
alias lookup='ps aux | grep' | |
alias goodnight='sudo systemctl suspend' | |
alias ls='ls --color=auto' | |
alias clean='sudo pacman -Qdtq | xargs sudo pacman --noconfirm -Rsn' | |
alias pacman='sudo pacman' | |
alias root='su root' | |
alias s='sudo' | |
alias please='sudo !-1' | |
alias starwars='telnet towel.blinkenlights.nl' |