Skip to content

Instantly share code, notes, and snippets.

William Herry williamherry

Block or report user

Report or block williamherry

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 hubot-explore.md

安装

Hubot需要Node和npm的比较新的版本,Mac os x安装非常简单,从nodejs.org下载安装就可以了

➜  node --version
v0.12.4
➜  npm --version
View hubot-script-example.coffee
# Description:
# Example scripts for you to examine and try out.
#
# Notes:
# They are commented out by default, because most of them are pretty silly and
# wouldn't be useful and amusing enough for day to day huboting.
# Uncomment the ones you want to try and experiment with.
#
# These are from the scripting documentation: https://github.com/github/hubot/blob/master/docs/scripting.md
@williamherry
williamherry / bearychat-webhook.coffee
Last active Apr 2, 2016
集成到倍洽(bearychat)的hook代码
View bearychat-webhook.coffee
{TextMessage} = require '../node_modules/hubot/src/message'
module.exports = (robot) ->
robot.router.post '/hubot/bearychat/:room', (req, res) ->
data = if req.body.payload? then JSON.parse req.body.payload else req.body
robot._send ?= robot.adapter.send;
robot.adapter.send = (user,strings...) ->
res.send {text: strings.toString()} if user.user.name is "http"
robot.adapter.send = robot._send if user.user.name isnt "http"
View gist:335e514de5a9fedaeb82
{
"name": "qiniu-js-sdk",
"version": "0.0.1",
"description": "Qiniu JavaScript SDK Node Module",
"main": "qiniu.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
View gist:de48684c30d91fe450ed
check process redis-server
with pidfile "/var/run/redis.pid"
start program = "/etc/init.d/redis-server start"
stop program = "/etc/init.d/redis-server stop"
if 2 restarts within 3 cycles then timeout
if totalmem > 100 Mb then alert
if children > 255 for 5 cycles then stop
if cpu usage > 95% for 3 cycles then restart
if failed host 127.0.0.1 port 6379 then restart
if 5 restarts within 5 cycles then timeout
View gist:9801716
undefined method `[]=' for Sidekiq:Module
/home/deploy/rails_apps/smart_lion/releases/20140326083837/config/initializers/sidekiq.rb:13:in `block in <top (required)>'
/home/deploy/rails_apps/smart_lion/shared/bundle/ruby/2.0.0/gems/sidekiq-2.17.0/lib/sidekiq.rb:47:in `configure_server'
/home/deploy/rails_apps/smart_lion/releases/20140326083837/config/initializers/sidekiq.rb:3:in `<top (required)>'
/home/deploy/rails_apps/smart_lion/shared/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/home/deploy/rails_apps/smart_lion/shared/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
/home/deploy/rails_apps/smart_lion/shared/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
/home/deploy/rails_apps/smart_lion/shared/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/home/deploy/rails_apps/smart_lion/shared/bundle/ruby/2.0.0/gems/rai
View gist:9503003
payload | duration | started_at
-----------------------------------------------------------------------------------+----------------+------------------------
{"class":"PushService","jid":"2ff704a149d4c74d3f225492","notification_count":200} | 5770.233193 | 2014-03-12 10:00:16+08
{"class":"PushService","jid":"bb1369d665db8931fd63e716","notification_count":200} | 20513.497832 | 2014-03-12 10:02:15+08
{"class":"PushService","jid":"29f47a69907044060579206c","notification_count":200} | 4035.010939 | 2014-03-12 10:04:15+08
{"class":"PushService","jid":"1c3d7f4ae405903fe5839abd","notification_count":200} | 54542.827837 | 2014-03-12 10:06:15+08
{"class":"PushService","jid":"0fcb6888c08ed51b41b94eb6","notification_count":200} | 143353.947749 | 2014-03-12 10:08:15+08
{"class":"PushService","jid":"b3e6b84b95d0683b593fa2bf","notification_count":200} | 50347.900462 | 2014-03-12 10:12:15+08
{"class":"PushService","jid"
View username-concept.rb
# app / controllers / application_controller.rb
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
View tinyssh.erl
-module(tinyssh).
-export([upload_download/1]).
-export([run_cmd/1]).
-export([download/3]).
-export([upload/3]).
-export([run_action/7]).
-export([run_action/6]).
-export([run/2]).
View mm_ssh.erl
%%% -------------------------------------------------------------------
%%% Author : anton
%%% Description :
%%%
%%% Created : 21 Dec 2008
%%% -------------------------------------------------------------------
-module(mm_ssh).
-behaviour(gen_fsm).
%% --------------------------------------------------------------------
You can’t perform that action at this time.