Skip to content

Instantly share code, notes, and snippets.

View AGhost-7's full-sized avatar
🤖
Discombobulating the hive mind

Jonathan Boudreau AGhost-7

🤖
Discombobulating the hive mind
  • The land of maple syrup
View GitHub Profile
@AGhost-7
AGhost-7 / client.bash
Last active February 19, 2016 02:13
Play music from the command line lol
# Make sure to run `paprefs` and make pulseaudio discoverable.
serverIp=something
# Send your client's ip over to the server.
wget http://ipinfo.io/ip -qO - | ssh $serverIp 'cat - > client_ip'
# Install x11 server and add the client ip to the list of allowed clients.
# TODO: https://razor.occams.info/blog/2009/02/11/pulseaudio-sound-forwarding-across-a-network/
ssh $serverIp 'sudo apt-get install xorg -y && xhost `cat client_ip`'
ssh -X $serverIp
@AGhost-7
AGhost-7 / multi-chat-installer.sh
Last active February 20, 2016 13:49
Install pidgin with Facebook chat, Google Talk/Hangouts. Slack client, facebook client.
sudo apt-get update
sudo apt-get install pidgin -y
sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/jgeboski/xUbuntu_$(lsb_release -rs)/ /' >> /etc/apt/sources.list.d/jgeboski.list"
cd /tmp && wget http://download.opensuse.org/repositories/home:/jgeboski/xUbuntu_$(lsb_release -rs)/Release.key
sudo apt-key add - < Release.key
sudo apt-get update
sudo apt-get install purple-facebook
sudo apt-add-repository -y ppa:rael-gc/scudcloud
@AGhost-7
AGhost-7 / create-app-runner.sh
Created January 8, 2016 15:50
use `./run-app` instead of `node server.js`
script="
export APP_CONFIG_PATH=`pwd`
node server.js
"
echo $script > run-app
chmod +x run-app
echo run-app >> .git/info/exclude
@AGhost-7
AGhost-7 / pub-sub-configs.js
Created January 5, 2016 18:07
Use publish/subscribe with database persistence to cache on the application server (high read data)
// In some situations, you want the "configuration" to be persistent and dynamic. For example, a
// web site with dynamic forms.
// There are multiple ways of making this work...
// - Store it in the database and access it when you need it; very poor performance.
// - Store it in the database and cache the data directly in the application server. Update
// every now and then; better performance, but not very clean considering you will need to wait
// for the configuration changes to take effect.
// - Use pud/sub; best performance and changes are instantaneous.
function reactiveDataPool(seneca, pgClient, entityName, query, done) {
var pushAll = function(arr, items) {
function add(a, b) {
if(arguments.length === 1) {
return add.bind(null, a);
} else {
return a + b;
}
}
var increment = add(1);
console.log(increment(10)); // 11
@AGhost-7
AGhost-7 / coffeelint.json
Last active December 21, 2015 02:46
Very strict Coffeescript
{
"arrow_spacing": {
"level": "ignore"
},
"braces_spacing": {
"level": "ignore",
"spaces": 0,
"empty_object_spaces": 0
},
"camel_case_classes": {
@AGhost-7
AGhost-7 / peer2peer-nodes.md
Last active December 17, 2015 01:55
Ramblings on peer to peer game servers

How do nodes discover each other?

Seems like the only way is to have a base list, or at least one node being pointed to the new instance. Maintain a table of addresses for each connected nodes, and share them between other nodes.

How to ensure the node is supposed to be part of the cluster?

Secret key generated on build of the application? Not sure. Public Key Certificate to verify ownership would probably be the best way (read - easiest), at least for the initial connection to ensure that you're not adding a spoofed node.

class One {
public static void main(String [] args) {
Scanner scn = new Scanner(System.in);
Two two = new Two(scn);
}
}
@AGhost-7
AGhost-7 / bashrc
Last active May 8, 2017 17:11
Encrypt Vagrant VMs on a separate partition
#
# Encrypting Vagrant VMs: I don't want to encrypt my entire filesystem due to
# the performance hog that it is. I don't even want it to decrypt
# automatically on login; I only really need the encryption for certain
# projects that I'm working on.
#
# One of the issues with this solution is that it globally changes where
# VirtualBox and Vagrant will save their data. I wasn't able to find a way
# to make VirtualBox load a VM from a different location aside from changing
@AGhost-7
AGhost-7 / pogostick-stream.js
Created November 9, 2015 18:15
Pogostick streaming?
function noop() {}
var debug = noop;
function feedServer(stream, options, procHandler) {
stream.on('data', function(buf) {
var data = buf.toString();
var msg = data.split('\n');