Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

M. Peter mpneuried

🏠
Working from home
View GitHub Profile
View pg-vs-mapd.md
@mpneuried
mpneuried / filtermacs.js
Created Jan 17, 2018
Filter Refurb Macs by GB and SSD: Small function to remove all refurbished macs that does not match the defined GB and SSD size
View filtermacs.js
// paste and execute it into the browser console. You can define ( GB, SSD [, index-of-box-content-class ] )
// https://www.apple.com/de/shop/browse/home/specialdeals/mac/macbook_pro
// eventually there is a header then you can test the param index-of-box-content-class = 1
((_gb, _ssd, content_idx) => { const _wrp = document.getElementsByClassName("box-content")[ content_idx || 0];Array.from(document.getElementsByClassName("specs")).forEach((el) =>{if (!(el.innerHTML.indexOf(_gb.toString() + " GB") > 0 && el.innerHTML.indexOf(_ssd.toString() + " GB") > 0)) {_wrp.removeChild(el.parentNode.parentNode.parentNode)}})})(16,512)
@mpneuried
mpneuried / birthday.coffee
Created Sep 4, 2017
Try to find birthdays by last/next n-days
View birthday.coffee
DAYMS = 1000 * 60 * 60 * 24
checkBirthday = ( now, bd, diff )->
# differ between next and last days (look back or forward)
if diff > 0
start = new Date( now + " 00:00:00 +0000" )
end = new Date( start.valueOf() + ( DAYMS * diff ) )
year = new Date( end ).getFullYear()
else
end = new Date( now + " 00:00:00 +0000" )
View keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@mpneuried
mpneuried / get_current_redis_client.coffee
Created Feb 10, 2017
parse and filter redis clients
View get_current_redis_client.coffee
querystring = require('querystring')
crypto = require('crypto')
parseRedisClients = ( raw, filter={} )->
clients = []
for line in raw.split( "\n" ) when line.length > 1
cl = querystring.parse( line, " ", "=" )
if Object.keys( filter ).length
_match = true
for _k, _v of filter when cl[ _k ] isnt _v
@mpneuried
mpneuried / Backbone.sub.coffee
Last active Dec 9, 2016
Backbone collection extension to solve sub collections.The models withtin the (sub)collection-tree will be distributed within all involved collections under consideration of each filter.
View Backbone.sub.coffee
###
EXAMPLE USAGE
parentColl = new Backbone.Collection.Extended()
# by Array
subCollA = parentColl.sub( [ 1, 2, 3 ] )
# or by Object
subCollO = parentColl.sub( { name: "Foo", age: 42 } )
@mpneuried
mpneuried / with.ex
Last active Oct 13, 2016
Small example how to use with
View with.ex
defmodule WithTest do
def run do
with{:ok, a} <- fun("A"),
{:ok, b} <- fun("B"),
{:ok, c} <- fun("C")
do
{:ok, [a,b,c] }
else
{:error, err} ->
{:error, err}
@mpneuried
mpneuried / helpers.sql
Last active Jul 27, 2016
SQL HELPERS :: SQL commands i allways have to search for
View helpers.sql
/* activate global logging and the logfile path*/
SET GLOBAL general_log = 'ON';
SET GLOBAL general_log_file = '/Users/mathiaspeter/logs/mysql_general.log';
/* deactivate global logging */
SET GLOBAL general_log = 'OFF';
/* show variables */
SHOW GLOBAL VARIABLES like '%log%';
@mpneuried
mpneuried / rsmq-worker-event-counter.js
Last active Jun 20, 2016
Small script to test the event listener count after the `.start()` and `.stop()` methods of rsmq-worker
View rsmq-worker-event-counter.js
var RSMQWorker = require( "./" );
var RedisSMQ = require("rsmq");
var WORKERCOUNT = 12;
var rsmq = new RedisSMQ( {host: "127.0.0.1", port: 6379, ns: "rsmq"} );
rsmq.setMaxListeners(WORKERCOUNT)
// count the event listener per event
var countListener = function(){
var _ret = {};
@mpneuried
mpneuried / grunt-fontello-edit.coffee
Created Oct 23, 2015
Fontello Grunt edit helper
View grunt-fontello-edit.coffee
###
USAGE:
1. Make sure you have a valid fontello config file
2. call "grunt edit-font" -> your browser will open with a session based on your config file
3. Edit your font within fontello and click "Save session"
4. call "grunt update-fonts". This will call the task "update-fonts-config" to download the session zip and replace the config. Then it's call the task `fontello:standard` based on your config.json.
###