Skip to content

Instantly share code, notes, and snippets.

@steegi
steegi / minecraft.service
Created July 23, 2016 15:48
Minecraft systemd (Ubuntu 16.04) configuration file
# /lib/systemd/system/minecraft.service
[Unit]
Description=Minecraft Server
[Service]
Type=forking
WorkingDirectory=/home/minecraft
User=minecraft
Group=minecraft
@steegi
steegi / stop-script.sh
Last active July 23, 2016 15:34
Minecraft Stop Script (tmux)
#!/bin/bash
tmux send-keys -t mcs 'say SERVER SHUTTING DOWN. Saving map...' C-m
tmux send-keys -t mcs 'save-all' C-m
tmux send-keys -t mcs 'stop' C-m
@steegi
steegi / start-script.sh
Last active July 23, 2016 15:27
Minecraft (Spigot) Startup Script (tmux)
#!/bin/bash
cd /home/minecraft
tmux new -d -s mcs 'java -Xms1G -Xmx7G -d64 -jar spigot-1.8.8-R0.1-SNAPSHOT-latest.jar nogui'
tmux detach -s mcs
@steegi
steegi / gist:11056123
Last active August 29, 2015 14:00
Installing trusty on crouton for Pixel
sudo sh -e ~/Downloads/crouton -t touch,keyboard,unity,extension,chrome -r trusty
sudo apt-get install ubuntu-session
@steegi
steegi / gist:5147716
Last active December 14, 2015 20:59
Extract the query parameters from a URL using Map/Reduce in JavaScript
/**
* Extracts the query parameters from a URL
* @url {string} url to be analyzed
* @return {string} params object with a property for each named URL query parameter set to the
* value of the parameter.
*/
function getUrlParams(url) {
// Note that a regex should be used to properly split the URL. I.e. an '=' inside a value will be lost
// This function is just to demonstrate the usage of Map/Reduce
var map = url.slice(url.indexOf('?') + 1).split('&').map(function(param) { return param.split('='); });
#bin/sh
sudo su
cd /usr/share/lirc/remotes/
# Make sure to include the trailing slash for the wget command as otherwise you'll be pulling all remotes
wget -r --no-parent -nH -R "index.html*" --cut-dir=1 http://lirc.sourceforge.net/remotes/pioneer/
wget -r --no-parent -nH -R "index.html*" --cut-dir=1 http://lirc.sourceforge.net/remotes/panasonic/
wget -r --no-parent -nH -R "index.html*" --cut-dir=1 http://lirc.sourceforge.net/remotes/lexicon/
wget -r --no-parent -nH -R "index.html*" --cut-dir=1 http://lirc.sourceforge.net/remotes/microsoft/
@steegi
steegi / gist:2942084
Created June 16, 2012 17:53
Script to drop disconnect and drop DB2 database
#!/bin/sh
db2 "connect to sugarult"
# Not sure if the following is actually need if the database needs to be restarted
# because of the 'currently in use' issues. However it should disconnect all application
# connected to the database.
db2 "quiesce database immediate force connections"
db2 "unquiesce database"
@steegi
steegi / gist:2934101
Created June 15, 2012 01:27
Script to drop all tables in a DB2 database
#/bin/sh
# Since there is no simple drop all tables from a database command in DB2,
# this script uses a few unix utilities to accomplish the same result
# Note that it assumes that your session is already connected to the database
# and that the schema from which you want to drop the tables has the same name
# as your current user.
db2 "Select 'DROP TABLE', TABLE_NAME from sysibm.tables WHERE TABLE_SCHEMA = UPPER('$USER')" | grep DROP | db2
@steegi
steegi / gist:2934001
Created June 15, 2012 01:07
Creating a SugarCRM DB2 developer database that works for all circumstances, but isn't suited for production
#!/bin/sh
# NOTE this creates a default 32k table space which is the maximum. Only a few tables in Sugar need 8k, others need only 4k
# However if you are using Studio the table needs enough extra space to add columns
# Also note that the specified collation is case insensitive US. By default DB2 is case sensitive.
db2 "CREATE DATABASE sugarult USING CODESET UTF-8 TERRITORY US COLLATE USING UCA500R1_LEN_S2 PAGESIZE 32 K"
# Sugar 6.4 and 6.5 need the Full Text Search engine up and running and operational.