Skip to content

Instantly share code, notes, and snippets.

Michi Kono michikono

Block or report user

Report or block michikono

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View hear.coffee
# demo of brain functionality (persisting data)
# https://github.com/github/hubot/blob/master/docs/scripting.md#persistence
# counts every time somebody says "up"
# prints out the count when somebody says "are we up?"
# /STUFF/ means match things between the slashes. the stuff between the slashes =
# regular expression.
# \b is a word boundary, and basically putting it on each side of a phrase ensures
# we are matching against the word "up" instead of a partial text match such as in "sup"
robot.hear /\bup\b/, (msg) ->
# note that this variable is *GLOBAL TO ALL SCRIPTS* so choose a unique name
View gist:bbe31d12e0f9eaadd413
# Description:
# A script to translate laughter to Argentina's native language
#
# Notes:
# :)
#
# Author:
# Michi Kono
module.exports = (robot) ->
@michikono
michikono / decide.coffee
Last active Aug 29, 2015
Hubot Script for Making Hard Decisions
View decide.coffee
# Description:
# Decides between two or more options at random. Now Spanish compatible!
#
# Commands:
# decide|choose|pick( between)(:) <option 1> and|or <option 2> (and|or <option #> ...)
# escoger|elegir|seleccionar|decidir( entre)(:) <opción 1> y|o <opción 2> (y|o <opción #> ...)
#
# Author:
# Michi Kono
View kue.js
module.exports = function (app, config, passport, express) {
var kue = require("kue");
var auth = express.basicAuth(function(user, pass, callback) {
var result = (user === 'username' && pass === 'password');
callback(null /* error */, result);
});
// any kue related settings can go here
kue.app.set('title', 'Jobs');
// create a wrapper to add auth on since without it we can't globally wrap kue's paths
var subApp = express()
@michikono
michikono / yyyy-mm-dd hh:ii:ss.js
Last active Dec 12, 2015
yyyy-mm-dd hh:ii:ss formatter
View yyyy-mm-dd hh:ii:ss.js
get_time = function() {
var date_part, local_time, now, time_part;
local_time = new Date();
now = new Date(local_time.getTime() + (local_time.getTimezoneOffset() * 60000));
date_part = "" + (this.zero_pad(now.getFullYear(), 2)) + "-" + (this.zero_pad(now.getMonth() + 1, 2)) + "-" + (this.zero_pad(now.getDate(), 2));
time_part = "" + (this.zero_pad(now.getHours(), 2)) + ":" + (this.zero_pad(now.getMinutes(), 2)) + ":" + (this.zero_pad(now.getSeconds(), 2));
return "" + date_part + " " + time_part;
}
zero_pad = function(number, length) {
var str;
@michikono
michikono / jquery.bump.js
Created Jan 21, 2012
jQuery Bump Animation Fixed
View jquery.bump.js
// taken from http://daveymorris.co.uk/web-development/bump-jquery-plugin-bounce
// improved with additional options
(function($){
$.bump = function(el, options){
// Some object and DOM instansiation to make traversing the DOM less expensive
var base = this;
base.$el = $(el);
base.el = el;
View backbone_extension.coffee
# centralized global_dispatcher object added to all Backbone Collection, Model, View, and Router classes
(->
return if this.isExtended
# attaching the Events object to the dispatcher variable
dispatcher = _.extend({}, Backbone.Events, cid: "dispatcher")
_.each [ Backbone.Collection::, Backbone.Model::, Backbone.View::, Backbone.Router:: ], (proto) ->
# attaching a global dispatcher instance
_.extend proto, global_dispatcher: dispatcher
)()
You can’t perform that action at this time.