Skip to content

Instantly share code, notes, and snippets.

View xkr47's full-sized avatar

Jonas Berlin xkr47

View GitHub Profile
@xkr47
xkr47 / jolla-usb-power-states.sh
Last active August 29, 2015 14:23
Jolla phone: Different usb power states
# NOTE: In order to change state, you need to run all three commands for the wanted state
# in given order to get the desired effect
# Charge battery, and use usb power to power phone (default state after powering up the phone)
chmod u+w /sys/class/power_supply/usb/charger_disable
echo 0 > /sys/module/pm8921_charger/parameters/disabled
echo 0 > /sys/class/power_supply/usb/charger_disable
# don't charge battery, but use usb power to power phone
chmod u+w /sys/class/power_supply/usb/charger_disable
@xkr47
xkr47 / myapp.cpp
Last active August 29, 2015 14:23 — forked from kimmoli/myclass.cpp
Disable SailfishOS app cover animation when cover is not visible
...
#include "myclass.h"
...
int main(int argc, char *argv[])
{
qmlRegisterType<myclass>("harbour.myapp.myclass", 1, 0, "myclass");
...
}
@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 / xkr-clipboard.pl
Created October 6, 2015 11:45
rxvt-unicode: Enable Ctrl-Insert/Ctrl-Shift-c to copy to CLIPBOARD (as opposed to PRIMARY) selection. Pasting works by Meta-<middle button>
#! perl
# Store this file as /usr/lib/urxvt/perl/xkr-clipboard
#
# To enable, add to ~/.Xresources:
#
# URxvt.perl-ext-common: default,xkr-clipboard
# URxvt.iso14755: false
# URxvt.keysym.Shift-Control-C: perl:clipboard:copy
# URxvt.keysym.Control-Insert: perl:clipboard:copy
@xkr47
xkr47 / twitter.css
Last active September 6, 2019 04:16
My css tweaks for Twitter - install using e.g. Stylish addon for Firefox (https://addons.mozilla.org/en-US/firefox/addon/stylish/)
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("twitter.com") {
.stream-item .promoted-tweet {
background: #ff9080;
}
/* you might like / in case you missed */
.stream-item.has-recap, .stream-item.has-recap .stream-item {
background: #ccffdd;
@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 / letsencrypt-jetty.sh
Last active August 29, 2023 07:22
How to use Letsencrypt certificate & private key with Jetty
# input: fullchain.pem and privkey.pem as generated by the "letsencrypt-auto" script when run with
# the "auth" aka "certonly" subcommand
# convert certificate chain + private key to the PKCS#12 file format
openssl pkcs12 -export -out keystore.pkcs12 -in fullchain.pem -inkey privkey.pem
# convert PKCS#12 file into Java keystore format
keytool -importkeystore -srckeystore keystore.pkcs12 -srcstoretype PKCS12 -destkeystore keystore.jks
# don't need the PKCS#12 file anymore
@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
}