Skip to content

Instantly share code, notes, and snippets.

View xkr47's full-sized avatar

Jonas Berlin xkr47

View GitHub Profile
@xkr47
xkr47 / virtualbox-reset.sh
Created September 21, 2015 12:56
virtualbox 5.0 installation hard-reset @ ubuntu 15.04
apt-get purge virtualbox-5.0
dpkg -i virtualbox-5.0_5.0.0-101573~Ubuntu~trusty_amd64.deb
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.0.0.vbox-extpack
@xkr47
xkr47 / flowdock-new.css
Created December 12, 2012 12:20 — forked from anonymous/flowdock-new.css
New flowdock line-compress css for use with "Stylish" plugin in Firefox, v2
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("flowdock.com") {
.chat-message, .comment-message, .action-message, .line-message, .status-message, .file-message, .error-message {
padding-top: 0 !important;
padding-bottom: 0 !important;
font-family: Ubuntu,Tahoma,sans-serif !important;
font-size: 10px !important;
}
}
@xkr47
xkr47 / x2-stats-text.pl
Last active November 4, 2015 07:46
My xmms2 read-only terminal "gui"
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
sub nonEmptyString($) {
my ($str) = @_;
return defined($str) && length($str);
@xkr47
xkr47 / precedence1.ceylon
Last active December 3, 2015 15:04
Ceylon Web Runner: ceylon precedence fun
//$webrun_wrapped
shared void run() {
value cn = "foo.bar";
print(cn[(cn.lastIndexWhere((Character ch) => ch == '.') else 0) ...]);
// vs
print(cn[(cn.lastIndexWhere((Character ch) => ch == '.') else 0)+1 ...]);
// vs
print(cn[ cn.lastIndexWhere((Character ch) => ch == '.') else 0 ...]);
@xkr47
xkr47 / hexdump.ceylon
Created December 6, 2015 07:42
Simple singleline hexdumper
void hexdump(String s) {
value hexes = { for (ch in s) let (x = "_____" + formatInteger(ch.integer, 16)) x[x.size - 5 ...] };
log.debug(hexes.fold("")((x,y) => x + y + " ")+ s);
}
@xkr47
xkr47 / autoShutdownPrevious.ceylon
Last active December 7, 2015 10:07
Automatically shut down previously running app instance on startup
import ceylon.file {
Path,
Nil,
File,
createFileIfNil,
parsePath
}
import ceylon.logging {
Logger
}
@xkr47
xkr47 / diff_-u_colors
Last active December 12, 2015 05:29
Colorify "diff -u" output
#!/usr/bin/perl
use File::Temp qw/ :mktemp /;
my @params = grep(/^-/,@ARGV);
@ARGV = grep(!/^-/,@ARGV);
my $tmp = $ENV{"TMP"};
$tmp = "/tmp" unless(defined($tmp));
($tmpfh, $tmpfile) = mkstemp($tmp."/diff_u.XXXXXX");
@xkr47
xkr47 / jolla-two-way-internet-sharing.md
Last active December 16, 2015 05:16
Two-way internet sharing with Jolla/sailfishos

Figure 1

In "internet sharing" mode

  • as-is implemented now, no changes needed
  • phone has static ip configuraton for usb network interface
  • phone runs udhcpd, which
    • provides gateway & dns info as made available by e.g. cellular internet connection
  • pc runs dhcp client, gets ip, gateway & dns info from phone
@xkr47
xkr47 / keyboard-font-zooming.el
Created December 18, 2015 09:54
Emacs keybindings for zooming font size
; For finnish keyboard layout. Uses Ctrl + the two keys to the right of non-numpad number key "0"
(define-key global-map [?\C-+] 'text-scale-increase)
(define-key global-map [?\C-'] 'text-scale-decrease)
@xkr47
xkr47 / PPFConfig.xml
Created June 17, 2013 11:29
snippet for configuring PPF 1.0.0 and newer to use UTF-8 for output and input, falling back to some other charset if utf-8 decoding fails
<botConfig>
<irc-settings>
<encoding>utf-8</encoding>
<fallbackEncoding>iso-8859-15</fallbackEncoding>