Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Nikita Dudnik Nek

🎯
Focusing
View GitHub Profile
@Nek
Nek / cors-nginx.conf
Created May 23, 2012 — forked from michiel/cors-nginx.conf
Wide-open CORS config for nginx
View cors-nginx.conf
#
# 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
Animatron "I thought it would work" list
View broken_nostroke.js
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 Jun 19, 2012
Animatron player contains examples
View contains1.js
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 Jun 22, 2012
Useful fish shell functions for OS X Lion.
View pfdir.fish
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 Jun 22, 2012 — forked from soemarko/theme.html
embed github gist to tumblr
View theme.html
<!-- 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 Jun 29, 2012
Strange builder behaviour
View builderbug.js
return b()
.add(
b("thing")
.rect([0,0], [100,50])
.text([100,100], "Start Game", 26, "Arial"));
@Nek
Nek / EasyLambda.hx
Created Jul 16, 2012
Declare lambda functions easily (Haxe 2.10).
View EasyLambda.hx
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;
View water.js
$.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 Jul 26, 2012
Simple server on node.js
View serv.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 Jul 27, 2012
keywords replacement in emacs
View snippet.el
;; 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\\) "
You can’t perform that action at this time.