Skip to content

Instantly share code, notes, and snippets.

View urbansky's full-sized avatar

Stefan Urbansky urbansky

View GitHub Profile
@urbansky
urbansky / keyboard.md
Last active July 25, 2016 06:37
Keyboard shortcuts
@urbansky
urbansky / inject.js
Created July 7, 2016 07:05
Inject JQuery to a page in ChromeDeveloper Tools
// run in console
// see: http://stackoverflow.com/questions/7474354/include-jquery-in-the-javascript-console
var script = document.createElement('script');script.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js";document.getElementsByTagName('head')[0].appendChild(script);
@urbansky
urbansky / letsencrypt.sh
Last active January 10, 2019 07:24
Let's encrypt for Ubuntu 14.04 on Apache
#
# From https://certbot.eff.org/#ubuntutrusty-apache
#
cd /usr/local/bin
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
./certbot-auto # Follow instruction
@urbansky
urbansky / collection.groovy
Last active August 30, 2017 06:29
Methods in groovy collections
assert "Found 2" == [1,2,3].findResult { it > 1 ? "Found $it" : null } // Return if not null
assert ["Found 2", "Found 3"] == [1,2,3].findResults { it > 1 ? "Found $it" : null }
assert 1*1*2*3 == [1,2,3].inject(1) { acc, val -> acc * val }
assert [2,4,6] == [1,2,3].collect { it * 2 }
assert [2,4] == [1,2,3,4].findAll { it % 2 == 0 }
@urbansky
urbansky / commands.sh
Last active January 18, 2017 13:55
Ubuntu commands
# Set the timezone
dpkg-reconfigure tzdata
# Add init script
# Ubuntu 14.04
update-rc.d tomcat defaults
# -------------------------
# Package manager
# -------------------------
@urbansky
urbansky / commands.sh
Last active June 29, 2016 11:41
CentOS commands
# Start|Stop network devices
# configuration in '/etc/sysconfig/network-scripts'
ifup eth0
ifdown eth0
service network start (start|stop|restart)
# Edit init-scripts
ntsysv
@urbansky
urbansky / git_common.sh
Last active August 29, 2016 19:12
common git parameter
# Show current branch
git status
# Change branch
git checkout branch_name
# Get all new remote branches
git fetch --all
@urbansky
urbansky / common.sql
Last active January 3, 2019 14:57
Most commonly used MySQL commands
-- Standard select
SELECT id, price FROM table_name;
-- Check not NULL
SELECT id, price FROM table_name WHERE consumer IS NOT NULL;
-- Update
UPDATE table_name SET price = 1;
@urbansky
urbansky / format date.js
Created May 31, 2016 13:43
Format a Javascript 'Date'-Object
// Use Moment.js
// see: http://momentjs.com/
moment().format("YYYY-MM-DD_HHmm") // '2016-05-31_1543'
@urbansky
urbansky / filter-string.js
Created May 31, 2016 12:23
Remove all special characters so a string can be used as valid filename
// Replace all special characters with empty string
var filename = stringToFilter.replace(/[^\w\s\-\.]/gi, '')
// ^ Negation
// \w alpha numeric
// \s spaces
// /gi search global and case insensitive