Skip to content

Instantly share code, notes, and snippets.

View matthiasg's full-sized avatar

matthiasg matthiasg

View GitHub Profile
@matthiasg
matthiasg / gist:b0e1511e6db140119cdf24ddc1743c0b
Created December 4, 2017 07:15 — forked from dalethedeveloper/gist:1503252
Mobile Device Detection via User Agent RegEx

#Mobile Device Detection via User Agent RegEx

Yes, it is nearly 2012 and this exercise has been done to death in every imaginable language. For my own purposes I needed to get the majority of non-desktop devices on to a trimmed down, mobile optimized version of a site. I decided to try and chase down an up-to-date RegEx of the simplest thing that could possibly work.

I arrived at my current solution after analyzing 12 months of traffic over 30+ US based entertainment properties (5.8M+ visitors) from Jan - Dec 2011.

The numbers solidified my thoughts on the irrelevancy of including browsers/OSes such as Nokia, Samsung, Maemo, Symbian, Ipaq, Avant, Zino, Bolt, Iris, etc. The brass tacks of the matter is that you certainly could support these obscure beasts, but are you really going to test your site on them? Heck, could you even find one?! Unless the folks that pay you are die hard Treo users my guess is "No".

Interestingly enough my research shows that /Mobile/ is more efficient than **/iP(

@matthiasg
matthiasg / docker-compose.builder.yml
Created January 22, 2019 09:11
docker-compose.yml for windows node development
version: '2'
volumes:
node_modules:
services:
base:
image: node:10
volumes:
- .:/usr/src/service
@matthiasg
matthiasg / gist:3cefcb5e6d51ba66995e3011b0175a32
Created February 25, 2019 15:50 — forked from xen0l/gist:732fb7a6bb50ffbf0ba9
How to make QEMU guest-agent work on SmartOS
[root@smartos ~]# UUID="afe2f552-4a35-4c44-8855-a9bac10f27d2"
[root@smartos ~]# vmadm update ${UUID} qemu_extra_opts="-chardev socket,path=/tmp/vm.qga,server,nowait,id=qga0 -device virtio-serial -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0"
Successfully updated VM afe2f552-4a35-4c44-8855-a9bac10f27d2
[root@smartos ~]# vmadm boot ${UUID}
Successfully started VM afe2f552-4a35-4c44-8855-a9bac10f27d2
[root@smartos ~]# sleep 60 # Machine needs to boot up
[root@smartos ~]# echo '{"execute": "guest-ping" }' | socat stdio unix-connect:/zones/${UUID}/root/tmp/vm.qga # Is GA alive?
{"return": {}}
[root@smartos ~]# echo '{"execute": "guest-info" }' | socat stdio unix-connect:/zones/${UUID}/root/tmp/vm.qga # show information about GA
{"return": {"version": "0.12.1", "supported_commands": [{"enabled": true, "name": "guest-set-vcpus"}, {"enabled": true, "name": "guest-get-vcpus"}, {"enabled": true, "name": "guest-network-get-interfaces"}, {"enabled": true, "name": "guest-suspend-hybrid"}, {"enabled": tru
@matthiasg
matthiasg / sha256.js
Created March 13, 2019 07:15
SHA256
// From: https://github.com/Hartland/GPL-CPU-Miner/blob/master/sha2.c
if ("undefined" == typeof vnet) {
vnet = new Array();
}
if ("undefined" == typeof vnet.crypt) {
vnet.crypt = new Array();
}
@matthiasg
matthiasg / playground.rs
Last active March 21, 2019 10:42 — forked from rust-play/playground.rs
Code shared from the Rust Playground
struct MyType {
value: u32
}
impl MyType {
fn new() -> MyType {
MyType {
value: 1
}
}
@matthiasg
matthiasg / keybase.md
Created April 16, 2019 07:55
keybase

Keybase proof

I hereby claim:

  • I am matthiasg on github.
  • I am matthiasg (https://keybase.io/matthiasg) on keybase.
  • I have a public key ASCFZyamXEDIBolEyLgrbvdB36vrCF5jFywJG0tmR1hdCAo

To claim this, I am signing this object:

@matthiasg
matthiasg / insert-signature-in-pdf.md
Created August 3, 2019 14:14 — forked from chrpinedo/insert-signature-in-pdf.md
How to insert your signature in a PDF file by using PDFtk

How to insert your signature in a PDF file by using PDFtk

Your signature in all the sheets

  1. convert the signature image to PDF file
convert firma.png firma.pdf
@matthiasg
matthiasg / insert-signature-in-pdf.md
Created August 3, 2019 14:14 — forked from chrpinedo/insert-signature-in-pdf.md
How to insert your signature in a PDF file by using PDFtk

How to insert your signature in a PDF file by using PDFtk

Your signature in all the sheets

  1. convert the signature image to PDF file
convert firma.png firma.pdf
@matthiasg
matthiasg / small-arc.sh
Created August 15, 2019 12:21 — forked from RantyDave/small-arc.sh
Limit the SmartOS (and Solaris?) ARC to a maximum of 256Mb. Works live, no reboot needed :)
#!/bin/bash
echo "arc_stats::print -a arcstat_p.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw
echo "arc_stats::print -a arcstat_c.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw
echo "arc_stats::print -a arcstat_c_max.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw
@matthiasg
matthiasg / small-arc.sh
Created August 15, 2019 12:21 — forked from RantyDave/small-arc.sh
Limit the SmartOS (and Solaris?) ARC to a maximum of 256Mb. Works live, no reboot needed :)
#!/bin/bash
echo "arc_stats::print -a arcstat_p.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw
echo "arc_stats::print -a arcstat_c.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw
echo "arc_stats::print -a arcstat_c_max.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw