Skip to content

Instantly share code, notes, and snippets.

@mweibel
mweibel / mod_msg_filter.erl
Created April 26, 2012 05:55 — forked from mardambey/mod_msg_filter.erl
mod_msg_filter allows the filtering of "message" stanzas across an HTTP service.
%% mod_msg_filter allows the filtering of "message"
%% stanzas across an HTTP service. The URL of the
%% service must be passed as part of the module's
%% configuration. Both JIDs and their resources are
%% passed as part of the query string and the result
%% is expected to be one of:
%%
%% <status value="denied">
%% <stanza1><error/></stanza1>
%% <stanza2><error/></stanza2>
@mweibel
mweibel / mod_onlineusers.erl
Created October 5, 2012 06:05
mod_onlineusers with list of users online
%%%----------------------------------------------------------------------
%%% File : mod_onlineusers.erl
%%% Author : Michael Weibel <michael.weibel+github@gmail.com>
%%% Purpose : Display number & list of online users
%%% Created : 2011-08-16
%%%----------------------------------------------------------------------
-module(mod_onlineusers).
-author('michael.weibel+github@gmail.com').
@mweibel
mweibel / gist:4123802
Created November 21, 2012 08:28
ISO8601 to unix timestamp
-module(iso8601_to_unixtimestamp).
-define(GREGORIAN_SECONDS_TO_UNIXTIMESTAMP_DIFFERENCE, 719528*24*3600).
-export([doit/0]).
parse_iso8601(DateString) ->
{ok,[Year, Month, Day, Hour, Min, Sec],_} = io_lib:fread("~d-~d-~dT~d:~d:~dZ", DateString),
{{Year,Month,Day},{Hour,Min,Sec}}.
ymdhms_to_gregorian_seconds({{Year,Month,Day},{Hour,Min,Sec}}) ->
@mweibel
mweibel / passport-mock.js
Last active December 5, 2022 03:33
Mock passport.js with an own strategy
/**
* Author: Michael Weibel <michael.weibel@gmail.com>
* License: MIT
*/
var passport = require('passport')
, StrategyMock = require('./strategy-mock');
module.exports = function(app, options) {
// create your verify function on your own -- should do similar things as
@mweibel
mweibel / gen-redis-protocol.sh
Last active December 17, 2020 05:14
Redis protocol generator in bash according to http://redis.io/topics/mass-insert. Use e.g. with `./fixture.sh |redis-cli --pipe`. Whitespaces within values are currently not supported.
#!/bin/bash
#
# License: MIT
# Author: Michael Weibel
#
gen_redis_protocol() {
cmd=$1
proto=""
proto+="*"
@mweibel
mweibel / React Component
Last active August 29, 2015 14:12
WebStorm/IntelliJ React component file template
/** @jsx React.DOM */
'use strict';
var React = require('react');
## Will replace dashes in names with camelCase
#set($componentName = "")
#foreach($str in $NAME.split("-"))
#set($str = $str.substring(0,1).toUpperCase()+$str.substring(1))
@mweibel
mweibel / supervisor2.diff
Created February 11, 2015 15:22
Supervisor2 MongooseIM vs. rabbit_common
--- apps/ejabberd/src/supervisor2_mongooseim.erl 2015-02-11 12:52:33.000000000 +0100
+++ deps/rabbit_common/src/supervisor2.erl 2015-01-30 07:35:08.000000000 +0100
@@ -23,17 +23,9 @@
%% stopping the supervisor, the supervisor instead continues and
%% tries to start up the child again, Delay seconds later.
%%
-%% Note that you can never restart more frequently than the MaxT
-%% and MaxR parameters allow: i.e. you must wait until *both* the
-%% Delay has passed *and* the MaxT and MaxR parameters allow the
-%% child to be restarted.
import cv2
import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread('image.jpg', cv2.IMREAD_GRAYSCALE)
def compute_skew(image):
image = cv2.bitwise_not(image)
height, width = image.shape
var items = [
{
id: '1',
refId: 'A'
},
{
id: '2',
refId: 'B'
},
{
@mweibel
mweibel / README.md
Created May 29, 2017 15:39
json.Unmarshal vs. json.NewDecoder

Go json unmarshal vs using the decoder

When running main_unmarshal.go:

$ go run ./main_unmarshal.go
Input 2:
json syntax error: unexpected end of JSON input at offset 144

When running main_decoder.go: