Skip to content

Instantly share code, notes, and snippets.

# Creating k to create r by Jimmy Song
def deterministic_k(self, z):
# RFC6979, optimized for secp256k1
k = b'\x00' * 32
v = b'\x01' * 32
if z > N:
z -= N
z_bytes = z.to_bytes(32, 'big')
secret_bytes = self.secret.to_bytes(32, 'big')
@irlnathan
irlnathan / Command, Option, & Shift Symbols in Unicode
Created June 29, 2016 14:45
Command, Option, & Shift Symbols in Unicode
⌘ – ⌘ – ⌘ – the Command Key symbol
⌥ – ⌥ – ⌥ – the Option Key symbol
⇧ – ⇧ – ⇧ – the Shift Key symbol
⎋ – ⎋ – ⎋ – the ESC Key symbol
⇪ – ⇪ – ⇪ – the Capslock symbol
⏎ – ⏎ – ⏎ – the Return symbol
⌫ – ⌫ – ⌫ – the Delete / Backspace symbo
@irlnathan
irlnathan / regularExpression.md
Last active March 18, 2016 21:09
Regular Expression Cheat Sheet

I'm documenting the .match() method for JavaScript, there are others.

  • / by itself indicates the beginning and the end of the regex
  • /^ combined with $/ means “ match the entire string” (rather than matching substrings that begin and/or end somewhere in the middle)
  • the i suffix is a modifier indicating that the match should be done in a case-insensitive manner
  • [a-z0-9\-] matches a character which is either a number, letter or dash (works for capital letters because of the i at the end
  • the + indicates the match one or more of whatever came before
  • if you put a caret (^) inside of the match expression capturer thingamajig, it reverses the meaning
module.exports = {
create: function(req, res) {
if (_.isEmpty(req.param('email')) || _.isEmpty(req.param('something else'))) {
return res.badRequest('An email address or something else is required!');
}
...
@irlnathan
irlnathan / index.js
Created December 27, 2015 18:43
Looking at the differences between EJS <%= %> and <%- %>
var EJS = require('ejs');
var fs = require('fs');
var http = require('http');
// Read File
fs.readFile(__dirname + '/my-view.ejs', 'utf8', function(err, template){
if (err) console.log(err);
// The local variables
// var person = 'Nikola Tesla';
@irlnathan
irlnathan / PageController.js
Created November 4, 2015 22:37
From chapter 12 of Sails in Action: complete tutorialDetail action (for now)
tutorialDetail: function(req, res) {
Tutorial.findOne(req.param('id')).exec(function(err, tutorial){
if (err) return res.negotiate(err);
if (!tutorial) return res.notFound();
// If not logged in set `me` property to `null` and pass the tutorial to the view
if (!req.session.userId) {
return res.view('tutorials-detail', {
me: null,
stars: tutorial.stars,
@irlnathan
irlnathan / TutorialController.js
Last active November 19, 2015 19:33
From chapter 12 of Sails in Action: complete createTutorial action
createTutorial: function(req, res) {
/*
__ __ _ _ _ _ _
\ \ / /_ _| (_)__| |__ _| |_(_)___ _ _
\ V / _` | | / _` / _` | _| / _ \ ' \
\_/\__,_|_|_\__,_\__,_|\__|_\___/_||_|
*/
@irlnathan
irlnathan / notFound.js
Created October 19, 2015 15:12
Option 2
/**
* 404 (Not Found) Handler
*
* Usage:
* return res.notFound();
* return res.notFound(err);
* return res.notFound(err, 'some/specific/notfound/view');
*
* e.g.:
* ```
@irlnathan
irlnathan / notFound.js
Created October 19, 2015 03:59
Part of chapter 11 of Sails in Action
options = (typeof options === 'string') ? { view: options } : options || {};
if (!req.session.userId) {
var me = null;
var locals = {
data: data,
me: me
};
@irlnathan
irlnathan / irl-mike-oct-15-2015--galaxy-cafe--detours.js
Created October 15, 2015 18:25
irl-mike-oct-15-2015--galaxy-cafe--detours :: Dealing with asynchronous "detours" using the ifThenFinally machine
// Approach #3 using ifThenFinally machine....
// var IfThen = require('machinepack-ifthen');
//
// ////////////////////////////////////////////////////////////
// // Customization:
// ////////////////////////////////////////////////////////////
// // If the user is logged in...
// IfThen.ifThenFinally({