Skip to content

Instantly share code, notes, and snippets.

Avatar

Alex Chuchunkov madfriend

  • Yandex, OpenCorpora
  • St. Petersburg, Russia
View GitHub Profile
@jauco
jauco / gist:201307
Created Oct 4, 2009
Design by contract in javascript
View gist:201307
//Design by contract function
function $contracted(pre, post, func){
return function(){
var paramsAsArray,
funcName,
retVal;
paramsAsArray = Array.slice(arguments)
funcName = func.toString().substr('function '.length);
funcName = funcName.substr(0, funcName.indexOf('('));//strip of everything, but the name
@dherman
dherman / short-functions.js
Created Mar 10, 2012
using -> for concise functions and => for TCP functions
View short-functions.js
// 1. Shorter function syntax.
//
// This version does not respect "Tennent's correspondence principle" -- it's nothing
// more than syntactic sugar for the traditional function syntax. That means when you
// see the normal braced body of a function, whether it's a longhand function or this
// shorthand version, there's no difference: return, this, and arguments are all tied
// to the new function body, and there's no implicit returning of the last expression
// result.
a.some((x) -> {
@dherman
dherman / functions.js
Created Jul 29, 2012
Function utilities
View functions.js
(function(Fp, Ap) {
var applyMethod = Fp.apply,
bindMethod = Fp.bind,
callMethod = Fp.call;
var sliceMethod = Ap.slice,
concatMethod = Ap.concat;
var apply = callMethod.bind(applyMethod),
bind = callMethod.bind(bindMethod),
@ramainen
ramainen / alc.md
Created Jan 21, 2012
Конспект по RBAC и ACL
View alc.md

Конспект по RBAC и ACL

Данный текст - мой набросок после филтрации огромного количества текстов.

По работе стоит задача реализации системы распределения прав. Дабы не строить велосипед, решил посмотреть в CI, Yii, Zend, и так далее. В итоге выяснилось, что даже именитые библиотеки вроде Zend_Acl не решают даже части проблем.

Для того, чтобы не держать в закладках уйму текста, было решено составить этот конспект. Если Вы случайно наткнулись на этот текст, и у Вас есть вопросы, мысли или предложения -

@substack
substack / how_i_write_tests_for_node_and_the_browser.markdown
Last active Sep 15, 2021
how I write tests for node and the browser
View how_i_write_tests_for_node_and_the_browser.markdown

In node I use simple test libraries like tap or tape that let you run the test files directly. For code that needs to run in both the browser and node I use tape because tap doesn't run in the browser very well and the APIs are mostly interchangeable.

The simplest kind of test I might write in test/ looks like:

var test = require('tape');
var someModule = require('../');

test('fibwibblers and xyrscawlers', function (t) {
    t.plan(2);