Skip to content

Instantly share code, notes, and snippets.

Avatar

Valerij Primachenko vprimachenko

View GitHub Profile
@vprimachenko
vprimachenko / code-cat.js
Created Sep 18, 2013
use highlight.js in the cosole
View code-cat.js
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 Sep 11, 2013
rainbows in console via node
View rainbow.js
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 Sep 10, 2013
angular.js keyevents for everywhere
View keydown.js
.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 Mar 23, 2013
really simple and hacky autoupdater for sublime text 3
View Main.sublime-menu
[
{
"id": "help",
"children":
[
{
"caption": "Update",
"command": "auto_update",
}
]
@vprimachenko
vprimachenko / comment-precompiler.c
Created Dec 4, 2012
#ifdef #else #endif with comments only: compatible with every language with // and /**/ comments
View comment-precompiler.c
/*
code1();
/*/
code2();
/**/
add a slash to flip the switch
//*
code1();
@vprimachenko
vprimachenko / .js.bat
Created Dec 4, 2012
windows hashbang to execute .js.bat files
View .js.bat
rem = 'by valerij primachenko';/*
node %0
pause
exit
*/
require('node_magic');