Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'sinatra'
require 'net-ldap'
require 'digest/sha1'
require 'base64'
require 'haml'
LDAP_HOST = 'localhost'
ADMIN_DN = 'cn=admin,dc=company,dc=com'
@bogdanRada
bogdanRada / Gemfile
Last active August 31, 2015 09:32 — forked from gorenje/Gemfile
source :rubygems
gem 'sinatra'
gem 'json'
gem 'omniauth'
gem 'omniauth-oauth2'
gem 'omniauth-github'
gem 'omniauth-facebook'
gem 'omniauth-twitter'
# gem 'omniauth-att', :path => File.expand_path("./../../omniauth-att", __FILE__)
module RecognizePath
def recognize_path(path, options)
recognized_path = Rails.application.routes.recognize_path(path, options)
# We have a route that catches everything and sends it to 'errors#not_found', you might
# need to rescue ActionController::RoutingError
return recognized_path unless recognized_path.slice(:controller, :action) == {controller: 'errors', action: 'not_found'}
# The main app didn't recognize the path, try the engines...
Rails.application.railties.engines.each do |engine|
@bogdanRada
bogdanRada / actor.rb
Last active August 31, 2015 09:38 — forked from darkhelmet/actor.rb
LolConcurrency::Actor Make Your own Celluloid
require 'forwardable'
require 'thread'
require 'monitor'
module LolConcurrency
module Actor
Context = Struct.new(:method, :args, :block)
Async = Struct.new(:instance, :mailbox) do
extend Forwardable
@bogdanRada
bogdanRada / pubsub.md
Last active August 29, 2015 14:18 — forked from addyosmani/pubsub.md

#Four Ways To Do Pub/Sub With jQuery and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

# Avoid annoying ActionController::UnknownHttpMethod exceptions like:
#
# ActionController::UnknownHttpMethod) "CONNECT, accepted HTTP methods are get, head, put, post, delete, and options"
#
# Install this file in app/metal and these requests will receive a 405
# "Method Not Allowed" status and will be logged under `info'.
class IgnoreUnknownHttpMethod
def self.call(env)
[
if ActionController::Request::HTTP_METHODS.include?(env["REQUEST_METHOD"].downcase)

YARD CHEATSHEET http://yardoc.org

cribbed from http://pastebin.com/xgzeAmBn

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

Namespace for classes and modules that handle serving documentation over HTTP

@bogdanRada
bogdanRada / olark_livecha_glass_theme.css
Last active August 31, 2015 09:43 — forked from stringtheory/azul_theme.css
Custom Theme Examples from Olark - non-minified.
#habla_window_div button, #habla_window_div input[type=submit] {
width: auto;
font-size: 14px;
margin: 5px 3px 0 5px!important;
}
#habla_window_div [class*=span] {
float: none;
margin-left: 0;
}
#habla_beta_container_do_not_rely_on_div_classes_or_names .habla_window_div_base {
@bogdanRada
bogdanRada / zopim_livechat_mixpanel_tracking.js
Last active August 31, 2015 09:46 — forked from fotoflo/gist:10934777
zopim mixpanel tracking.js
//
// Track.js - tracking scripts by alex miller
//
//
config = {};
config.track = true;// set to true in production, false in dev env
config.dump = true;// set to false in production env, true in dev
config.mixpanel = true; // <%= TRACKS_CONFIG['mixpanel'] %>; // set to true in production env, false in dev
config.googleAnaltyics = true;