Skip to content

Instantly share code, notes, and snippets.

View Voronenko's full-sized avatar
turning coffee into code since late 90s

Vyacheslav Voronenko

turning coffee into code since late 90s
View GitHub Profile
@Voronenko
Voronenko / initdfs.sh
Created February 2, 2013 22:23
Initialize hadoop dfs
sudo -u hdfs hadoop fs -mkdir /tmp
sudo -u hdfs hadoop fs -chmod -R 1777 /tmp
sudo -u hdfs hadoop fs -mkdir /var
sudo -u hdfs hadoop fs -mkdir /var/lib
sudo -u hdfs hadoop fs -mkdir /var/lib/hadoop-hdfs
sudo -u hdfs hadoop fs -mkdir /var/lib/hadoop-hdfs/cache
sudo -u hdfs hadoop fs -mkdir /var/lib/hadoop-hdfs/cache/mapred
sudo -u hdfs hadoop fs -mkdir /var/lib/hadoop-hdfs/cache/mapred/mapred
sudo -u hdfs hadoop fs -mkdir /var/lib/hadoop-hdfs/cache/mapred/mapred/staging
@Voronenko
Voronenko / jspromise
Last active December 15, 2015 13:58
Pure javascript simplified promis http://jsfiddle.net/dpecos/HDbBa/e pattern
function Promise(promise) {
if (promise instanceof Promise) {
return promise;
} else {
// this is a new promise chain
this.callbacks = [];
}
}
Promise.prototype.then = function(callback_ok, callback_error) {
@Voronenko
Voronenko / SimpleFormatter.js
Created March 31, 2013 08:06
Simple javascript formatter. Supports tokens {{property}}, {{someobject.property}}, {{anotherobject.nestedobject.property}} Enjoy.
function fmt(tmpl, repls) {
var res = tmpl.replace(
/(?:\{\{|\%7B\%7B)(.*?)(?:\}\}|\%7D\%7D)/g,
function (m) {
return getPropertyFromVar(repls, m);
}
);
return res;
@Voronenko
Voronenko / .gitignore
Created June 7, 2013 14:17
GitIgnore for c# projects (Nuget packages are accepted)
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
[Bb]in/
[Oo]bj/
# mstest test results
TestResults
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
#!/bin/sh
sudo rm /var/lib/mongodb/mongod.lock 
sudo -u mongodb mongod -f /etc/mongodb.conf --repair

#Create bitbucket branch

##Create local branch

$ git checkout -b sync
Switched to a new branch 'sync'
$ git branch
  master
* sync
@Voronenko
Voronenko / get line-height of the HTML element
Created December 13, 2013 16:26
Reliable way to get line-height of the particular html element with JQuery
function dirty_lineheight_px(obj) {
$(obj).append("<div id='dirty_lineheight_px' style='position:absolute; visibility:hidden'>S</div>");
// measure
var temp_height = $('#dirty_lineheight_px').height();
// cut
$('#dirty_lineheight_px').remove();
return temp_height;
}
@Voronenko
Voronenko / git init submodules
Created January 3, 2014 18:22
This shell file can be used to re-checkout git submodules basing on .gitmodules file
#!/bin/bash
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' > tempfile
while read -u 3 path_key path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
read -p "Are you sure you want to delete $path and re-initialize as a new submodule? " yn
# 172.25.24.104 = your local ip address
ACCEPT loc:172.25.24.104 net tcp 9418
@Voronenko
Voronenko / dirty cmd string replace
Created March 12, 2014 16:07
This example copies Vagrantfile and fixes relative path in target file
@echo off
setlocal enabledelayedexpansion
set INTEXTFILE=.kitchen\kitchen-vagrant\default-precise32-vsdev\Vagrantfile
set OUTTEXTFILE=Vagrantfile
set SEARCHTEXT=../../../
set REPLACETEXT=
set OUTPUTLINE=
for /f "tokens=1,* delims=¶" %%A in ( '"type %INTEXTFILE%"') do (
SET string=%%A