Skip to content

Instantly share code, notes, and snippets.

// If URL is available URL link the image
// Otherwise just display the image
<% if ( instagram_link_url ) { %> <a href="<%= instagram_link_url %>" target="_blank"> <% } %>
<img src="<%= url %>" alt="<%= username %>" />
<% if ( instagram_link_url ) { %> </a> <% } %>
// Example 2 - Check if formated date
<% if (typeof(date) != "undefined") { %>
<span class="date"><%= date %></span>
<% } %>
@akotlov
akotlov / README.md
Created October 18, 2013 20:44 — forked from mhkeller/README.md

This is a work in progress. Based off of the polygon svg example here: http://bost.ocks.org/mike/leaflet/

Built to find a way around the difficulty in manipulating markers in leaflet / adding arbitrary html / classes / ids etc. to better time them to some time of user-driven narrative (buttons, scrolling etc.)

@akotlov
akotlov / simpleServer
Created October 18, 2013 21:22
simple python server
python -m SimpleHTTPServer 8000
import requests
import time
import json
import zmq
from multiprocessing import Process
import couchdbkit
s = couchdbkit.Server("https://usr:[email protected]")
db = couchdbkit.Database("https://usr:[email protected]/db")
@akotlov
akotlov / idioms.js
Last active December 27, 2015 10:39
Common idioms in Javascript
// Use Array.join to concatenate strings.
//INSTEAD OF
var html = '<div class="button-set">' +
'<span class="button">OK</span>' +
'<span class="button">Apply</span>' +
'<span class="button">Cancel</span>' +
'</div>';
@akotlov
akotlov / module.js
Last active December 30, 2015 15:19
JavaScript module pattern (one of the flavors)
var module = (function () {
// private variables and functions
var foo = 'bar';
// constructor
var module = function () {
};
// prototype
module.prototype = {
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
<script type='text/javascript'>
(function(){
try{
var msg = '\n _\n (_)\n _ _ __ ___ __ _ _ _ _ __\n | | \'_ ` _ \\ / _` | | | | \'__|\n | | | | | | | (_| | |_| | |\n |_|_| |_| |_|\\__, |\\__,_|_|\n __/ |\n |___/\n';
msg += '========================================\nYou opened the console! Know some code,\ndo you? Want to work for one of the best\nstartups around? http://imgur.com/jobs\n========================================\n';
console.log(msg);
}catch(e){}
})()
@akotlov
akotlov / gist:62c448c9e641df644888
Created July 2, 2014 03:24
Public,private,static variables in JavaScript
function MyClass () { // constructor function
var privateVariable = "foo"; // Private variable
this.publicVariable = "bar"; // Public variable
this.privilegedMethod = function () { // Public Method
alert(privateVariable);
};
}