Skip to content

Instantly share code, notes, and snippets.

View matthiasg's full-sized avatar

matthiasg matthiasg

View GitHub Profile
@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: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(

{
"main": "dist/allServicesWrappedByOneService.umd.min.js",
"exports": "service"
}
@matthiasg
matthiasg / TestPattern.cpp
Created July 21, 2017 14:38 — forked from roxlu/TestPattern.cpp
Example usage of X264. We create a raw YUV pattern and encode it with x264.
#include <cmath>
#include <assert.h>
#include <core/TestPattern.h>
TestPattern::TestPattern()
:w(0)
,h(0)
,frame_num(0)
,duration(0)
@matthiasg
matthiasg / chrome_170421_092716.dmp
Last active June 1, 2019 04:15
Hung Chrome.exe Process (windbg)
This file has been truncated, but you can view the full file.
@matthiasg
matthiasg / _decimal.scss
Created March 25, 2017 14:48 — forked from terkel/_decimal.scss
Rounding decimals in Sass
// _decimal.scss | MIT License | gist.github.com/terkel/4373420
// Round a number to specified digits.
//
// @param {Number} $number A number to round
// @param {Number} [$digits:0] Digits to output
// @param {String} [$mode:round] (round|ceil|floor) How to round a number
// @return {Number} A rounded number
// @example
// decimal-round(0.333) => 0
@matthiasg
matthiasg / 1. README.md
Last active December 13, 2016 07:30
Example of GraphQl issues with respect to filtering. Duplicated filter on data__noxe reference field. Also potentially conflicting with different versions.

Given a schema with three entities cases,products,noxe where cases and products link to noxe via field data__noxe and where the type noxe is a union of two major versions Noxe_v1 and Noxe_v2.

If the noxe should be filtered (by parent AND other properties) then the code to filter might be duplicated if put into the resolvers naively. The code can be easily be factored out but the duplication in the arguments remains AND is complicated by the fact that different filters might be needed for different versions of Noxe.

Looking at the line 4: data__noxe(match:"some n2") { we can see an argument data__value which is supposed to define a filter on field data__value. When adding another filter only present in one of the versions data__noxe(data__value:"eq:some n2" data__sometext:"contains:some") {

@matthiasg
matthiasg / create.js
Last active August 31, 2016 05:38
Postgres query test
var pg = require('pg');
var faker = require('faker');
var Promise = require('bluebird');
var uuid = require('node-uuid');
// create a config to configure both pooling behavior
// and client options
// note: all config is optional and the environment variables
// will be read if the config is not present
var config = {
@matthiasg
matthiasg / haproxy.cfg
Created August 9, 2016 19:29 — forked from ryzy/haproxy.cfg
HAProxy - essentials for HTTP/2
frontend https-in
mode tcp
bind *:443 ssl crt /etc/ssl/dummy.pem alpn h2,http/1.1
use_backend nodes-http2 if { ssl_fc_alpn -i h2 }
default_backend nodes-http
backend nodes-http
server node1 web.server:80 check
backend nodes-http2
@matthiasg
matthiasg / gist:2b8748cfdf919ce77c3fd0438613cee6
Created April 12, 2016 21:11 — forked from robinloxley1/gist:7ea7c4f37a3413b1ca16
sample elasticsearch query to sort parent based on child field
{
"query":{
"has_child":{
"query":{
"function_score":{
"functions":[
{
"field_value_factor":{
"factor":1,
"field":"count"