Skip to content

Instantly share code, notes, and snippets.

ANSI_COLOR_CODE = {
0 => 'black',
1 => 'red',
2 => 'green',
3 => 'yellow',
4 => 'blue',
5 => 'purple',
6 => 'cyan',
7 => 'white'
}
@bogdanRada
bogdanRada / olark.php
Last active August 29, 2015 14:15 — forked from iloveitaly/olark.php
<?php
/*
Plugin Name: OLark
Description: Live Chat
Version: 1.0
Author: Michael Bianco
Author URI: http://github.com/iloveitaly/
*/
function admin_page () {
//basic zopim widget code, from their site
window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
_.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');
$.src='//v2.zopim.com/?26Smu9lv0NXQEOOg8IAZrMPh9yQstAcV';z.t=+new Date;$.
type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');
//make sure zopim does not show till we know we have department agents
var intial_zopim_hiding_done = false;
<!--Start of Zopim Live Chat Script-->
< script type = "text/javascript" >
window.$zopim || (function (d, s) {
var z = $zopim = function (c) {
z._.push(c)
}, $ = z.s =
d.createElement(s),
e = d.getElementsByTagName(s)[0];
z.set = function (o) {
z.set.

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

# 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)
@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:

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|
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'