Skip to content

Instantly share code, notes, and snippets.

@NoUsername
NoUsername / websocket_loadtester.js
Created January 16, 2013 07:32
a simple load tester for websocket server which connects a desired number of clients, sends "client _RANDOM_UNIQUE_ID_" and then in a given interval "ping _RANDOM_NUMBER_" prints out any messages sent by the server
#!/usr/bin/env node
// to run install: nodejs and the module "websocket"
// npm install websocket
// then execute
// node tester.js _NUMBER_OF_CLIENTS_
var WebSocketClient = require('websocket').client;
var HOST = 'ws://localhost:8449/ws/endpoint';
var PING_TIME_MS = 20000;
from multiprocessing import Process, Queue
from Queue import Empty
MAX_MSG = 200000
NUM_PROC = 10
def startProducer(queue, out, max):
import time, random
time.sleep(2)
for i in range(max):
@NoUsername
NoUsername / imageViewer.html
Created March 2, 2014 15:38
Simple image viewer, which loads all images from an html directory listing.
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<img id="viewer" src="" width="800px"/>
<div id="info"> </div>
<script>
$(function() {
@NoUsername
NoUsername / speedCap
Created March 23, 2014 14:43
helper script for setting speed limit in openwrt via wshaper
#!/bin/sh
speed=4000
if [ $# -gt 0 ]; then
speed=$1
fi
printf "setting speed to $speed\n"
uci set wshaper.settings.downlink=$speed
uci commit
/etc/init.d/wshaper restart
@NoUsername
NoUsername / raspberryPiCheatSheet
Last active August 29, 2015 14:01
Raspberry-Pi cheat sheet
# disabling raspbmc firewall the dirty way:
# from http://raspberrypi.stackexchange.com/questions/5334/how-can-i-disable-raspbmcs-firewall-via-ssh
# in /etc/network/if-up.d/secure-rmc replace:
iptables -A INPUT -s $NETMASK -i $IFACE -j ACCEPT
iptables -A INPUT -i $IFACE -j DROP
# with
iptables -A INPUT -i $IFACE -j ACCEPT
# fixing a broken sd card
@NoUsername
NoUsername / i3-custom-config
Last active August 29, 2015 14:12
custom configuration for the i3 window manager (to be appended to default config file in ~/.i3/config )
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout somewhen, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
@NoUsername
NoUsername / .Xdefaults
Created January 3, 2015 17:35
.Xdefaults config file
URxvt*transparent: true
URxvt*tintColor: #222222
URxvt*shading: 80
URxvt*saveLines: 12000
URxvt*foreground: White
URxvt*background: #000000
#URxvt*font: xft:Bitstream Vera Sans Mono:pixelsize=12:antialias=true:hinting=true
#URxvt*boldFont: xft:Bitstream Vera Sans Mono:bold:pixelsize=12:antialias=true:hinting=true
URxvt*font: xft:DejaVu Sans Mono:pixelsize=12:antialias=true:hinting=true
URxvt*boldFont: xft:DejaVu Sans Mono:bold:pixelsize=12:antialias=true:hinting=true
@NoUsername
NoUsername / 15_windows
Created January 3, 2015 19:17
GRUB2 boot file for windows (by exiting grub)
#!/bin/sh -e
echo "Adding Windows to GRUB 2 menu"
cat << EOF
menuentry "Windows" {
exit
}
EOF
## to activate this run:
## sudo grub-mkconfig -o /boot/grub/grub.cfg
@NoUsername
NoUsername / usbreset.c
Created February 4, 2015 20:56
Usb reset utility
// copy of https://github.com/leonarf/radioRaspberry/blob/master/src/resetLibusb.c
#include <stdio.h>
#include <stdlib.h>
#include <libusb-1.0/libusb.h>
//compile: gcc usbreset.c -o usbreset -lusb-1.0
//usage: ./usbreset 2 6
//use lsusb to check out the bus number and device number
struct libusb_device_handle *devh;
@NoUsername
NoUsername / syslog
Created March 7, 2015 16:51
syslog part of lenovo suspend issue
Mar 7 17:48:51 paulbook3 kernel: [ 7192.099016] tpm_tis 00:04: Error (28) sending savestate before suspend
Mar 7 17:48:51 paulbook3 kernel: [ 7192.099023] __pnp_bus_suspend(): tpm_pm_suspend+0x0/0x1b0 returns 28
Mar 7 17:48:51 paulbook3 kernel: [ 7192.099025] dpm_run_callback(): pnp_bus_suspend+0x0/0x20 returns 28
Mar 7 17:48:51 paulbook3 kernel: [ 7192.099028] PM: Device 00:04 failed to suspend: error 28
Mar 7 17:48:51 paulbook3 kernel: [ 7192.099030] PM: Some devices failed to suspend, or early wake event detected
Mar 7 17:48:51 paulbook3 kernel: [ 7192.104247] sd 0:0:0:0: [sda] Starting disk