Skip to content

Instantly share code, notes, and snippets.

View aweijnitz's full-sized avatar

Anders Weijnitz aweijnitz

View GitHub Profile
@aweijnitz
aweijnitz / copySubmissions.php
Last active December 29, 2015 18:39
PHP script to copy ukulele advent calendar submissions using the day of month as base file name (i.e. 1.htm, 1.mp3, 1.jpg on Dec 1st and so on)
<html>
<head>
<title>My First PHP Page</title>
</head>
<body>
<?php
// Change these to actual directory paths (including trailing slash '/')
$SOURCE_DIR = '/Users/anders/tmp/from/';
$DESTINATION_DIR = '/Users/anders/tmp/to/';
@aweijnitz
aweijnitz / Twitter UTC Date Parser
Created February 20, 2014 21:22
Parsing UTC time from Twitter's created_at field
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.Locale;
/** Parse UTC time from Twitter's created_at field.
*
* Compile and run: javac TwitterDateParser.java && java TwitterDateParser
@aweijnitz
aweijnitz / DateAritmethics
Created March 25, 2014 20:33
Illustration of basic date arithmetics in Java.
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
public class DateAritmethics {
public static void main(String[] args) {
@aweijnitz
aweijnitz / Vagrantfile
Last active March 25, 2024 13:54
This is a Vagrant file and a provisioning script to create a Debian-based Jenkins server, including Java, Ant and Tomcat. Also see "provision.sh" below
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
# Named boxes, like this one, don't need a URL, since the are looked up
@aweijnitz
aweijnitz / Basic Template Engine
Last active August 29, 2015 14:04
Three-line Template Engine in Javascript for quick substitution of object properties into a string
/**
* A mini "template engine".
* Arguments:
* template - A string of looking like "Something {{variableName}} and {{nested.object.data}}"
* data - A Javascript object with properties to substitute into the template
*
* Returns:
* A string with the variables substituted with the corresponding properties from the data
*/
var applyTemplate = function(template, data) {
@aweijnitz
aweijnitz / RF Link 433Mhz receiver
Last active January 4, 2016 11:14
RF Link 433MHz debug setup for Arduino
@aweijnitz
aweijnitz / installJava8.sh
Last active April 19, 2019 12:42
Provisioning script for non-interactive Java8 installation on Linux
#!/bin/sh
# From http://www.webupd8.org/2014/03/how-to-install-oracle-java-8-in-debian.html
#
# You need to run this script as root
#
# su -
echo "INSTALLING JAVA 8 AS USER `whoami` "
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list
@aweijnitz
aweijnitz / setupSecurity.sh
Last active August 29, 2015 14:14
Basic firewall and connection autobanning on Debian
#!/bin/bash
#
# ____ Install Uncomplicated Firewall (frontend to iptables)
#
sudo apt-get install -y ufw
# Be paranoid
sudo ufw disable
@aweijnitz
aweijnitz / installIOJS.sh
Created January 30, 2015 21:33
script to install io.js
#!/bin/sh
su -
mkdir ./downloads
cd downloads
rm -rf /uss/lib/iojs*
rm /usr/bin/iojs
rm /usr/bin/node
rm /usr/bin/npm
@aweijnitz
aweijnitz / listBannedIPs.sh
Created January 30, 2015 21:34
list banned IP addresses in iptables
sudo iptables -L -n