Skip to content

Instantly share code, notes, and snippets.

@swarminglogic
swarminglogic / focusscreen.sh
Created July 2, 2013 11:24
Script to move mouse cursor to the specified screen (for separate x screens).
#!/bin/bash
# Script to move mouse cursor to the specified screen (for separate x screens).
# Useful if set up to trigger with a global hotkey.
#
# e.g.: ./focusscreen.sh 0
#
if [ ! `which xdotool` ] ; then echo "You need xdotool!" && exit ; fi
@swarminglogic
swarminglogic / createwebfolder.sh
Last active December 19, 2015 02:59
Script to add and configure a virtual host to apache2 server. PS: Requires that /etc/apache2/ports.conf contains the lines "#ADD NAMEVIRTUALHOST" and "#ADD LISTEN" PPS: Rough script, but it gets the job done.
#!/bin/bash
#
# Modifies /etc/apache2/ports.conf to listen to specified port-number ($2)
# Adds configuration file to /etc/apache2/sites-available/$1.conf
# Creates symbolink to the above file in /etc/apache2/sites-enabled/$1.conf
# Restarts apache server.
#
# Note: This is a very rough script, and only used to automate a process.
# Not intended for production.
#
@swarminglogic
swarminglogic / Main.cpp
Last active December 18, 2015 22:59
SFML-vs-SDL-benchmark, forked from github.com/eXpl0it3r/SFML-vs-SDL-Benchmark. Since it's just a silly and fairly nonconstructive benchmark, I prefer to not have it listed as a forked repository.
#include <iomanip>
#include <iostream>
int spritesSDL();
int spritesSFML();
int spritesAlphaSDL();
int spritesAlphaSFML();
@swarminglogic
swarminglogic / updatesdl.sh
Created May 27, 2013 14:08
Update and build latest SDL 2.0 -- automatic pull and update from repository, and compile SDL, SDL_image, SDL_mixer, SDL_net, SDL_ttf. Simple Direct,edia Library (http://www.libsdl.org/)
#!/bin/bash
prefixDir=`pwd`/sdl2-x86
# ------------------------------ Functions Start ------------------------------
function cloneSdlRepo {
(hg clone http://hg.libsdl.org/$1 && cd SDL && hg co default && hg pull -u)
}
function pullAndBuildSdlRepo {
@swarminglogic
swarminglogic / autobuild.sh
Last active December 17, 2015 14:18
Watch over project files, and automatically rebuild project when files are modified. Created with SCons and C++ in mind, but can easily be customized.
#!/bin/bash
#
# Watch over project files, and automatically rebuild
# project when files are modified. Can easily be
# customized for different project types/languages.
#
# Use: ./autobuild.sh [executable]
#
# Optional: Pass path to executable to run whenever
@swarminglogic
swarminglogic / autodirexec.py
Last active December 17, 2015 13:39
Monitors executables in a directory (passed as argument). Executables that are modified (based on md5sum) or introduced, are executed.
#!/usr/bin/env python
import sys, os, commands, time, errno
def getExecutablesAndMd5(directory):
"""
Returns a dictionary with the following.
Key: Paths to executable within specified directory.
Value: The md5sums of the executable.
"""
@swarminglogic
swarminglogic / subtlemark.sh
Last active December 1, 2015 21:53
Subtlemark: Tool for adding subtle watermarks to images. Parameter customization: position (TL,TC,TR,BL,BC,BR), font, font-size, caption, textcolor, bgcolor. Also supports predefined styles.
#!/bin/bash
version=0.1.4
versionDate="2014-09-02"
function showHelp() {
echo "subtlemark - add subtle watermarks to images
Usage:
----------------------------------------
@swarminglogic
swarminglogic / userpass.sh
Last active December 1, 2015 21:52
Command-line utility to manage passwords, protected by sudo
#!/bin/bash
file=/home/$SUDO_USER/.local/share/userpass.list
function showHelp {
version=0.0.2
versionDate="2014-06-24"
echo "$0 - manage passwords
@swarminglogic
swarminglogic / info-mode.el
Last active November 18, 2015 08:22
emacs major mode for Boost PropertyTree INFO file format and parser
;;; info-mode-el -- Major mode for editing INFO files
;; Author: Roald Fernandez <contact@swarminglogic.com>
;; Created: 10 Nov 2014
;; Keywords: INFO major-mode
;; Copyright (C) 2014 Roald Fernandez <contact@swarminglogic.com>
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
@swarminglogic
swarminglogic / pngopt.sh
Last active August 29, 2015 14:06
pngopt: A wrapper for pngcrush, that makes it easier to use for overriding images with its optimized output (e.g ./pngopt filea.png fileb.png filec.png). If a file is optimized it outputs the filename with percentage reduction.
#!/bin/bash
# pngopt: A wrapper for pngcrush, that makes it easier to use for overriding
# images with its optimized output.
#
# use: pngopt FILE1 [FILE2] [FILE3] ...
#
# If a file is optimized it outputs the filename with percentage reduction.
#
#