Skip to content

Instantly share code, notes, and snippets.

View jstepien's full-sized avatar
↗️
elsewhere

Jan Stępień jstepien

↗️
elsewhere
View GitHub Profile
@jstepien
jstepien / pwwifi.sh
Created March 29, 2010 08:34
An automatic authentication for pwwifi's Cisco access points.
#!/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 April 25, 2010 19:14
A LaTeX file for extracting slides from handouts
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 July 2, 2010 09:09
A script creating a static dump of a Trac instance
#!/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 October 7, 2010 19:32
Prints file's history ready for inclusion in LaTeX documents
#!/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 November 11, 2010 14:42
An M4 macro checking for given gems. Example: AX_CHECK_GEMS([rspec simplecov])
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 April 7, 2011 18:47
A recursive approach to the Cartesian product
# 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|
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 16:16
[PATCH] Don't assume that llvm-config is a Perl script
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 March 6, 2017 11:21
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 February 5, 2018 10:32
That looks oddly familiar
[package]
name = "phash"
version = "0.1.0"
authors = ["Jan Stępień"]
[dependencies]
libc = "0.2.36"
rayon = "0.9.0"