Skip to content

Instantly share code, notes, and snippets.

@thomxc
thomxc / Headphones Last.fm auto update
Last active August 29, 2015 13:57
A Pen by Thomas Wiersema.
Headphones Last.fm auto update
-----
@thomxc
thomxc / InsertDate.gs
Created April 2, 2014 08:17
Google Docs Script Macro: Insert Date
/**
* The onOpen function runs automatically when the Google Docs document is
* opened. Use it to add custom menus to Google Docs that allow the user to run
* custom scripts. For more information, please consult the following two
* resources.
*
* Extending Google Docs developer guide:
* https://developers.google.com/apps-script/guides/docs
*
* Document service reference documentation:
@thomxc
thomxc / iptables
Last active August 29, 2015 14:07
CentOS iptables config
#DigitalOcean VPSs usually come with the empty configuration: all traffic is allowed. Just to make sure of this, we can flush the firewall rules - that is, erase them all:
iptables -F
#We can then add a few simple firewall rules to block the most common attacks, to protect our VPS from script-kiddies. We can't really count on iptables alone to protect us from a full-scale DDOS or similar, but we can at least put off the usual network scanning bots that will eventually find our VPS and start looking for security holes to exploit. First, we start with blocking null packets.
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
#We told the firewall to take all incoming packets with tcp flags NONE and just DROP them. Null packets are, simply said, recon packets. The attack patterns use these to try and see how we configured the VPS and find out weaknesses. The next pattern to reject is a syn-flood attack.
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
#Syn-flood attack means that the attackers
@thomxc
thomxc / gist:603d47bd0e41b763a577
Created December 15, 2014 20:47
LimeSurvey Exclusivity workaround for multi dimensional multiple choice questions
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var arrExclusive = ["A5", "A6"];
for (index = 0; index < arrExclusive.length; index++) {
$('input[type="checkbox"][name$="'+arrExclusive[index]+'"]').change(function(event) {
var objClicked = this;
var clicked = $(this).attr('name').substr(0,$(this).attr('name').length-2);
@thomxc
thomxc / index.html
Created July 21, 2015 13:51
Google's Material Design Drawer
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Material Design Lite components demo</title>
<link rel="stylesheet" href="css/style.css">
<div class="media">
<div class="col-sm-3">
<div style="margin: 1em; padding: 0em; border: 1px solid #ccc">
<div style="height:150px; background: url('/scripting/upload/surveys/272922/images/Hardloopster.png') no-repeat; background-size: contain; background-position: center"></div>
<div style="padding: 1em"><small>Boodschap 1</small><p>Zorgeloos genieten van het moment met muziek die past bij jouw stemming en smaak</p></div>
</div>
</div>
<div class="col-sm-3">
<div style="margin: 1em; padding: 0em; border: 1px solid #ccc">
<div style="height:150px; background: url('/scripting/upload/surveys/272922/images/Radio%20DJ\'s%205386666.png') no-repeat; background-size: contain; background-position: center"></div>
@thomxc
thomxc / phplint.sh
Created July 5, 2017 19:26
phplint shell script using directories or files as input and outputting exit codes
#!/bin/bash
error=false
echo "Starting phplint.."
while test $# -gt 0; do
current=$1
shift
if [ ! -d $current ] && [ ! -f $current ] ; then
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
local sonos_name = 'Draagbaar'
local sonos=assert(io.popen('curl http://localhost:5005/'..sonos_name..'/state'))
local status = sonos:read('*all')
sonos:close()
local jsonStatus = json:decode(status)
local tv_woonkamer_status = 'TV Woonkamer System Alive'
# inherit
source ~/.git-bash-for-mac.sh
# aliases
alias laradock="cd ~/workspace/laradock"
alias prod-up="docker-compose -f ~/workspace/laradock/production-docker-compose.yml up -d"
alias up="docker-compose up -d"
alias down="docker-compose down"
alias build="docker-compose up --build"
alias workspace="cd ~/workspace"
alias serve="php artisan serve"