Skip to content

Instantly share code, notes, and snippets.

View pid's full-sized avatar

Sascha pid

  • Baden-Württemberg, Germany
View GitHub Profile

REST Ideology & Rants

I am getting frustrated by the number of people calling any HTTP-based interface a REST API. Today’s example is the SocialSite REST API. That is RPC. It screams RPC. There is so much coupling on display that it should be given an X rating.

REST APIs must be hypertext-driven


Roy Fielding writes a PhD dissertation describing the architectural style of the World Wide Web. He coins the term ‘Representational State Transfer’ (REST) to describe it – after all, if you’re going to talk about something, you need to give it a name. Somehow, in a semantic shift of epic fail proportions, the term REST has also come to mean something completely different to most people, a ‘style’ of writing web services. This style has no agreed protocol.

@pid
pid / jsaes.js
Created June 14, 2013 19:25
This is a javascript implementation of the AES block cipher. Key lengths of 128, 192 and 256 bits are supported. http://point-at-infinity.org/jsaes/
/*
* jsaes version 0.1 - Copyright 2006 B. Poettering
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@pid
pid / keystroke-toggle-linenumbers-settings.json
Created October 21, 2013 20:17
Sublime Text keystroke toggle line numbers show/hide
{
"keys": ["ctrl+alt+l"],
"command": "toggle_setting",
"args": {
"setting": "line_numbers"
}
@pid
pid / create-bootable-tails-usb-stick
Last active June 8, 2021 05:37
CREATE BOOTABLE TAILS USB-STICK https://tails.boum.org/ (OSX) Tails is a live operating system, that you can start on almost any computer from a DVD, USB stick, or SD card. It aims at preserving your privacy and anonymity, and helps you to: use the Internet anonymously and circumvent censorship; Alle Internet-Verbindungen werden zwingend durch d…
#!/usr/bin/env bash
###########################################################
# create bootable tails usb-stick https://tails.boum.org/ #
# !!! Read the comments !!! CHANGE <diskN> placeholder #
###########################################################
# get iso
wget http://dl.amnesia.boum.org/tails/stable/tails-i386-0.21/tails-i386-0.21.iso
jQuery.fn.brightness = function() {
var bg_color, rgba, y;
bg_color = this.css('background-color');
if ((bg_color != null) && bg_color.length) {
rgba = bg_color.match(/^rgb(?:a)?\(([0-9]{1,3}),\s([0-9]{1,3}),\s([0-9]{1,3})(?:,\s)?([0-9]{1,3})?\)$/);
if (rgba != null) {
if (rgba[4] === '0') {
if (this.parent().length) return this.parent().brightness();
} else {
y = 2.99 * rgba[1] + 5.87 * rgba[2] + 1.14 * rgba[3];

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

Welcome!

For feedback or suggestions, please send a tweet (@dideler). Gist comments don't notify me. Pull requests aren't possible with gists (yet), so I don't recommend forking because then I can't easily get the change.

Starring this gist will give me an idea of how many people consider this list useful.


  • OpenStrategy - kinda like this list, but much nicer presentation
@pid
pid / gist:6119939
Created July 31, 2013 07:08
Firewall iptables config example securing access to mongodb
iptables -N MongoDB
iptables -I INPUT -s 0/0 -p tcp --dport 27017 -j MongoDB
iptables -I INPUT -s 0/0 -p tcp --dport 28017 -j MongoDB
iptables -I MongoDB -s 127.0.0.1 -j ACCEPT
iptables -I MongoDB -s 10.0.0.1 -j ACCEPT
iptables -I MongoDB -s 10.0.0.2 -j ACCEPT
iptables -I MongoDB -s 10.0.0.3 -j ACCEPT
iptables -A MongoDB -s 0/0 -j DROP
/etc/init.d/iptables save
module KellyColors exposing (..)
import Color exposing (..)
import Maybe exposing (..)
import List.Extra as List exposing (..)
type alias KellyDef =
{ isccNbsNr : Int, hexString : String, r : Int, g : Int, b : Int }
@pid
pid / gist:6039252
Created July 19, 2013 13:53
generate slug / speaking url node.js or browser
// http://pid.github.io/speakingurl/
var slug;
var options = {
maintainCase: true,
separator: '_'
};
var mySlug = require('speakingurl').createSlug(options);
slug = mySlug("Bel été !");
console.log(slug); // Output: Bel_ete