This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.DateFormat | |
import java.text.SimpleDateFormat | |
TimeZone tz = TimeZone.getTimeZone("Europe/Berlin") // Change the timezone | |
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmX") // X is the timezone in ISO8601 | |
df.setTimeZone(tz) | |
String iso8601 = df.format(new Date()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Moment.js | |
// see: http://momentjs.com/ | |
moment().format("YYYY-MM-DD_HHmm") // '2016-05-31_1543' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Show current branch | |
git status | |
# Change branch | |
git checkout branch_name | |
# Get all new remote branches | |
git fetch --all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start|Stop network devices | |
# configuration in '/etc/sysconfig/network-scripts' | |
ifup eth0 | |
ifdown eth0 | |
service network start (start|stop|restart) | |
# Edit init-scripts | |
ntsysv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set the timezone | |
dpkg-reconfigure tzdata | |
# Add init script | |
# Ubuntu 14.04 | |
update-rc.d tomcat defaults | |
# ------------------------- | |
# Package manager | |
# ------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
OlderNewer