Skip to content

Instantly share code, notes, and snippets.

View Demonstrandum's full-sized avatar

Samuel Demonstrandum

View GitHub Profile
# An example configuration file for MPD.
# Read the user manual for documentation: http://www.musicpd.org/doc/user/
# Files and directories #######################################################
#
# This setting controls the top directory which MPD will search to discover the
# available audio files and add them to the daemon's online database. This
# setting defaults to the XDG directory, otherwise the music directory will be
# be disabled and audio files will only be accepted over ipc socket (using
<ul class="website-list ui-sortable">
<li class="website-list-item ui-state-default sorting-initialize ui-sortable-handle">
<span class="website-name">Github</span>
<i class="fa fa-times remove-website"></i>
<a target="_blank" class="website-link" href="https://github.com">https://github.com/</a>
</li><li class="website-list-item ui-state-default sorting-initialize ui-sortable-handle">
<span class="website-name">Gist it</span>
<i class="fa fa-times remove-website"></i>
<a target="_blank" class="website-link" href="https://gist.github.com/">https://gist.github.com/</a>
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'
@Demonstrandum
Demonstrandum / frost_sieve.c
Last active October 25, 2017 19:50
Prime Sieve, Frost.
#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
@Demonstrandum
Demonstrandum / progress_bar.rb
Last active November 5, 2017 23:39
Different style progress bars in Ruby
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
@Demonstrandum
Demonstrandum / music.rb
Last active January 21, 2018 16:29
Generating sweet saw tooth wave synths in Ruby, duuuude.
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
@Demonstrandum
Demonstrandum / index.html
Last active June 1, 2018 00:59
p5 Riemann sum
<!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>
#!/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) }
@Demonstrandum
Demonstrandum / brainfrog
Last active July 8, 2018 15:10
Fully functioning Brainf*ck interpreter in Ruby
#!/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
@Demonstrandum
Demonstrandum / perlin.js
Created August 5, 2018 23:24
Perlin and Simplex noise -- by josephg
/*
* 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]).