Skip to content

Instantly share code, notes, and snippets.

View Karunamon's full-sized avatar

Mike Parks Karunamon

View GitHub Profile
@Karunamon
Karunamon / string_ranges.rb
Last active December 31, 2015 23:49
A monkey patch to return enumerable ranges from arbitrary strings
class String
def to_r
a = self.partition(/\(.+?\)/)
fail "No range in string" if a[0].empty?
fail "Invalid range #{a}" if a.select { |v| v.match(/[A-Za-z]/) }
eval a[1]
end
def to_r_leading_zero
a = self.partition(/\(.+?\)/)
If you want, I can try and help with pointers as to how to improve the indexing speed you get. Its quite easy to really increase it by using some simple guidelines, for example:
- Use create in the index API (assuming you can).
- Relax the real time aspect from 1 second to something a bit higher (index.engine.robin.refresh_interval).
- Increase the indexing buffer size (indices.memory.index_buffer_size), it defaults to the value 10% which is 10% of the heap.
- Increase the number of dirty operations that trigger automatic flush (so the translog won't get really big, even though its FS based) by setting index.translog.flush_threshold (defaults to 5000).
- Increase the memory allocated to elasticsearch node. By default its 1g.
- Start with a lower replica count (even 0), and then once the bulk loading is done, increate it to the value you want it to be using the update_settings API. This will improve things as possibly less shards will be allocated to each machine.
- Increase the number of machines you have so
@Karunamon
Karunamon / ssh_tunnel.sh
Created December 30, 2013 15:19
SSH tunnel setup script. Source in your profile for awesomeness.
#!/bin/bash
function proxtun(){
#Validity check of settings
if [ ! -e ~/.proxtun ]; then
echo "No proxy user/host set. Please set up a remote machine with SSH"
echo "tunneling capability (with keys) and then put that user@host in"
echo "~/.proxtun"
return 5
fi
tunhost=`cat ~/.proxtun`
@Karunamon
Karunamon / web.py
Last active January 25, 2016 00:15
Flask Class Shenanignas
from flask import Flask
import thread
web = Flask(__name__)
class AwesomeClass(object):
def __init__(self):
thread.start_new_thread(web.run, ())
self.some_important_var = "spam"
@Karunamon
Karunamon / SMCGP.md
Last active February 14, 2016 21:50
SMCGP

%%%%%%%%%%%%%%%%%%%%%%%%%%%

Title = "Short Message Chess Game Protocol"
abbrev = "Short Message Chess Game Protocol"
category = "info"
docName = "smcgpv1-draft"
ipr = "full3978"

[pi]

private = "yes"

@Karunamon
Karunamon / triples.java
Last active May 16, 2016 15:30
Pythagorean triple finders, comparing a basic for loop vs a parallelStream
import java.util.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.stream.*;
class Main {
private static class tripleCandidate {
BigDecimal a;
BigDecimal b;
@Karunamon
Karunamon / redbot.service
Created July 22, 2016 15:43
Systemd unit for a Twitch bot
[Unit]
Description=Red-DiscordBot
After=Network.target
[Service]
Type=simple
#Yeah, it's discouraged to run as root, but this is a single purpose VM. Change user appropriately, and make sure to update the workingdirectory.
User=root
ExecStart=/usr/bin/python3.5 /root/Red-DiscordBot/red.py
Restart=on-abort
@Karunamon
Karunamon / gist:7e4773825308e6c12da9b2bc5d57b910
Created July 26, 2016 15:26
Install mu with the EMACS var
$ EMACS=$(which emacs) brew install mu --with-emacs --verbose
=> Downloading https://github.com/djcb/mu-releases/raw/master/mu-0.9.16.tar.gz
Already downloaded: /Library/Caches/Homebrew/mu-0.9.16.tar.gz
==> Verifying mu-0.9.16.tar.gz checksum
tar xvzf /Library/Caches/Homebrew/mu-0.9.16.tar.gz
x mu-0.9.16/
x mu-0.9.16/COPYING
x mu-0.9.16/TODO
x mu-0.9.16/Makefile.in
x mu-0.9.16/guile/
@Karunamon
Karunamon / gist:4818b245b7cfe42f8a235dd8fdede447
Created July 26, 2016 15:29
Install mu without the EMACS var
$ brew install mu --with-emacs --verbose
==> Downloading https://github.com/djcb/mu-releases/raw/master/mu-0.9.16.tar.gz
Already downloaded: /Library/Caches/Homebrew/mu-0.9.16.tar.gz
==> Verifying mu-0.9.16.tar.gz checksum
tar xvzf /Library/Caches/Homebrew/mu-0.9.16.tar.gz
x mu-0.9.16/
x mu-0.9.16/COPYING
x mu-0.9.16/TODO
x mu-0.9.16/Makefile.in
x mu-0.9.16/guile/
@Karunamon
Karunamon / tvg.md
Created January 29, 2017 00:33
Twitch vs Glitch

Twitch vs Glitch

General Description:

Streamer plays SMB3 (or similar NES game) using the BizHawk Real Time corruptor mod.

Hotkeys are mapped into various RTC functions, by a bot that hangs out in the twitch chat.

One random viewer is chosen. They have 30 seconds to !roll a d20 equivalent, which determines how many rounds of garbage are injected into the game. Other methods to get extra injections include trivia and puzzles.