Skip to content

Instantly share code, notes, and snippets.

@marcinbunsch
marcinbunsch / index.js
Created Apr 19, 2017
Groove Webhook Handler Example
View index.js
const express = require("express");
const app = express();
const bodyParser = require('body-parser');
const options = {};
app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
app.post('/groove/ticket/assign', function(req, res) {
console.log(req.body)
View keybase.md

Keybase proof

I hereby claim:

  • I am marcinbunsch on github.
  • I am marcinbunsch (https://keybase.io/marcinbunsch) on keybase.
  • I have a public key whose fingerprint is 1836 25CF 5835 7135 7C96 B578 7139 5EA3 254C 76F4

To claim this, I am signing this object:

@marcinbunsch
marcinbunsch / wat_spec.rb
Created Jun 25, 2012
expecting an error once
View wat_spec.rb
class Wat
attr_accessor :collaborator, :credentials
def foo(arg)
@collaborator.foo(arg)
rescue
@collaborator.set_auth_credentials(credentials)
@collaborator.foo(arg)
end
View graceful.rb
require "singleton"
class GracefulQuit
include Singleton
attr_accessor :breaker
def initialize
self.breaker = false
end
@marcinbunsch
marcinbunsch / codewall.badges.js
Created Mar 10, 2012
Coderwall - display missing badges
View codewall.badges.js
// How to use this:
// 1. Go to the desired profile page on coderwall, like http://coderwall.com/marcinbunsch
// 2. Paste this gist in the JS console
//
// You can also probably use this in greasemonkey and dot.js
//
// Also, it was tested in Chrome, Firefox and Safari, it probably will
// not work in IE, but I just don't care about it ;)
//
// UPDATE: Coderwall made changes to the site and I cannot retrieve the achievements, so they are hardcoded, taken from a cached version of the achievements page
@marcinbunsch
marcinbunsch / lochness.rb
Created Mar 7, 2012
Loch Ness Monster Case implementation in Ruby
View lochness.rb
class String
def loch_ness_monster_case
self.split('::').collect do |section|
section.gsub(/([^\/])([A-Z])/, '\1_\2').downcase.split(/_/).collect { |part|
chars = part.split('')
half = chars.length/2
chars[half].upcase!
chars[half - 1].upcase!
chars.join('')
View true_dat.rb
class TrueClass
def dat
self
end
end
true.dat # => true
@marcinbunsch
marcinbunsch / profiling_tool.rb
Created Dec 29, 2011 — forked from ksarna/profiling_tool.rb
Profiling rails requests with ruby-prof
View profiling_tool.rb
# You can use this class in your console. For example
# p = ProfilingTools.new
# p.profiled_request(:controller => :welcome, :action => :index)
# this will profile whole application stack and save file in your tmp/profiler folder
# You can also use +request+ method just to see the output for example:
#
# p.request(:controller => :offers, :action => :index)
#
# p.response.body
# p.response.cookies # and so on
@marcinbunsch
marcinbunsch / things-yammer-checkin
Created Jul 8, 2011 — forked from cziko/things-yammer-checkin
Things - Yammer checkin script
View things-yammer-checkin
#!/usr/bin/ruby
# gem install things-client --source http://gemcutter.org
# gem install broadcast
require 'rubygems'
require 'things'
require 'broadcast'
@marcinbunsch
marcinbunsch / gist:1044437
Created Jun 24, 2011 — forked from michalbugno/gist:1042356
Rails production prompt change as a Rails initializer
View gist:1044437
# Put this file in config/initializers/irb.rb
# Works in Rails 3.0+, should also work in 2.3
# Override the IRB, to provide the Rails environment in the prompt
module IRB
class << self
def setup_with_prompt_override(ap_path)
setup_without_prompt_override(ap_path)
env = (Rails.env.to_sym == :production ? "\033[00;31mPRODUCTION\033[00m" : Rails.env)