CRUD = Create, Read, Update, Delete
$host = '127.0.0.1';
$dbname = 'test';
$username = 'root';
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works | |
const axios = require('axios'); // promised based requests - like fetch() | |
function getCoffee() { | |
return new Promise(resolve => { | |
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee | |
}); | |
} |
Validation Errors and Rollback | |
A common use case is to rollback a transaction if there are validation errors. For example consider this service: | |
import grails.validation.ValidationException | |
class AuthorService { | |
void updateAge(id, int age) { | |
def author = Author.get(id) | |
author.age = age | |
if (!author.validate()) { |
git shortlog -e -s -n |
This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.
Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).
def (a,b,rest) = [0, 1, 2..-1].collect { [1,2,3,4][it] } | |
assert a == 1 | |
assert b == 2 | |
assert rest == [3,4] |
<html> | |
<head> | |
<script type="text/javascript" src="/jquery.min.js"></script> | |
<title>Mime type checker</title> | |
<script> | |
$(function () { | |
var result = $('div#result'); | |
if (window.FileReader && window.Blob) { | |
$('span#submit').click(function () { | |
var files = $('input#file').get(0).files; |
# Backup | |
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql | |
# Restore | |
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE | |