Skip to content

Instantly share code, notes, and snippets.

Kestutis Stalmokas stalmok

  • Vancouver, Canada
Block or report user

Report or block stalmok

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
stalmok / flatten.js
Created Feb 11, 2019
Flatten an array of arbitrarily nested arrays of integers into a flat array of integers
View flatten.js
* 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
View nginx.config
content: |
server_tokens off;
client_max_body_size 2M;
content: |
map $http_upgrade $connection_upgrade {
default "upgrade";
stalmok / sync-directory
Created Feb 8, 2013
Synchronize directories. With `-n` files aren't actually moved - just prints the expected output of the operation.
View sync-directory
rsync -n -u --stats --progress /home/user/test/1/* /home/user/test/2/
stalmok /
Last active Dec 11, 2015 — forked from rik/
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"
stalmok / strip-whitespace.js
Created Jan 6, 2013
JavaScript: Strip Whitespace From String
View strip-whitespace.js
// 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
stalmok / nginx-check-conf
Created Dec 21, 2012
Nginx: test configuration
View nginx-check-conf
nginx -t -c /etc/nginx/nginx.conf
stalmok / restrict-access
Created Dec 5, 2012
Restrict user access to content in folders using PHP and Apache
View restrict-access
* Original post:
# The .htaccess file
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^\/(path\/to\/some\/folder|dummy)\/.*$
RewriteRule !^((.*.php)|(.*\/))$ authorize.php
stalmok / sql-replace-string
Created Nov 12, 2012
MySQL: replace string and update
View sql-replace-string
// replace string and update
update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');
stalmok / clear_cache.php
Created Nov 8, 2012
Drupal: clear cache
View clear_cache.php
stalmok / mysql-import
Created Oct 29, 2012
MySQL: Import Datafile
View mysql-import
mysql -u username -p -h localhost DATA-BASE-NAME < data.sql
You can’t perform that action at this time.