Skip to content

Instantly share code, notes, and snippets.

View mpneuried's full-sized avatar
🏠
Working from home

M. Peter mpneuried

🏠
Working from home
View GitHub Profile
@mpneuried
mpneuried / filtermacs.js
Created January 17, 2018 08:04
Filter Refurb Macs by GB and SSD: Small function to remove all refurbished macs that does not match the defined GB and SSD size
// 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 September 4, 2017 12:52
Try to find birthdays by last/next n-days
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" )
@mpneuried
mpneuried / keybase.md
Last active August 25, 2017 06:59
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 February 10, 2017 09:01
parse and filter redis clients
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 December 9, 2016 07:55
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.
###
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 October 13, 2016 13:02
Small example how to use with
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 July 27, 2016 13:11
SQL HELPERS :: SQL commands i allways have to search for
/* 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 June 20, 2016 11:32
Small script to test the event listener count after the `.start()` and `.stop()` methods of rsmq-worker
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 October 23, 2015 06:01
Fontello Grunt edit helper
###
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.
###