Skip to content

Instantly share code, notes, and snippets.

View marcinbunsch's full-sized avatar

Marcin Bunsch marcinbunsch

View GitHub Profile
@marcinbunsch
marcinbunsch / index.js
Created April 19, 2017 08:27
Groove Webhook Handler Example
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)
@marcinbunsch
marcinbunsch / keybase.md
Created October 25, 2016 14:30
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 June 25, 2012 20:45
expecting an error once
class Wat
attr_accessor :collaborator, :credentials
def foo(arg)
@collaborator.foo(arg)
rescue
@collaborator.set_auth_credentials(credentials)
@collaborator.foo(arg)
end
@marcinbunsch
marcinbunsch / graceful.rb
Created March 14, 2012 17:36
Gracefult quit
require "singleton"
class GracefulQuit
include Singleton
attr_accessor :breaker
def initialize
self.breaker = false
end
@marcinbunsch
marcinbunsch / codewall.badges.js
Created March 10, 2012 22:18
Coderwall - display missing badges
// 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 March 7, 2012 17:11
Loch Ness Monster Case implementation in Ruby
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('')
@marcinbunsch
marcinbunsch / true_dat.rb
Created February 23, 2012 19:08
True#dat
class TrueClass
def dat
self
end
end
true.dat # => true
@marcinbunsch
marcinbunsch / profiling_tool.rb
Created December 29, 2011 14:22 — forked from ksarna/profiling_tool.rb
Profiling rails requests with ruby-prof
# 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 July 8, 2011 11:41 — forked from cziko/things-yammer-checkin
Things - Yammer checkin script
#!/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 June 24, 2011 08:30
Rails production prompt change as a Rails initializer
# 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)