This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# # PubSub | |
# | |
# Is a small helper to simply realize a pub/sub pattern to a coffee class. | |
# | |
# A namespaceing of the topics is also included. | |
# This means you can subscribe to `a` and also get the `a.b`. But if you subscribe to `a.b` you will not get a `a`. | |
# | |
# **required module**: `underscore` | |
# | |
class PubSub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
o = { | |
"ID": "BgQfL", | |
"jsonSettings": "{\"weight\":49,\"height\":158,\"heartrate_max\":168,\"phonebusiness\":\"03423/667840\",\"usergroups\":\"Mitglied\",\"colors\":{\"plantargets\":[],\"usergroups\":[],\"pain\":[],\"damage\":[],\"activeplan_targets\":[]},\"comment\":\"Skoliose\r\n\r\nPatientin ist hypermobil\r\n\r\nbd Clavicula gebrochen; links 2011, recht 1997\",\"plantargets\":\"Muskelaufbau,Ausdauer\"}", | |
"firstname": "Heike", | |
"lastname": "Jüttner" | |
} | |
console.log( o.jsonSettings ) | |
_json = | |
encode: ( s )-> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SortableCollection extends Collection | |
### | |
## moveAfter | |
`collections.moveAfter( model, predecessor )` | |
Move a model after another model or if `predecessor` is `null` or `0` to the top of the model list | |
@param { Model | String | Number } model The model to move, it's `id` or the `cid` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JSONreplace | |
### | |
## _jsonreplacemap | |
`_jsonreplacemap( _json, map )` | |
Replace the values of a key inside of a json string. | |
@param { String | Object } _json A Stringfied JSON or a object witch will be stringfied. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Middleware | |
constructor: -> | |
# define a shared object witch will be routed through all called methods | |
shared = {} | |
# run the middleware method to process all defined methods | |
# If one method fails by calling error the queue will be stopped | |
@middleware shared, @simpleCall, @addSomeMethods, ( err, shared )=> | |
if err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# drop a existing test table | |
DROP TABLE IF EXISTS `test`; | |
# create the test table | |
CREATE TABLE `test` ( | |
`_h` varchar(5) NOT NULL DEFAULT '', | |
`_set` text, | |
PRIMARY KEY (`_h`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
**IMPORTANT** Make shure moment.js is available. | |
**ARGUMENTS** | |
* `timestamps` *( Array )*:An arry of timestamps. | |
* `type` *( String )*: A moment time type like `minute`, `hour`, `day` | |
* `pastCursor` *( Number )*: A number to define the maximum time to the past. If lower than `0` all given timestamps will be returned. | |
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### USEAGE | |
crypto = require( "./crypto" )() | |
_crypted = crypto.crypt( "myPassowrd", "data123" ) | |
crypto.decrypt( "myPassowrd", _crypted ) # data123 | |
### | |
crypto = require( "crypto" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
EXAMPLE USAGE | |
testColl = new Backbone.Collection.Extended() | |
# PROMISE USAGE | |
# define handlers | |
fnSuccess = -> | |
console.log( "SUCCESS", arguments ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEFAULT_IP=127.0.0.1 | |
IP=${2:-$DEFAULT_IP} | |
sed -ie "\| $1\$|d" /etc/hosts | |
echo "$IP $1" >> /etc/hosts | |
exit 0 |