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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>My Website</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body> | |
</body> | |
</html> |
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
function Page(urlhash) { | |
'use strict'; | |
this.hash = { | |
"value": urlhash, | |
"name": "" | |
} | |
} | |
Page.prototype.getHashName = function () { |
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
#to-top { | |
text-decoration: none; | |
color: white; | |
transition: color 0.15s ease, transform 0.5s ease; | |
position: fixed; | |
bottom: 2em; | |
right: 2em; | |
text-align: center; | |
padding: 0 0.5em; | |
} |
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
function lookupRecord(id, ...otherParams) { | |
return db.lookup( | |
"people-records", id, ...otherParams | |
); | |
} | |
function getSomeData() { | |
var someVals = [2,3]; | |
return [1,...someVals,4]; |
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
async function *getOrders(personId) { | |
var cursor = db.query( "orders", personId ); | |
do { | |
let record = await cursor.next(); | |
yield.record; | |
} while (!cursor.done); | |
} | |
async function printOrders(name) { | |
var person = await lookupPerson( name ); |
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 do expression when assigning variables | |
var x = do { | |
function foo() { | |
return ... | |
} | |
var a = 3 | |
foo(a * 7) | |
}; | |
// Use do expression with try-catch to capture errors when assigning variables |
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
// Create and enter new database | |
use scorecard | |
// Create new collection named "scorecards" within database "scorecard" | |
db.createCollection('scorecards'); | |
// Insert data into scorecards collection | |
db.scorecards.insert({ | |
"title": "Bacon Pancakes", | |
"players": [ |
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
$('#elementId').on('click keydown', function(e) { | |
// Respond to mouse click or enter | |
if (e.type == 'click' || (e.type == 'keydown' && e.keyCode == 13)) { | |
e.preventDefault(); | |
e.stopPropagation(); | |
// Do stuff... | |
} | |
// Respond to down arrow |
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
/** | |
* Shortcut for print_r or var_dump while debugging | |
* @param $value (optional) - value, of any type, to print (providing nothing will result in weird face) | |
* @param bool $vardump (optional) - specify if you prefer var_dump instead of print_r | |
**/ | |
function peep($value = " ˁ(⦿ᴥ⦿)ˀ ", $vardump = false) | |
{ | |
echo '<pre>'; | |
if ($vardump || (empty($value) && $value !== 0 && $value !== "0")) { | |
var_dump($value); |
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
/** | |
* A migration to remove ALL links from images on all wordpress posts | |
* Based on https://gist.github.com/cfxd/219f083465bb5b93fac8#file-remove_wp_selfies-php | |
**/ | |
function remove_linked_images() { | |
$all_ids = new WP_Query(array( | |
'post_type' => array('post'), // feel free to add custom post types here if necessary | |
'posts_per_page' => -1, | |
'post_status' => 'publish', | |
'fields' => 'ids' |
OlderNewer