Skip to content

Instantly share code, notes, and snippets.

@swarminglogic
swarminglogic / autodirexec.py
Last active Dec 17, 2015
Monitors executables in a directory (passed as argument). Executables that are modified (based on md5sum) or introduced, are executed.
View autodirexec.py
#!/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 / autobuild.sh
Last active Dec 17, 2015
Watch over project files, and automatically rebuild project when files are modified. Created with SCons and C++ in mind, but can easily be customized.
View autobuild.sh
#!/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 / updatesdl.sh
Created May 27, 2013
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/)
View updatesdl.sh
#!/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 / gifcapture.sh
Last active Jun 5, 2018
gifcapture -- A linux tool to record a region of the screen and convert it to a well optimized gif.
View gifcapture.sh
#!/bin/bash
delay=0.2
title='default'
count=0
loop=1 #0 for infinite loop
# Set if you want to skip mouse selection
if [[ $# -eq 6 ]]
then
@swarminglogic
swarminglogic / Main.cpp
Last active Dec 18, 2015
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.
View Main.cpp
#include <iomanip>
#include <iostream>
int spritesSDL();
int spritesSFML();
int spritesAlphaSDL();
int spritesAlphaSFML();
@swarminglogic
swarminglogic / createwebfolder.sh
Last active Dec 19, 2015
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.
View createwebfolder.sh
#!/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 / focusscreen.sh
Created Jul 2, 2013
Script to move mouse cursor to the specified screen (for separate x screens).
View focusscreen.sh
#!/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 / getoeis.sh
Created Aug 15, 2013
Bash script to crawl the OEIS database, and get the number of entries for each integer. See http://swarminglogic.com/articles/2013_08_oeis for more information.
View getoeis.sh
#!/bin/bash
[[ ! "$1" == "-" && ! "$1" == "+" ]] && echo "Invalid sign paramter [-|+]" && exit;
[[ "$1" == "-" ]] && suff="neg";
[[ "$1" == "+" ]] && suff="pos";
cntfile='cntfile_'$suff
[[ ! -e $cntfile ]] && echo '0' > $cntfile;
file='values_'$suff
@swarminglogic
swarminglogic / nicekill.sh
Last active Jan 4, 2016
nicekill: A bash script to terminate a process in the order of SIGTERM, SIGINT, SIGHUP, SIGKILL, giving each signal 2 seconds to enact.
View nicekill.sh
#!/bin/bash
# $1: PID
# Returns true if a process exists with pid=PID
function isProcessAlive {
if [ `ps -p $1 | wc -l` -gt 1 ] ; then
return 0;
else
return 1;
fi
@swarminglogic
swarminglogic / recordscreen.sh
Last active Aug 29, 2015
recordscreen: A bash script for timelapse recordinging two separate X displays, and creating a picture-in-picture overlay with one display
View recordscreen.sh
#!/bin/bash
if [ ! $# -eq 2 ] ; then
echo "Usage: ./recordscreen delay outputfolder"
exit
fi
if [ ! -d $outputFolder ] ; then
echo "Output folder does not exist"
exit