Skip to content

Instantly share code, notes, and snippets.

function calc({
balance,
months,
percent,
cashbackPercent,
earnings,
spendings
}){
let totalIncome = 0;
let credit = 0;
@aromanyuk
aromanyuk / list_files_and_folders_in_one_line
Created October 13, 2016 09:32
Files and folders in current path print in 1 line
ls | xargs
pactl -- set-sink-volume 0 150%
0 - number of device(may be 1)
@aromanyuk
aromanyuk / find_in_files_grep
Created June 16, 2016 16:32
Find text in files recursively using grep
grep -rnw '/path/to/somewhere/' -e "pattern"
-r or -R is recursive,
-n is line number, and
-w stands match the whole word.
-l (lower-case L) can be added to just give the file name of matching files.
Along with these, --exclude or --include parameter could be used for efficient searching. Something like below:
grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
This will only search through the files which have .c or .h extensions. Similarly a sample use of --exclude:
grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern"
@aromanyuk
aromanyuk / uglify_folder_to_public.bash
Last active June 7, 2016 01:11
Use it in npm scripts
find public/js/* | xargs -I file ./node_modules/.bin/uglifyjs file -c -o file
//"uglify:js": "find public/js/* | xargs -I file uglifyjs file -c -o file"
@aromanyuk
aromanyuk / Makefile
Created April 14, 2016 21:51 — forked from srquinn21/Makefile
Frontend Development with Makefile
#==========================================================
# Environment/Configuration
#==========================================================
# For project consistency, its better to depend on npm binaries loaded locally than
# globally, so we add .node_modules/.bin to the path for shorthand references. This
# means you should add any binaries you need to "devDependencies" in package.json.
export PATH := ./node_modules/.bin/:$(PATH)
# Pull in the name and version from package.json. The name will default to "app" if not set.
@aromanyuk
aromanyuk / python_fib_loop.py
Last active February 27, 2016 19:10
Python fibonacci loop
def fibonacci(n):
foo = bar = 0
for _ in range(n - 1):
# print foo, bar
if foo == 0:
foo = foo + 1
continue
foo, bar = [foo + bar, foo]
return foo;
@aromanyuk
aromanyuk / wget_recursive_site_fetch.txt
Last active June 27, 2016 15:26
wget for recursive site fetch
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent http://example.org
--mirror – Makes (among other things) the download recursive.
--convert-links – convert all the links (also to stuff like CSS stylesheets) to relative, so it will be suitable for offline viewing.
--adjust-extension – Adds suitable extensions to filenames (html or css) depending on their content-type.
--page-requisites – Download things like CSS style-sheets and images required to properly display the page offline.
--no-parent – When recursing do not ascend to the parent directory. It useful for restricting the download to only a portion of the site.
-e robots=off - Ignore robots.txt rules
wget -mkEpnp -e robots=off http://example.org
let foo, bar, firstMethod, secondMethod;
foo = [];
foo.push({ value: 'ua', long: 'Ukraine' });
foo.push({ value: 'en', long: 'USA' });
foo.push({ value: 'uk', long: 'United Kingom' });
foo.push({ value: 'ca', long: 'Canada' });
foo.push({ value: 'de', long: 'Germany' });
bar = [];