Skip to content

Instantly share code, notes, and snippets.

View raws's full-sized avatar
🥯
dabbling in pumpernickel

Ross Paffett raws

🥯
dabbling in pumpernickel
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JQuery Demo</title>
<style type="text/css" media="screen">
#the-box {
padding: 1em;
background-color: lightblue;
}
@raws
raws / WeightedCollection.java
Created January 24, 2012 04:24
Weighted randomization in Java
import java.util.NavigableMap;
import java.util.Random;
import java.util.TreeMap;
public class WeightedCollection<E> {
private NavigableMap<Integer, E> map = new TreeMap<Integer, E>();
private Random random;
private int total = 0;
@raws
raws / wonder-llama-demo.rb
Last active June 9, 2021 04:04
Quick demo of responding to bot mentions using Wonder Llama: https://github.com/raws/wonder-llama
require 'bundler/inline'
gemfile do
gem 'wonder-llama', github: 'raws/wonder-llama', branch: 'master', require: 'wonder_llama'
end
def bot_mentioned?(message)
message.content.include?('@**Ralph**')
end
5.times do
print "I am a giant bucket"
end
@raws
raws / 01-install.txt
Created November 23, 2012 03:34
Install Ruby 1.9.3-p327 on a Synology DS1511+ with DSM 4.1
#########################################
### Install wget-ssl over ipkg's wget ###
#########################################
$ ipkg install -verbose_wget libidn # To get ipk URL
$ ipkg install -verbose_wget wget-ssl # To get ipk URL
$ /usr/syno/bin/wget http://ipkg.nslu2-linux.org/feeds/optware/syno-i686/cross/unstable/libidn_1.25-1_i686.ipk
$ /usr/syno/bin/wget http://ipkg.nslu2-linux.org/feeds/optware/syno-i686/cross/unstable/wget-ssl_1.12-2_i686.ipk
$ ipkg install libidn_1.25-1_i686.ipk
$ ipkg install wget-ssl_1.12-2_i686.ipk
@raws
raws / gist:07002f33ff6cd2e0b6c638dc627ad3e5
Created November 26, 2018 21:23
Ruby array block argument splatting
[['foo', 'bar', 'baz']].each { |array| puts array.inspect }
#=> ["foo", "bar", "baz"]
[['foo', 'bar', 'baz']].each do |first, second, third|
puts first.inspect
puts second.inspect
puts third.inspect
end
#=> "foo"
#=> "bar"
@raws
raws / pumpkin_collection.rb
Created February 21, 2018 01:45
Demonstration of how to create an #each method on our own class that behaves similarly to Array#each
class PumpkinCollection
def initialize(colors)
@colors = colors
end
def each
i = 0
while i < @colors.length do
color = @colors[i]
@raws
raws / puma.rb
Created January 18, 2018 18:19
Puma config snippet
workers Integer(ENV.fetch('WEB_CONCURRENCY', '2')) / 2
threads_count = ENV.fetch('RAILS_MAX_THREADS', '2')
threads threads_count, threads_count
preload_app!
@raws
raws / downcase.sh
Created July 15, 2012 17:12
Bash helper script for recursively lowercasing file names
#!/bin/bash
#
# downcase PATH
#
# Recursively convert all file names contained in the given directory
# tree (but excluding the given directory itself) to lowercase.
# Existing files which are named identical to new, lowercased file
# names will be clobbered.
#
# Author: Ross Paffett <ross@rosspaffett.com>
@raws
raws / SRVLookupTest.java
Created February 1, 2012 19:36
Example SRV record lookup for Minecraft servers
package com.rosspaffett.srv;
import org.xbill.DNS.Lookup;
import org.xbill.DNS.Record;
import org.xbill.DNS.SRVRecord;
import org.xbill.DNS.TextParseException;
import org.xbill.DNS.Type;
public class SRVLookupTest {