Skip to content

Instantly share code, notes, and snippets.

@bekzod
bekzod / ago.js
Created February 4, 2013 00:48 — forked from cowboy/ago.js
ago
module.exports = (function(){
const MS =
{ seconds: 1000
, minutes: 60 * 1000
, hours: 60 * 60 * 1000
, days: 24 * 60 * 60 * 1000
, weeks: 7 * 24 * 60 * 60 * 1000
, months: 30 * 7 * 24 * 60 * 60 * 1000
, years: 365 * 24 * 60 * 60 * 1000 }
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as:
@bekzod
bekzod / app.js
Created April 10, 2013 18:12 — forked from bobbydavid/app.js
var express = require('express')
, http = require('http')
, connect = require('connect')
, io = require('socket.io');
var app = express();
/* NOTE: We'll need to refer to the sessionStore container later. To
* accomplish this, we'll create our own and pass it to Express
* rather than letting it create its own. */
var sessionStore = new connect.session.MemoryStore();

JavaScript Best Practices

Code conventions

Closing/opening brackets

Although this isn't a problem in other languages, because of semicolon insertion, there could be problems if you don't place the bracket on the opening line:

// no:
function()
{
{
"orderInfo":[
{
"type":"confirm",
"id":"77442c47-f2bc-4576-88f4-34166b466814",
"lastTicketDate":"2013-12-06T09:01:20.055Z",
"trip":"SVO-LHR-SVO",
"route":[
[
"SVO",

Top Sublime Plugins You Need


##Must Have

###Sublime-jslint JSLint for sublime

*install using sublime package manager github repo

@bekzod
bekzod / gist:8314892
Last active January 2, 2016 14:09
My Sublime Settings
{
"animation_enabled": false,
"auto_complete_commit_on_tab": true,
"bold_folder_labels": true,
"caret_style": "solid",
"chrome_path":
{
"osx": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
},
"close_windows_when_empty": true,
{
orderInfo: [
{
type: "confirm",
id: "9743aca9-7d11-4488-b5c3-459ff562f433",
lastTicketDate: "2014-02-06T13:07:57.850Z",
trip: "DME-LHR-DME",
route: [
[
"DME",
Order.prototype.getHotelWidgetData = function(params, cb){
var self = this;
params = params || {};
params.date_start = params.date_start || (new Date().format('yyyy-mm-dd'));
params.date_end = params.date_end || params.date_start;
params.adults = params.adults || 2;
params.currency = params.currency || 'EUR';
params.children = params.children || 0;
params.city = params.city || 'moscow';
@bekzod
bekzod / new_api
Last active August 29, 2015 13:57
new_api
"insurance": {
"src": "LIBERTY"
"cur": "RUB",
"types": {
"BAGGAGE_ACCIDENT": {
"price": 249,
"payouts": [30000]
}
"BAGGAGE_CANCEL": {
"price": 524,