Skip to content

Instantly share code, notes, and snippets.

@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.
@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}}) ->
var items = [
{
id: '1',
refId: 'A'
},
{
id: '2',
refId: 'B'
},
{
@mweibel
mweibel / README.md
Last active November 16, 2017 10:26 — forked from Im0rtality/README.md
PHP CLI Debugging in Vagrant using Xdebug and PHPStorm

In host:

  1. Go to PHPStorm Settings > Project settings > PHP > Servers
  2. Add server with following parameters:
    • Name: vagrant (same as serverName= in debug script)
    • Host, port: set vagrant box IP and port
    • Debugger: Xdebug
    • [v] Use path mappings
    • Map your project root in host to relative dir in guest
  • Hit OK
@mweibel
mweibel / Foo.test.js
Created June 26, 2018 13:30
Mock react-beautiful-dnd
// mocks react-beautiful-dnd Droppable without the need of a DragDropContext etc.
jest.mock('react-beautiful-dnd', () => ({
Droppable: jest.fn(
// params to children are `provider`, `snapshot`
({children}) => children({}, {})
)
}));
@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:

@mweibel
mweibel / usage.tsx
Last active January 24, 2020 16:58
my own useForm hook
const schema = {
email: {
presence: { allowEmpty: false, message: "required" },
email: {
message: "valid"
}
}
};
interface LoginFormFields {