Skip to content

Instantly share code, notes, and snippets.

@nickscript0
nickscript0 / async_hello_world.py
Last active November 6, 2015 13:36
TypeError with async await syntax compared to equivalent @asyncio.coroutine syntax
"""
Was running into the following error with the new async await syntax, where the equivalent @asyncio.coroutine did not give an error.
But this has since resolved, liekly due to an import problem or library version:
...
loop.run_until_complete(hello_world())
File "/usr/local/lib/python3.5/site-packages/asyncio-3.4.3-py3.5.egg/asyncio/base_events.py", line 296, in run_until_complete
future = tasks.async(future, loop=self)
File "/usr/local/lib/python3.5/site-packages/asyncio-3.4.3-py3.5.egg/asyncio/tasks.py", line 516, in async
raise TypeError('A Future or coroutine is required')

Keybase proof

I hereby claim:

  • I am nickscript0 on github.
  • I am nickscript0 (https://keybase.io/nickscript0) on keybase.
  • I have a public key ASDVmINbkT5Bkt1i6E5r2EFd9lcvw7R9OTQbq6dhikhBwAo

To claim this, I am signing this object:

@nickscript0
nickscript0 / crypto-bruteforce-estimates.md
Last active January 28, 2018 17:53
Security level of modern encryption algorithms
@nickscript0
nickscript0 / letsencrypt_security.md
Last active February 4, 2018 00:22
Let's Encrypt Cert and Key Security information
  • Why it's acceptable for Let's Encrypt's root to be sha-1 signed and why root certificates are exempt from SHA1 sunsetting: https://community.letsencrypt.org/t/sha-1-signed-certificate-in-chain/24897/2
  • Currently Let’s Encrypt only signs end-entity certificates with RSA intermediates. Let’s Encrypt will generate an ECDSA root and intermediates [in the future] which can be used to sign end-entity certificates [ref].
    • The benefit of an ECDSA authentication key (over RSA) is speed.
    • RSA don't scale very well as you increase bit size compared to ECDSA [ref: Section 1.1]
  • You should only support suites that use ECDHE and DHE as they offer Perfect Forward Secrecy. How to read a cipher suite [ref]:
    TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
    ---------------------------------------
    TLS -
    
@nickscript0
nickscript0 / promisified_node_fs.ts
Created February 17, 2018 18:45
Typescript Promisified nodejs fs functions
// promisified fs.writeFile
export function writeFile(filename, data): Promise<void> {
return new Promise<void>((resolve, reject) =>
fs.writeFile(filename, data, (err) => (err) ? reject(err) : resolve())
);
}
// promisified fs.readFile
function readFile(filename): Promise<string> {
return new Promise<string>((resolve, reject) =>
@nickscript0
nickscript0 / typescript_cheatsheet.md
Last active April 29, 2018 03:58
Typescript Cheatsheet
@nickscript0
nickscript0 / vsc_user_settings.json
Created February 20, 2018 23:18
My Visual Studio Code User Settings
// Place your settings in this file to overwrite the default settings
{
"window.zoomLevel": 0,
"typescript.referencesCodeLens.enabled": false,
"editor.cursorBlinking": "solid",
"editor.minimap.enabled": false,
"workbench.colorCustomizations": {
"editor.lineHighlightBackground": "#585a6941"
}
}
@nickscript0
nickscript0 / kill_sticky_headers.js
Created August 13, 2018 13:45
Kill Sticky Headers - Updated Version
// Updated the original to include the new 'sticky' style in addition to 'fixed' https://alisdair.mcdiarmid.org/kill-sticky-headers/
// Note to run this as a Chrome bookmark paste it in the URL field, prefixed with: javascript:
(function () {
var i, elements = document.querySelectorAll('body *'); for (i = 0; i < elements.length; i++) {
if (["sticky", "fixed"].includes(getComputedStyle(elements[i]).position)) {
elements[i].parentNode.removeChild(elements[i]);
}
}
}
)();
@nickscript0
nickscript0 / date-fns-migrate.js
Last active October 2, 2021 02:33
How to migrate from moment.js to date-fns (as the package is way smaller)
/**
* date-fns v2 is still in alpha, but has built-in Typescript support so best to use it:
* Docs: https://date-fns.org/v2.0.0-alpha.16/docs/Getting-Started
*
* npm install --save date-fns@next
*/
// Useful functions to import
import { formatDistanceStrict, isAfter, isBefore, format, subDays, isSameDay } from 'date-fns';