Skip to content

Instantly share code, notes, and snippets.

View jsarenik's full-sized avatar

Ján Sáreník jsarenik

View GitHub Profile
@jsarenik
jsarenik / swap.c
Created July 14, 2016 12:40
Change endianess (e.g. 01101 to 10110 bit-wise)
#include <stdio.h>
unsigned int reverse(unsigned char b) {
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
return b;
}
int
@jsarenik
jsarenik / GNU_Social
Created June 14, 2016 13:00
[SDF] let SDF help GNU!
Date: Sun, 14 Feb 2016 09:53:21 GMT
From: membership@sdf.org
Subject: [SDF] let SDF help GNU!
Want to take back the internet?
No, wait a second. I'm serious. Do you remember a thing called USENET? Do
you remember how cool it was when you posted something and someone at
hawaii.edu or telebit.com responded? GNU Social is reviving this idea. Much
of the internet for the general public these days is not only just focused
on http/https but a key number of central sites. When SDF was (uh, it still
@jsarenik
jsarenik / busyroot.sh
Last active October 29, 2019 17:33
chroot hack
#!/bin/sh
CHROOT=${1:-"myroot"}
ARCH=${2:-"armv5l"}
test -n "$UNSHARE" || {
export UNSHARE="unshare --fork --pid --mount"
exec $UNSHARE $0 $CHROOT
}
@jsarenik
jsarenik / check.sh
Last active January 27, 2016 07:22
IPv6
#!/bin/sh
#
# https://tunnelbroker.net/tunnel_detail.php?tid=$TID
TID=1234567
HEUSER=login
HEPASS=Update_Key_from_Tunnel_Details/Advanced
CHECK_DNS=you.dns.he.dynamically.updated.domain
URL="https://$HEUSER:$HEPASS@ipv4.tunnelbroker.net/nic/update?hostname=$TID"
@jsarenik
jsarenik / git-delmerged.sh
Created December 15, 2015 11:02
Script that deletes all git branches that were already merged to current one
#!/bin/sh
git branch --merged | grep -v "^\*\|master" | xargs -r -n 1 git branch -d
@jsarenik
jsarenik / isohybrid.pl
Created November 15, 2015 14:37
isohybrid.pl from Syslinux-6.03
#!/usr/bin/perl
## -----------------------------------------------------------------------
##
## Copyright 2002-2008 H. Peter Anvin - All Rights Reserved
## Copyright 2009 Intel Corporation; author: H. Peter Anvin
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
## Boston MA 02111-1307, USA; either version 2 of the License, or
#!/bin/bash
ifthere() {
for cmd in "$@"
do
type ${cmd%% *} >/dev/null 2>&1 && { $cmd || continue; return $?; }
done
}
usage() {
@jsarenik
jsarenik / init
Last active March 9, 2017 09:07
init.sh
#!/bin/sh
. /etc/tinitrc
HOSTNAME=$(cat /etc/hostname)
DOMAIN=$(cat /etc/dnsdomainname)
FQDN=$HOSTNAME.$DOMAIN
NETCONF=/etc/network/interfaces
IPV4=$(cat $NETCONF | sed -n 's/.*address //p')
IPV6=$(grep "up ifconfig venet0 add" $NETCONF | sed 's/^.*add //')
@jsarenik
jsarenik / rconf.sh
Created September 1, 2015 22:30
Read file omitting # comments
#!/bin/sh
for i in $*
do
grep -v '^#' $i | sed '/^$/d'
done
@jsarenik
jsarenik / keyboard.sh
Created June 17, 2015 07:45
X Window script to set up keyboard.
#!/bin/sh
setxkbmap ${1:-'dvorak'}
setxkbmap -option ""
xmodmap - <<EOF
! for help, see $ xmodmap -grammar
!in /etc/X11/xorg.conf.d/20-keyboard.conf
! or by running setxkbmap -option "ctrl:nocaps"