Skip to content

Instantly share code, notes, and snippets.

View vol4ok's full-sized avatar

Andrew Volkov vol4ok

View GitHub Profile

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

(function() {
this.tmpl3 = function tmpl(str, data) {
var value = "var out = ''; out+=" + "'" +
str.replace(/[\r\t\n]/g, " ")
.replace(/'(?=[^%]*%>)/g,"\t")
.split("'").join("\\'")
.split("\t").join("'")
.replace(/<%=(.+?)%>/g, "'; out += $1; out += '")
.split("<%").join("';")
@rrobe53
rrobe53 / gist:976610
Created May 17, 2011 14:46
Node.js File Extension Content Type
exports.ext = function () {
var extTypes = {
"3gp" : "video/3gpp"
, "a" : "application/octet-stream"
, "ai" : "application/postscript"
, "aif" : "audio/x-aiff"
, "aiff" : "audio/x-aiff"
, "asc" : "application/pgp-signature"
, "asf" : "video/x-ms-asf"
, "asm" : "text/x-asm"
@coolaj86
coolaj86 / fs.extra.js
Last active May 22, 2022 22:45
fs.copy and fs.move for Node.JS
/*
UPDATE: this has finally been pushed to npm as `fs.extra`
URL: https://github.com/coolaj86/utile-fs/tree/master/fs.extra
*/
(function () {
"use strict";
console.warn('[Deprecated] See https://github.com/coolaj86/utile-fs');
var fs = require('fs')
@michiel
michiel / cors-nginx.conf
Created July 5, 2011 10:41
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
anonymous
anonymous / gist:1067074
Created July 6, 2011 12:03
/* white button CSS VERSION */
a.button-white-css {
display: inline-block;
vertical-align: middle;
padding: 1px;
line-height: 28px;
-moz-border-radius: 30px;
-webkit-border-radius: 30px;
border-radius: 30px;
-webkit-user-select: none;
@priithaamer
priithaamer / useragent.js
Created July 15, 2011 21:07 — forked from terkel/jquery.ua.js
Node.js User-Agent parser
// Based on fantastic jQuery useragent parser plugin https://gist.github.com/373298
function parse(uaStr) {
var agent = {
platform: {},
browser: {},
engine: {}
};
var ua = uaStr,
p = agent.platform,

#Understanding MVC And MVP (For JavaScript & Backbone Developers)

Before exploring any JavaScript frameworks that assist in structuring applications, it can be useful to gain a basic understanding of architectural design patterns. Design patterns are proven solutions to common development problems and can suggest structural paradigms to help guide us in adding some organization to our application.

I think patterns are exciting as they're effectively a grass roots effort that build upon the collective experience of skilled developers who have previously faced similar problems as we do now. Although developers 10 or 20 years ago may not have been using the same programming languages for implementing patterns, there are many lessons we can learn from their efforts.

In this section, we're going to review two popular patterns - MVC and MVP. The context of our exploration will be how these patterns are related to the popular JavaScript framework Backbone.js, which will be explored in greater detail later on.

@bryanchow
bryanchow / sha256.js
Created January 20, 2012 20:16
JavaScript SHA-256 implementation
// Modified by bryanchow for namespace control and higher compressibility
// See https://gist.github.com/1649353 for full revision history from original
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
* in FIPS 180-2
* Version 2.2 Copyright Angel Marin, Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for details.
@rauchg
rauchg / README.md
Created March 16, 2012 21:05
~/.js/github.com.js

github.com.js

dotjs userscript for visualizing package.json files (if present) underneath the tree view.

Very useful for navigating Node.JS projects