Skip to content

Instantly share code, notes, and snippets.

@petejodo
petejodo / errors.rs
Last active January 16, 2019 06:01
Rust Tide Error Handling Example
use std::error;
use std::fmt;
use http::StatusCode;
use serde::Serializer;
use serde_derive::Serialize;
use tide::{body::Json, IntoResponse, Response};
#[derive(Debug, Serialize)]
#[serde(tag = "type", content = "message")]
@petejodo
petejodo / utils.rs
Created January 9, 2019 02:44
Rust Salts and Password Hashing
use lazy_static::lazy_static;
use ring::rand::{SecureRandom, SystemRandom};
lazy_static! {
static ref RANDOM: SystemRandom = {
let rng = SystemRandom::new();
let mut warming_salt: Vec<u8> = vec![0; 8];
rng.fill(&mut warming_salt)
.expect("Failure to initialize with warming salt");
rng
@petejodo
petejodo / javascript.json
Last active November 7, 2018 15:59
React/Relay w. Flow VSCode snippets
{
"React Flow Functional Component": {
"prefix": "rffc",
"body": [
"// @flow",
"",
"import * as React from 'react';",
"",
"type Props = {",
"\t${1:children: React.Node,}",
@petejodo
petejodo / keybase.md
Created October 10, 2017 03:04
keybase.md

Keybase proof

I hereby claim:

  • I am petejodo on github.
  • I am pjode (https://keybase.io/pjode) on keybase.
  • I have a public key ASBCdgID_cfib46Pbf9by-assJbqF6pes1kRoLYJlTzLVQo

To claim this, I am signing this object:

@petejodo
petejodo / MyComponent.jsx
Created September 21, 2017 16:37
Merge Theme React HOC using Flow
// @flow
import React from 'react';
type MyComponentTheme = {
someClass: string
};
export type {MyComponentTheme as Theme};
@petejodo
petejodo / Button.js
Last active July 14, 2017 18:21
Inject Theme into Component
// @flow
import React from 'react';
import classNames from 'classnames';
type ButtonTheme = {
button: string,
small: string,
medium: string,
large: string
@petejodo
petejodo / SomeComponent.jsx
Last active October 4, 2016 15:26
Consistent style-providing HOCs
import React, { DOM } from 'react';
import { colorPrimary, colorPrimaryButton } from './style-hocs';
const PrimaryButton = colorPrimaryButton(DOM.button);
const PrimaryLink = colorPrimaryButton(DOM.link)
const PrimaryComponent = colorPrimary(AnotherComponent);
export const SomeComponent = props => (
<div>
<PrimaryButton>A primary button</PrimaryButton>