Skip to content

Instantly share code, notes, and snippets.

Serg Hospodarets malyw

Block or report user

Report or block malyw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@malyw
malyw / index.js
Last active May 10, 2019
Capture DOM element screenshot using Chrome headless
View index.js
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Adjustments particular to this page to ensure we hit desktop breakpoint.
page.setViewport({width: 1000, height: 600, deviceScaleFactor: 1});
await page.goto('https://www.chromestatus.com/samples', {waitUntil: 'networkidle'});
@malyw
malyw / Find unused SCSS variables
Last active Dec 28, 2017
Script finds all SCSS variables (e.g. $some_variable-NAME1) which are used in code only once (e.g. declaration or using variable from some framework). Tested on MAC and Linux.
View Find unused SCSS variables
#!/usr/bin/env bash
# HOW TO USE
# Save code to file
# Run as "SCRIPT_FILE_NAME SASS_DIRECTORY"
# e.g "./find_unused_variables.sh ./sass"
VAR_NAME_CHARS='A-Za-z0-9_-'
find "$1" -type f -name "*.scss" -exec grep -o "\$[$VAR_NAME_CHARS]*" {} ';' | sort | uniq -u
@malyw
malyw / delete-local-branches-except-the-current.sh
Last active May 2, 2017
Delete all the local Git branches except the current one
View delete-local-branches-except-the-current.sh
#!/usr/bin/env bash
git branch | grep -v (git rev-parse --abbrev-ref HEAD) | xargs git branch -D
@malyw
malyw / remove-merged-branches-to-the-current.sh
Last active May 2, 2017
Remove Git branches, which are merged to the current one (+ ability to exclude some of them)
View remove-merged-branches-to-the-current.sh
#!/usr/bin/env bash
# based on https://gist.github.com/schacon/942899
# list
git branch -r --merged | grep origin | grep -v '>' | grep -v master\* | grep -v release-\* | xargs -L1
# delete
git branch -r --merged | grep origin | grep -v '>' | grep -v master\* | grep -v release-\* | xargs -L1 | awk '{sub(/origin\//,"");print}' | xargs git push origin --delete
@malyw
malyw / .htaccess
Created Feb 15, 2017 — forked from darcyliu/.htaccess
Apache GZIP compression and Expires headers
View .htaccess
# BEGIN GZIP
# http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
<IfModule mod_deflate.c>
# Enabling Compression
SetOutputFilter DEFLATE
# Insert filters
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
@malyw
malyw / gist:f300a5f804f62e37392864ce2f0b733c
Created Dec 28, 2016
Push failed: Failed with error: unable to access 'https://github.com/USERNAME/REPO.git/': The requested URL returned error: 403
View gist:f300a5f804f62e37392864ce2f0b733c
https://help.github.com/articles/changing-a-remote-s-url/
$ vim .git/config
change:
https://github.com/USERNAME/OTHERREPOSITORY.git
to:
git@github.com:USERNAME/OTHERREPOSITORY.git
@malyw
malyw / killProcessByPort.js
Created Dec 18, 2016
Script takes the port as a param and tries to find and kill a process which is listening the port, e.g. `node killProcessByPort.js 8080`
View killProcessByPort.js
#!/usr/bin/env node
/**
* Script takes the port as a param and tries to find and kill a process
* which is listening the port
*
* Example of the script usage:
* node SCRIPT %PORT_NUMBER%
*/
@malyw
malyw / Native JavaScript promises API
Last active Sep 26, 2016
Description of the native JavaScript promises API with examples
View Native JavaScript promises API
// Current browser support for native promises: http://kangax.github.io/compat-table/es6/#Promise
// Article: http://www.html5rocks.com/en/tutorials/es6/promises/
// Polyfills:
// https://github.com/getify/native-promise-only
// https://github.com/jakearchibald/es6-promise
/*------------------------------ GET PROMISE ------------------------------*/
// N.B.: Promises pass only first argument to resolve/reject callbacks, others are ignored
function doSomething(){
return new Promise(function(resolve, reject) {
@malyw
malyw / clearport.sh
Last active Aug 5, 2016
Script to kill all the processes which established connection to the port.Usage: './checkport.sh 35729' (clear the livereload port)
View clearport.sh
#!/usr/bin/env bash
function terminate {
echo ':'$1
lsof -P | grep ':'$1 | awk '{print $2}' | xargs kill -9
}
terminate $1
You can’t perform that action at this time.