Skip to content

Instantly share code, notes, and snippets.

View markbrown4's full-sized avatar

Mark Brown markbrown4

View GitHub Profile
@markbrown4
markbrown4 / rsa-key-pairs.rb
Created October 25, 2019 01:16
RSA Key Pair signing in Ruby
data = 'hello'
# generate signature and public key
private_key = OpenSSL::PKey::RSA.new(2048)
signature = private_key.sign(OpenSSL::Digest::SHA256.new, data)
public_key = private_key.public_key
# verify signature with public key
rsa_key = OpenSSL::PKey::RSA.new(public_key.to_pem)
rsa_key.verify(OpenSSL::Digest::SHA256.new, signature, data)
@markbrown4
markbrown4 / read-write.js
Created January 8, 2019 22:21
Read / write access in Flow
// @flow
// read / write access
type ReadWriteType = {
+readOnly: number | string,
-writeOnly: string
};
function test(obj: ReadWriteType) {
const read = obj.readOnly;

I'm trying to write a program that replaces a scss function call and doubles the input e.g.

input

.color {
  margin: spacing(1.5);
}

.test {
@markbrown4
markbrown4 / middleware.js
Last active November 24, 2017 09:51
simple express-like middleware
class Middleware {
constructor () {
this.stack = []
}
use (fn) {
this.stack.push(fn)
}
go (next, remaining = this.stack.slice()) {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style media="screen">
body {
font-family: sans-serif;
line-height: 1.15;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style media="screen">
@font-face {
font-family: "San Francisco";
font-weight: 200;
src: url("https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-thin-webfont.woff");
@markbrown4
markbrown4 / webpack.config.js
Created February 3, 2017 14:05
webpack-demo
const webpack = require('webpack')
const path = require('path')
const extractCommons = new webpack.optimize.CommonsChunkPlugin({
name: 'commons',
filename: 'commons.js'
})
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const extractCSS = new ExtractTextPlugin('[name].bundle.css')
@markbrown4
markbrown4 / install.sh
Last active November 11, 2016 09:29
setup dev machine
Software Updates
App Store -> Xcode
launch xCode
xcode-select --install
defaults write NSGlobalDomain KeyRepeat -int 0
defaults write com.apple.finder AppleShowAllFiles YES
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
var eggs = true
(function() {
console.log(eggs)
})
// => TypeError: true is not a function
const Todo = (props, send)=> {
const todo = props.todo
const index = props.index
return html`
<li>
<input
type="checkbox"
${todo.completed ? 'checked' : ''}
onchange=${(e)=> onChange(e, index)}