Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Nek's full-sized avatar
🏠
Working from home

Nikita Dudnik Nek

🏠
Working from home
View GitHub Profile
@Nek
Nek / cors-nginx.conf
Created May 23, 2012 17:42 — forked from michiel/cors-nginx.conf
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@Nek
Nek / broken_nostroke.js
Created May 30, 2012 18:40
Animatron "I thought it would work" list
var b = Builder._$, C = anm.C;
var fhsv = Builder.fhsv;
// canvas1
var scene1 = b().circle([0, 0], 20)
.fill(fhsv(1, .5, .5, 1))
.nostroke();
createPlayer('gameScreen', {'mode':C.M_DYNAMIC}).load(scene1);
@Nek
Nek / contains1.js
Created June 19, 2012 19:59
Animatron player contains examples
var circleOne = b('c1').circle([0, 0], 30)
.trans([0, 3], [[0, 200], [400, 200]]);
var handler = function (evt) {
console.log("SCENE CLICKED");
if (this.$.contains(evt.pos)) {
console.log("CIRCLE CLICKED");
}
};
circleOne.on(C.X_MCLICK, handler);
@Nek
Nek / pfdir.fish
Created June 22, 2012 16:52
Useful fish shell functions for OS X Lion.
function pfdir;
echo "tell application \"Finder\"
return POSIX path of (target of window 1 as alias)
end tell" | osascript ^/dev/null;
end;
@Nek
Nek / theme.html
Created June 22, 2012 17:09 — forked from soemarko/theme.html
embed github gist to tumblr
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
@Nek
Nek / builderbug.js
Created June 29, 2012 07:51
Strange builder behaviour
return b()
.add(
b("thing")
.rect([0,0], [100,50])
.text([100,100], "Start Game", 26, "Arial"));
@Nek
Nek / EasyLambda.hx
Created July 16, 2012 21:48
Declare lambda functions easily (Haxe 2.10).
import haxe.macro.Expr;
class EasyLambda {
@:macro public static function f(p:Expr, e:Expr) : Expr {
var res:Expr = macro function(a) {return $e;};
var params = macro $p;
var pname =
switch (params.expr) {
case EConst(i):switch (i) {
case CIdent(v): v;
default: null;
@Nek
Nek / water.js
Created July 18, 2012 08:19 — forked from anonymous/water.js
created for livecoding - http://livecoding.gabrielflor.it
$.ajaxSetup({
cache: true
});
var s1 = $.getScript('https://raw.github.com/Animatron/player/master/vendor/matrix.js');
var s2 = $.getScript('https://raw.github.com/Animatron/player/master/anm.player.js');
var s3 = $.getScript('https://raw.github.com/Animatron/player/master/anm.builder.js');
//var s4 = $.getScript('https://raw.github.com/Animatron/player/master/anm.collisions.js');
$.when( s1, s2, s3 ).then(function() {
@Nek
Nek / serv.js
Created July 26, 2012 20:20
Simple server on node.js
var http = require("http");
var fs = require("fs");
var path = require("path");
var url = require("url");
var mimeTypes = {
"html": "text/html",
"jpeg": "image/jpeg",
"jpg": "image/jpeg",
"png": "image/png",
@Nek
Nek / snippet.el
Created July 27, 2012 14:50
keywords replacement in emacs
;; Use lambda for anonymous functions
(font-lock-add-keywords
'js2-mode `(("\\(function\\) *("
(0 (progn (compose-region (match-beginning 1)
(match-end 1) "\u0192")
nil)))))
;; Use right arrow for return in one-line functions
(font-lock-add-keywords
'js2-mode `(("function *([^)]*) *{ *\\(return\\) "