Skip to content

Instantly share code, notes, and snippets.

// $mq-mobile-portrait : 320px !default;
// $mq-mobile-landscape : 480px !default;
// $mq-tablet-portrait : 640px !default; -- changed because i want my blog content is around this wide, not 768. you should let content & design determine your breakpoints
// $mq-tablet-landscape : 1024px !default;
// $mq-desktop : 1382px !default;
$mq-mobile-portrait : 20em !default;
$mq-mobile-landscape : 30em !default;
$mq-tablet-portrait : 40em !default;
$mq-tablet-landscape : 64em !default;
@lotsofcode
lotsofcode / gist:5014949
Created February 22, 2013 17:04
Playing with functions and closures
function foobar(binary) {
return function(a) {
return function (b) {
if (typeof binary == 'function') { // binary
return binary(a, b);
} else if (typeof window[binary] == 'function') { // string
return window[binary](a, b);
} else {
throw "Invalid function provided";
}
@lotsofcode
lotsofcode / installing-java.sh
Created February 24, 2013 13:27
Sun/Oracle Java on Ubuntu 12.10
sudo add-apt-repository ppa:webupd8team/java;
sudo apt-get update;
sudo apt-get install oracle-java8-installer;
@lotsofcode
lotsofcode / gist:5092167
Created March 5, 2013 17:32
Markdown Template

Sample Markdown Cheat Sheet

This is a sample markdown file to help you write Markdown quickly :)

If you use the fabulous [Sublime Text 2 editor][ST2] along with the [Markdown Preview plugin][MarkdownPreview], open your ST2 Palette with CMD+P then choose Markdown Preview in browser to see the result in your browser.

Text basics

this is italic and this is bold . another italic and another bold

@lotsofcode
lotsofcode / gist:5157069
Created March 13, 2013 22:37
write already install bower components to component.json file
for component in $(ls components --color=never); do bower install $component --save; done;
function yeoapp() {
local dirname="$1"
if [ "$dirname" = "" ]; then
echo "usage: yeoman $dirname";
return 1;
fi
if [ -d "$dirname" ]; then
echo "'$dirname' exists, please choose another";

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@lotsofcode
lotsofcode / gist:5626525
Created May 22, 2013 10:05
javascript duplicate function
Array.prototype.duplicate = function() {
return this.concat(this);
}
var duped = [1,2,3,4,5].duplicate()
console.log(duped)

The idea is to have nginx installed and node installed. I will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx 0.7.62 and node 0.2.3 installed on a Linux distro (I used Ubuntu).

In a nutshell,

  1. nginx is used to serve static files (css, js, images, etc.)
  2. node serves all the "dynamic" stuff.

So for example, www.foo.com request comes and your css, js, and images get served thru nginx while everything else (the request for say index.html or "/") gets served through node.

  1. nginx listens on port 80.
@lotsofcode
lotsofcode / epsilon-greedy-method.php
Last active December 19, 2019 06:28
epsilon-greedy-method.php
<?php
/*
@ref http://stevehanov.ca/blog/index.php?id=132
def choose():
if math.random() < 0.1:
# exploration!
# choose a random lever 10% of the time.
else:
# exploitation!
# for each lever,