Skip to content

Instantly share code, notes, and snippets.

View stalmok's full-sized avatar

Kestutis Stalmok stalmok

  • Vancouver, Canada
View GitHub Profile
@stalmok
stalmok / jpegtran-directory.sh
Last active December 11, 2015 04:39 — forked from rik/jpegtran-directory.sh
Bash: Optimize .jpg images
#!/usr/bin/env bash
function optimize
{
echo $1
filesize=`stat --format=%s "$1"`
if [[ $filesize -lt 10000 ]]; then
jpegtran -copy none -optimize "$1" > "$1.bak"
echo "pet"
else
@stalmok
stalmok / sync-directory
Created February 8, 2013 14:50
Synchronize directories. With `-n` files aren't actually moved - just prints the expected output of the operation.
rsync -n -u --stats --progress /home/user/test/1/* /home/user/test/2/
@stalmok
stalmok / nginx.config
Last active May 22, 2017 14:24
ebs-meteor
files:
"/etc/nginx/conf.d/custom_config.conf":
content: |
server_tokens off;
client_max_body_size 2M;
"/etc/nginx/sites-available/elasticbeanstalk-nginx-docker-proxy.conf":
content: |
map $http_upgrade $connection_upgrade {
default "upgrade";
@stalmok
stalmok / prevent-text-breakouts.css
Created August 14, 2012 05:38
CSS: Prevent Long URL’s From Breaking Out of Container
.prevent-text-breakouts {
-ms-word-break: break-all;
word-break: break-all;
word-break: break-word;
-webkit-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
@stalmok
stalmok / flatten.js
Created February 11, 2019 01:34
Flatten an array of arbitrarily nested arrays of integers into a flat array of integers
/**
* Code was written in Javascript (ES6)
* Tests will work only in Node.js environment
*/
/**
* Flatten an array of arbitrarily nested arrays of integers into
* a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
*
* @param {Array} input
@stalmok
stalmok / strip-whitespace.js
Created January 6, 2013 16:51
JavaScript: Strip Whitespace From String
// http://css-tricks.com/snippets/javascript/strip-whitespace-from-string/
// Remove leading and trailing whitespace
// Requires jQuery
var str = " a b c d e f g ";
var newStr = $.trim(str);
// "a b c d e f g"
// Remove leading and trailing whitespace
// JavaScript RegEx