Skip to content

Instantly share code, notes, and snippets.

View bartek's full-sized avatar
🐗

Bartek Ciszkowski bartek

🐗
View GitHub Profile
var gamejs = require('gamejs');
var handleEvent = function(data) {
gamejs.log("Ugh", data);
};
gamejs.ready(function() {
gamejs.onEvent(handleEvent);
});
var __scripts = ["http://127.0.0.1:4000/javascript/public/lodash.js","http://127.0.0.1:4000/javascript/public/yabble.js","http://127.0.0.1:4000/javascript/public/gamejs.min.js"];
__scripts.forEach(function(script) {
try {
importScripts(script);
} catch (e) {
// can't help the worker
}
});
self.require.setModuleRoot("http://127.0.0.1:4000/javascript/");self.require.run("./gramework/gamepad");
#index.html
<!-- Start javascript/main.js -->
<script src='./javascript/public/lodash.js'></script>
<script src="./javascript/public/yabble.js"></script>
<script src="./javascript/public/gamejs.min.js"></script>
<script>
require.setModuleRoot('./javascript/');
require.run('main')
</script>
@bartek
bartek / gist:4670192
Last active April 6, 2019 21:08
Postgres memory optimization

After some reading and help from #postgresql. I settled on these changes to my memory settings in postgresql.conf. This is on a box with 8gb of ram and 2 cpus.

shared_buffers = 1GB
work_mem = 128MB
maintenance_work_mem = 256MB
effective_cache_size = 6GB

For kernel settings, I did this:

kernel.shmmax=1288490000

@bartek
bartek / emoticons.json
Created January 17, 2013 03:32
collection of emoticons so far primarily collected from reddit.
{
"misc": [
"(✿つ⌒∇⌒)つ~♡"
],
"reddit": [
"⊙▃⊙",
"๏̯͡๏﴿",
"ಠ~ಠ",
"ಠoಠ",
"ರ_ರ",
@bartek
bartek / postgres_slave_promote.md
Created January 10, 2013 14:29
What to do when promoting a postgresql slave to master

This example is based on having a cascading setup, where you have a single master, a single "primary" slave, and cascading slaves which are being replicated from the primary slave. For an example of this setup, check out http://bartek.im/blog/2012/12/04/postgresql-92-streaming-primer.html

On the existing master, if accessible, stop postgres.

$ sudo service postgresql stop

And better to be safe than sorry. We can't have two masters running. (I only use this in an automated script. If you're doing this manually, you'd know if it was shutoff)

$ kill -9 `sudo cat /var/lib/postgresql/9.2/main/postmaster.pid | head -n 1` &> /dev/null
@bartek
bartek / gist:4439084
Created January 2, 2013 22:56
open currently opened file in vim with Marked.app
command! Marked silent !open -a "Marked.app" "%:p"
command! Marked silent !open -a "Marked.app" "%:p"
@bartek
bartek / change_db_ownership.sh
Created December 20, 2012 15:32
Script by Alex Soto.
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script set ownership for all table, sequence and views for a given database
Credit: Based on http://stackoverflow.com/a/2686185/305019 by Alex Soto
@bartek
bartek / postgres_replication_status.py
Created November 26, 2012 20:18
postgres replication status
# I hate urllib and subprocess, so use tools by Kenneth Reitz.
import envoy
import requests
from socket import socket, AF_INET, SOCK_DGRAM
# Simple script to check the delay in replication between master and slave(s).
# The server runnin this will need to be allowed access via pg_hba to all the
# hosts it connects to.
hosts = (