Skip to content

Instantly share code, notes, and snippets.

View vprimachenko's full-sized avatar

Valerij Primachenko vprimachenko

View GitHub Profile
@vprimachenko
vprimachenko / code-cat.js
Created September 18, 2013 14:56
use highlight.js in the cosole
var hljs = require('highlight.js');
var high = hljs.highlight('cpp', 'void main<>(){return true;}').value;
high = high.replace(/<\/span>/g,'\x1b[0m');
high = high.replace(/<span class="([a-z]+)">/g,function (match,p1) {
return {
'keyword':'\x1b[32m',
'types':'\x1b[34m',
'number':'\x1b[33m',
'consts':'\x1b[37m'
}[p1];
@vprimachenko
vprimachenko / rainbow.js
Created September 11, 2013 13:52
rainbows in console via node
c = [41,43,42,46,44,45,41];
var rainbow = '';
for(var i=0; i<6;i++) {
rainbow += '\x1B['+c[i]+'m';
rainbow += '\x1B['+(c[i+1]-10)+'m';
rainbow += ' ';
rainbow += '\x1B['+c[i]+'m';
rainbow += '\x1B['+(c[i+1]-10)+'m';
rainbow += '░';
rainbow += '\x1B['+c[i+1]+'m';
@vprimachenko
vprimachenko / keydown.js
Created September 10, 2013 01:07
angular.js keyevents for everywhere
.directive('onKeydown', ['$parse',function($parse) {
return function(scope, elm, attrs) {
var keydownFn = $parse(attrs.onKeydown);
elm.bind("keydown", function(event) {
scope.$apply(function(){
keydownFn(scope, { '$event': event });
});
});
};
}]);
@vprimachenko
vprimachenko / Main.sublime-menu
Created March 23, 2013 13:16
really simple and hacky autoupdater for sublime text 3
[
{
"id": "help",
"children":
[
{
"caption": "Update",
"command": "auto_update",
}
]
@vprimachenko
vprimachenko / comment-precompiler.c
Created December 4, 2012 20:58
#ifdef #else #endif with comments only: compatible with every language with // and /**/ comments
/*
code1();
/*/
code2();
/**/
add a slash to flip the switch
//*
code1();
@vprimachenko
vprimachenko / .js.bat
Created December 4, 2012 20:54
windows hashbang to execute .js.bat files
rem = 'by valerij primachenko';/*
node %0
pause
exit
*/
require('node_magic');