Skip to content

Instantly share code, notes, and snippets.

View alexbihary's full-sized avatar

Alexander Bihary alexbihary

View GitHub Profile
var safeCharsForCSSContent = /[0-9A-Za-z\`\~\!\@\#\$\%\^\&\*\(\)\-\_\=\+\|\[\{\]\}\:\,<\.\>\/\?]/;
var singleEscapeChars = /[\\\;]/;
function escapeForCSSContent(text) {
var index = 0,
length = text ? text.length : 0,
result = '';
while(index < length) {
var character = text.charAt(index);
if (safeCharsForCSSContent.test(character)) {
@alexbihary
alexbihary / ko-binding-dump.js
Created December 24, 2013 14:49
Knockout debugging binding handler - dump. Will output models/values to the page in <pre> tags.
/*
* Dump binding values onto the page using this HTML syntax:
* <div data-bind="dump: $data"></div>
*/
/* catch and precent cyclical references in rootObject */
function toJSON(rootObject, replacer, spacer) {
var cache = [];
var plainJavaScriptObject = ko.toJS(rootObject);
@alexbihary
alexbihary / sublimetext2.reg
Created December 19, 2013 14:31
Open folder in Sublime Text - add to right-click menu for Windows
Windows Registry Editor Version 5.00
; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\shell\sublime]
@="Open Folder as &Sublime Project"
"Icon"="\"C:\\Program Files\\Sublime Text 2\\sublime_text.exe\",0"
[HKEY_CLASSES_ROOT\Directory\shell\sublime\command]
@alexbihary
alexbihary / setZeroTimeout.js
Created September 3, 2013 15:28
custom setZeroTimeout() - Better than setTimeout(0) From http://dbaron.org/log/20100309-faster-timeouts
// Only add setZeroTimeout to the window object, and hide everything
// else in a closure.
(function() {
var timeouts = [];
var messageName = "zero-timeout-message";
// Like setTimeout, but only takes a function argument. There's
// no time argument (always zero) and no arguments (you have to
// use a closure).
function setZeroTimeout(fn) {
public static void TestTypeSwitch()
{
var ts = new TypeSwitch()
.Case((int x) => Console.WriteLine("int"))
.Case((bool x) => Console.WriteLine("bool"))
.Case((string x) => Console.WriteLine("string"));
ts.Switch(42);
ts.Switch(false);
ts.Switch("hello");
public enum EngineType
{
Diesel,
Gasoline
}
public class Bicycle
{
public int Cylinders;
}
@alexbihary
alexbihary / ..readme.md
Last active December 15, 2015 15:38
Ubuntu Server Development Setup

#Ubuntu Server Setup

##Create Server

  • DigitalOcean or other cloud service
  • Setup DNS A record

##User Setup

As root:

@alexbihary
alexbihary / gist:5078409
Last active December 14, 2015 11:19 — forked from RaVbaker/gist:2967695

Ubuntu 12.04 Ruby on Rails Development Environment

I haven't set up an install guide for the latest ubuntu release, largely because the last set of instructions worked pretty closely with the latest and greatest Ubuntu, 12.04 Precise Pangolin, however when installing today, I found that there were enough differences in the way that I configure my setup to justify an update, so here it goes. Yes, I'm late to the party, but a quick google search didn't find anything that I felt was as complete for my requirements as my previous install guides, so here I go.

As always with my install guides, I have included here is just about everything you'll need (and then some) to get started with ruby on rails development with Ubuntu 12.04 as a platform. These are my settings and preferences, and this is certainly not the only way of doing things, so keep that in mind.

##Step 0: User Setup (from root login)

sudo adduser <username>

sudo adduser sudo