Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Volkov vol4ok

View GitHub Profile
@vol4ok
vol4ok / echoHttpRequest.js
Last active Aug 29, 2015 — forked from Marak/echoHttpRequest.js
Echo HTTP requests
View echoHttpRequest.js
module['exports'] = function echoHttp (hook) {
hook.debug("Debug messages are sent to the debug console");
hook.debug(hook.params);
hook.debug(hook.req.path);
hook.debug(hook.req.method);
@vol4ok
vol4ok / gist:fc094e5f95ea5c89c5bb
Last active Aug 29, 2015
route all to angular grunt config
View gist:fc094e5f95ea5c89c5bb
var modRewrite = require('connect-modrewrite');
//...
// initConfig -> Connect section
livereload: {
options: {
open: true,
base: [
'.tmp',
@vol4ok
vol4ok / gist:9364446
Last active Aug 29, 2015
on ng-repeat finish directive for angular js
View gist:9364446
angular.module("app").directive("onRepeatFinish", ["$timeout", function($timeout){
return {
restrict: "A",
link: function($scope, $element, $attrs) {
if ($scope.$last) {
$timeout(function(){
if (angular.isFunction($scope[$attrs["onRepeatFinish"]]))
$scope[$attrs["onRepeatFinish"]]()
});
}
View gist:8555531
mkdir output
i=1
for f in *.jpg *.JPG
do
echo "$f -> photo-$i.jpg"
cp "$f" photo-$i.jpg
gm mogrify -resize 1920x1920 photo-$i.jpg
jpegtran -outfile output/photo-$i.jpg -copy none -optimize -perfect photo-$i.jpg
rm photo-$i.jpg
(( i++ ))
@vol4ok
vol4ok / drv_mgr.c
Created Aug 20, 2013
Driver manager module. Allow to load, start, stop and unload driver on all version of Windows
View drv_mgr.c
#include <windows.h>
#include "drv_mgr.h"
SC_HANDLE install_driver(const wchar_t *name, const wchar_t *path)
{
SC_HANDLE h_scm;
SC_HANDLE h_svc = INVALID_HANDLE_VALUE;
if (!path || !name)
return INVALID_HANDLE_VALUE;
@vol4ok
vol4ok / _linear-gradient.scss
Created Jul 31, 2013
linear-gradient mixin for scss
View _linear-gradient.scss
@mixin linear-gradient($from, $to) {
background: $from;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0, $from), color-stop(1, $to));
background: -webkit-linear-gradient(top, $from, $to);
background: -moz-linear-gradient(top, $from, $to);
background: -ms-linear-gradient(top, $from, $to);
background: -o-linear-gradient(top, $from, $to);
background: linear-gradient(top, bottom, $from, $to);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$from}', endColorstr='#{$to}');
-ms-filter: quote(progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$from}', endColorstr='#{$to}'));
@vol4ok
vol4ok / gist:5727997
Created Jun 7, 2013
share local server to remote server via ssh
View gist:5727997
LOCAL_PORT = 3333
REMOTE_PORT = 2222
SSH_USER_HOST = "foo@var.com"
express = require "express"
{spawn} = require "child_process"
ssh = spawn('ssh', ['-N', '-R', "#{REMOTE_PORT}:localhost:#{LOCAL_PORT}", SSH_USER_HOST])
app = express()
@vol4ok
vol4ok / gist:5487093
Created Apr 30, 2013
Show the List of Installed Packages on Ubuntu or Debian and find the locations
View gist:5487093
dpkg --get-selections
dpkg -L <pkg-name>
View translit.coffee
String::translit = (->
L =
"А": "A", "а": "a", "Б": "B", "б": "b", "В": "V", "в": "v"
"Г": "G", "г": "g", "Д": "D", "д": "d", "Е": "E", "е": "e"
"Ё": "Yo", "ё": "yo", "Ж": "Zh", "ж": "zh", "З": "Z", "з": "z"
"И": "I", "и": "i", "Й": "Y", "й": "y", "К": "K", "к": "k"
"Л": "L", "л": "l", "М": "M", "м": "m", "Н": "N", "н": "n"
"О": "O", "о": "o", "П": "P", "п": "p", "Р": "R", "р": "r"
"С": "S", "с": "s", "Т": "T", "т": "t", "У": "U", "у": "u"
"Ф": "F", "ф": "f", "Х": "H", "х": "h", "Ц": "Ts", "ц": "ts"
View gist:5346163
{
"working_dir": "${project_path}",
"path": "C:\\Program Files\\nodejs;C:\\Users\\<USER_NAME>\\AppData\\Roaming\\npm",
"cmd": ["grunt", "--no-color"],
"shell": true
}