Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
// assignment in function parameters | |
function sum1 ({Array: numbers}) { | |
let total = 0; // let {Number: total} = 0; would also be fine | |
let i = numbers.length; | |
while (i--) { | |
let {Number: n} = numbers[i]; | |
total += n; | |
} | |
/* | |
* This work is free. You can redistribute it and/or modify it under the | |
* terms of the Do What The Fuck You Want To Public License, Version 2, | |
* as published by Sam Hocevar. See the COPYING file for more details. | |
*/ | |
/* | |
* Easing Functions - inspired from http://gizma.com/easing/ | |
* only considering the t value for the range [0, 1] => [0, 1] | |
*/ | |
EasingFunctions = { |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
List some crypto libraries for JavaScript out there. Might be a bit out dated. Scroll to the bottom.
http://www.w3.org/TR/WebCryptoAPI/
This specification describes a JavaScript API for performing basic cryptographic operations in web applications, such as hashing, signature generation and verification, and encryption and decryption. Additionally, it describes an API for applications to generate and/or manage the keying material necessary to perform these operations. Uses for this API range from user or service authentication, document or code signing, and the confidentiality and integrity of communications.
Please see the original article for a full explanation. Please feel free to comment, question and criticize there as well!
Requires https://www.npmjs.com/package/simple-free-encryption-tool
'use strict'; | |
const crypto = require('crypto'); | |
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters) | |
const IV_LENGTH = 16; // For AES, this is always 16 | |
function encrypt(text) { | |
let iv = crypto.randomBytes(IV_LENGTH); | |
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv); |
Mobile Safari does not support position: fixed
when an input focused and virtual keyboard displayed.
To force it work the same way as Mobile Chrome, you have to use position: absolute
, height: 100%
for the whole page or a container for your pseudo-fixed elements, intercept scroll
, touchend
, focus
, and blur
events.
The trick is to put the tapped input control to the bottom of screen before it activates focus. In that case iOS Safari always scrolls viewport predictably and window.innerHeight
becomes exactly visible height.
Open https://avesus.github.io/docs/ios-keep-fixed-on-input-focus.html in Mobile Safari to see how it works.
Please avoid forms where you have several focusable elements because more tricks to fix position will be necessary, those were added just for demonstration purposes.
let elliptic = require('elliptic'); | |
let sha3 = require('js-sha3'); | |
let ec = new elliptic.ec('secp256k1'); | |
// let keyPair = ec.genKeyPair(); | |
let keyPair = ec.keyFromPrivate("97ddae0f3a25b92268175400149d65d6887b9cefaf28ea2c078e05cdc15a3c0a"); | |
let privKey = keyPair.getPrivate("hex"); | |
let pubKey = keyPair.getPublic(); | |
console.log(`Private key: ${privKey}`); | |
console.log("Public key :", pubKey.encode("hex").substr(2)); |