Skip to content

Instantly share code, notes, and snippets.

@aktau
aktau / mysql.sh
Last active June 22, 2022 14:01
Handy mysql commands and tips
#!/bin/sh
set -e
set -u
# I'm just getting acquainted with mysql so cut me some slack ;)
## check the size of the db
# source: http://stackoverflow.com/questions/1733507/how-to-get-size-of-mysql-database
# per schema
@aktau
aktau / udev-tty.pl
Created May 24, 2013 17:28
Perl script to assign TTY's to specific links
#!/usr/bin/perl
# udev rules:
# =====================
# kernel=="ttyUSB*", ATTRS{bNumConfigurations}=="*", PROGRAM="/etc/prysm/create_usb_symlink.pl %p %s{idVendor} %s{idProduct}", SYMLINK="%c"
# kernel=="ttyACM*", ATTRS{bNumConfigurations}=="*", PROGRAM="/etc/prysm/create_usb_symlink.pl %p %s{idVendor} %s{idProduct}", SYMLINK="%c"
# =====================
package links::3G;
use Sys::Syslog qw(:standard :macros);
@aktau
aktau / array-loop-assign-microbenchmark.php
Created May 25, 2013 11:47
Microbenchmakring some php loops for a tiny ORM I'm making...
<?php
/**
* microbenchmarking is great fun!
*/
function blank_copy($a) {}
function blank_ref(&$a) {}
function foreach_copy($a) {
@aktau
aktau / git.sh
Created June 6, 2013 14:03
build system
git clean -fxdq
git fetch --all # fetch everything from mirror
git reset --hard origin/$version # this works for branches...
git reset --hard $version # this works for tags...
@aktau
aktau / callback.js
Created June 11, 2013 21:15
callback on the stack forever?
// my code in some.js
var i;
someAsyncFunction(arg, function myCallback(results) {
// the rest of my program flow
// basically someAsyncFunction is STILL on the stack...
});
@aktau
aktau / bindmp
Created July 15, 2013 23:27
bin dump
7b2274656d706c617465223a223c7461626c652069643d5c2274656d706c6174655c222063656c6c73706163696e673d5c22305c222063656c6c70616464696e673d5c22305c22207374796c653d5c2277696474683a20313030253b206865696768743a20313030253b5c223e3c74723e3c746420636c6173733d5c2263616e7661735c2220646174612d706c61796c6973742d69643d5c223331345c22207374796c653d5c2277696474683a20313030253b206865696768743a20313030253b5c223e3c5c2f74643e3c5c2f74723e3c5c2f7461626c653e222c2273686f77735f70726f636573736564223a302c22706c61796c69737473223a7b22333134223a7b226e616d65223a22313331352047656572646567656d205661617274202d2070726573222c226974656d73223a7b223138353839223a7b2274797065223a226d65646961222c2266696c6574797065223a22766964656f222c2266696c656e616d65223a2264656d6f5c2f424d472053616c657320547261696c65725f51542e6f6776222c226475726174696f6e223a32302e3034303030303931353532372c227769647468223a313932302c22686569676874223a313038302c226d74696d65223a313337333032383634382c226964223a31383538392c226974656d5f6964223a31373938322c227072696f72697479223a32382c226d6435223a
@aktau
aktau / it.scpt
Created July 27, 2013 15:05
launch iTerm with applescript
on run argv
-- launch "iTerm"
tell application "iTerm"
activate
tell the first terminal
launch session "cmd-session"
tell the last session to write text (item 1 of argv)
end tell
end tell
@aktau
aktau / avg.scala
Created July 29, 2013 08:38
benchmark averaging methods
def movingRunningApprox(window: Int, l: Seq[Int]) = {
val N = window
val seedrun = l.take(N)
var avg = seedrun.sum / seedrun.length
println(l)
val xs = l map { el =>
val (pre,dec,inc) = (avg,avg/N,el/N)
avg = avg - avg/N + el/N
@aktau
aktau / frame.c
Created July 31, 2013 00:11
OpenGL: frame processing time
static void diagFrameDone(SDL_Window *window) {
char title[1024];
/* processing time per frame */
static int counter = 0;
static int min = 0, max = 0, avg = 0;
static int elapsed = 0, totalElapsed = 0;
static int last = 0;
@aktau
aktau / cygwin-sshd-gui.md
Last active July 14, 2020 03:45
Short description of how to run an sshd under cygwin that can run gui programs, even under windows 7

The key point is that we're not going to run sshd as a service via cygrunsrv or anything, but that we're going to start it directly as the desktop user.

  1. install cygwin (the x86 version currently has more packages, such as zsh. oh-my-zsh works by the way)
  2. install ssh and if you like some helper programs (git, mc, wget, curl, nano, vim, rsync, zsh, ...)
  3. start cygwin, I don't believe it is necessary to run as administrator with my method, but I guess it can't hurt
  4. execute the same script as a normal sshd setup:
$ ssh-host-config