Skip to content

Instantly share code, notes, and snippets.

Avatar

Jan Stępień jstepien

View GitHub Profile
@jstepien
jstepien / pwwifi.sh
Created Mar 29, 2010
An automatic authentication for pwwifi's Cisco access points.
View pwwifi.sh
#!/bin/sh
die() {
echo "Fail" 1>&2
exit 1
}
user=123456
pass=allyourbasearebelongtous
url="https://1.1.1.1/login.html?buttonClicked=4&err_flag=0&err_msg=&info_flag=0&info_msg=&password=$pass&redirect_url=&username=$user"
@jstepien
jstepien / slides.tex
Created Apr 25, 2010
A LaTeX file for extracting slides from handouts
View slides.tex
n=9;for i in `seq $n`; do pages=$(identify wyklad$i.pdf | tail -n 1 | perl -ne '/^wyklad.*?\[(\d+)/; $_ = $1+1; print'); sed -e s/wyklad1/wyklad$i/g -e s/23/$pages/ < slides.tex > slides$i.tex; done
@jstepien
jstepien / trac_dump.sh
Created Jul 2, 2010
A script creating a static dump of a Trac instance
View trac_dump.sh
#!/bin/sh
src=/path/to/trac
dst=$src.tmp
port=54134
target=$dst/localhost\:$port
pidfile=$dst/pid
set -x
@jstepien
jstepien / print_file_versions.pl
Created Oct 7, 2010
Prints file's history ready for inclusion in LaTeX documents
View print_file_versions.pl
#!/usr/bin/env perl
use warnings;
use strict;
use Git;
use File::Basename;
use Date::Parse;
use Date::Format;
# States
@jstepien
jstepien / ax_check_gems.m4
Created Nov 11, 2010
An M4 macro checking for given gems. Example: AX_CHECK_GEMS([rspec simplecov])
View ax_check_gems.m4
AC_DEFUN([AX_CHECK_GEMS],[
AC_MSG_CHECKING([whether we've got all required gems])
result=`$RUBY -e '
ARGV.each { |f| begin; require f; rescue LoadError; puts(f); exit 1; end }
' $1 2>&1`
if test x = "x$result"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([cannot find $result])
@jstepien
jstepien / cartesian.rb
Created Apr 7, 2011
A recursive approach to the Cartesian product
View cartesian.rb
# irb(main):001:0> cartprod [[:a, :b], (1..3), [true, false]]
# => [[:a, 1, true], [:a, 1, false], [:a, 2, true], [:a, 2, false],
# [:a, 3, true], [:a, 3, false], [:b, 1, true], [:b, 1, false],
# [:b, 2, true], [:b, 2, false], [:b, 3, true], [:b, 3, false]]
def cartprod(colls)
if colls.empty?
[[]]
else
rest_cartprod = cartprod colls[1..-1]
colls[0].reduce [] do |all, x|
View Makefile
CFLAGS = $(shell pkg-config --cflags mozjs185) -O2 -Wall
LDFLAGS = -Wl,--as-needed -Wl,-O1
LDLIBS = $(shell pkg-config --libs mozjs185)
all: parse
parse: parse.o
parse.o: parse.c date.js.h
date.js.h: date.js
( \
echo 'const char *code =' ; \
@jstepien
jstepien / 0001-Don-t-assume-that-llvm-config-is-a-Perl-script.patch
Created May 3, 2012
[PATCH] Don't assume that llvm-config is a Perl script
View 0001-Don-t-assume-that-llvm-config-is-a-Perl-script.patch
As of the upcoming LLVM 3.1 release llvm-config has been rewritten as a
native executable [1]. Executing it with Perl causes the configure script
to fail with a message
Unrecognized character \x7F; marked by <-- HERE after
<-- HERE near column 1 at llvm-config line 1.
This commit makes llvm-config to be invoked directly. As a result it works
correctly with LLVM 3.0 and fails with a more friendly error message when
encountering LLVM 3.1svn.
@jstepien
jstepien / reduce-and-gc.clj
Last active Mar 6, 2017
reduce-and-gc.clj
View reduce-and-gc.clj
;; Let's experiment with Clojure 1.8.0 running with a relatively small heap
;; of 10MB. To avoid any extra dependencies, we'll start it as follows:
;;
;; java -Xmx10m -jar clojure-1.8.0.jar
;;
;; Copy following expressions into your REPL one by one.
;;
;; Let's take a small number, for instance one million.
(def small-num (* 1000 1000))
@jstepien
jstepien / Cargo.toml
Created Feb 5, 2018
That looks oddly familiar
View Cargo.toml
[package]
name = "phash"
version = "0.1.0"
authors = ["Jan Stępień"]
[dependencies]
libc = "0.2.36"
rayon = "0.9.0"