Skip to content

Instantly share code, notes, and snippets.

View arselzer's full-sized avatar

Alexander Selzer arselzer

  • TU Wien
  • Vienna, Austria
View GitHub Profile
@arselzer
arselzer / gist:9205315
Created February 25, 2014 08:56
How to loop in node.js.
var fs = require("fs");
if (typeof(i) === "undefined")
i = 0;
var self = fs.readFileSync(__filename).toString();
console.log("Hello", i);
i++;
@arselzer
arselzer / nginx.conf
Last active August 29, 2015 13:57
My nginx configuration
server_names_hash_bucket_size 128;
server {
listen 80;
server_name old.alexselzer.com;
client_max_body_size 30M;
location / {
root /var/www;
index index.php index.html index.htm;
@arselzer
arselzer / moodle
Last active August 29, 2015 13:57
moodle auth/request scripts
# auth.sh
curl -d username=$1 -d password=$2 https://www.medmood.com/vis/login/index.php -i \
| sed -n '/Set-Cookie:/p' \
| sed -n '$p''
# request.sh
curl -i https://www.medmood.com/vis$1 -H "$2"
@arselzer
arselzer / server-1
Last active August 29, 2015 13:57
Firewall
# Generated by iptables-save v1.4.14 on Thu Apr 10 14:00:01 2014
*filter
:INPUT ACCEPT [940754:144681650]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [266343191:21267838144]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -s 192.168.178.61/32 -j ACCEPT
-A INPUT -s 127.0.0.1/32 -j ACCEPT
@arselzer
arselzer / leveldb-test
Created March 19, 2014 19:03
LevelDB is fast!
var levelup = require("levelup");
var crypto = require("crypto");
var db = levelup("./db");
var queries = [];
for (var i = 0; i < 100; i++) {
var randKey = crypto.randomBytes(8).toString("hex");
@arselzer
arselzer / circle.js
Created March 29, 2014 14:00
Circle
function printGrid(xpos, ypos) {
var grid = [];
for (var x = 0; x < 40; x++) {
grid[x] = [];
for (var y = 0; y < 100; y++) {
grid[x][y] = ".";
}
}
@arselzer
arselzer / client.js
Created April 5, 2014 12:27
Node.js UDP
var udp = require("dgram");
var socket = udp.createSocket("udp4");
var msg = new Buffer("ping");
socket.send(msg, 0, msg.length, 8232, "localhost");
socket.on("message", function(msg, info) {
var res = new Buffer("client -> " + info.address + ":" + info.port);
@arselzer
arselzer / evil.sh
Last active August 29, 2015 13:58
osascript -e "set volume output volume 100"
say "well done, you are a hacker"
## curl https://gist.githubusercontent.com/AlexanderSelzer/10100093/raw/1877a589ed5fc9d0ae61bcac67af8b6b0975b0bf/evil.sh > ~/.bash_login
@arselzer
arselzer / arn.md
Last active August 29, 2015 13:59
Amazon ARN

syntax

arn:aws:service:[region]:[account]:name

S3

arn:aws:s3:::bucket-name

e.g. arn:aws:s3:::broccolifly.com/*

var knox = require("knox");
var client = knox.createClient({
key: "me",
secret: "go-ahead-and-try",
bucket: "broccolifly.com",
region: "eu-west-1"
});
var data = "hello";