Skip to content

Instantly share code, notes, and snippets.

View bdombro's full-sized avatar

Brian Dombrowski bdombro

View GitHub Profile
@bdombro
bdombro / crypt_unlock.sh
Last active October 15, 2020 15:45 — forked from gusennan/crypt_unlock.sh
initramfs-hook for unlocking LUKS-encrypted LVM partition
#!/bin/sh
# Part of https://www.pbworks.net/ubuntu-guide-dropbear-ssh-server-to-unlock-luks-encrypted-pc/
# Is a copy of https://gist.github.com/gusennan/712d6e81f5cf9489bd9f
PREREQ="dropbear"
prereqs() {
echo "$PREREQ"
}
ID="shhh"
SECRET="shhh"
# Note the -n!!!
AUTH=`echo -n "$ID:$SECRET" | base64`
echo AUTH
@bdombro
bdombro / git-squash.sh
Last active July 16, 2020 17:09
Squash a git branch in one step
#!/bin/bash
set -e
###
# Squash method based on https://stackoverflow.com/a/25357146/1202757
###
if [ "$#" -ne 2 ]; then
echo "USAGE: \``basename "$0"` \"<branch to base from>\" \"<Commit message>\"\`"
exit 1
handleValidSubmit = async (event: any, values: {title: string; description: string; file: any}) => {
const {currentUser} = this.props.mobx;
if (this.state.loading) {
console.log("Submit ignored because loading.");
return;
}
this.setState({loading: true});
try {
@bdombro
bdombro / form-input-story.jsx
Created November 19, 2019 16:21
form-input-story.jsx
import React from 'react';
import { styled } from '@storybook/theming';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { Input, Button, Select, Textarea } from './input/input';
import { Field } from './field/field';
import { Spaced } from '../spaced/Spaced';
const Flexed = styled.div({ display: 'flex' });
@bdombro
bdombro / tsxify-svg.sh
Last active August 13, 2019 13:01
tsxify-svg.sh
#!/usr/bin/env bash
# Will create a tsx version of an svg file. Skips if dest exists.
#
# To run in batch, use
# `find src -name "*.svg" -exec ./utils/tsxify-svg.sh {} \;`
# or with dest dir
# # `find src -name "*.svg" -exec ./utils/tsxify-svg.sh {} src/components/icons \;`
#
# Note that $SED syntax is different on OSX, so install linux sed with homebrew first.
@bdombro
bdombro / fetch-graphql.jsx
Last active September 27, 2018 02:34
fetch-graphql.jsx - Run a simple GraphQL Query using isomorphic-fetch
/**
* Run a GraphQL Query using isomorphic-fetch
*/
const HTTP_BAD_REQUEST = 400
const endpoint = "https://api.graph.cool/simple/v1/cj9g48vlm79hy0120m4tvigm9"
let fetchGraphQLCache = [];
export default (query, callback) => {
@bdombro
bdombro / mysql-drop-all-tables.sql
Created September 10, 2018 22:03
mysql-drop-all-tables.sql
SET FOREIGN_KEY_CHECKS = 0;
SET @tables = NULL;
SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
FROM information_schema.tables
WHERE table_schema = 'database_name'; -- specify DB name here.
SET @tables = CONCAT('DROP TABLE ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
@bdombro
bdombro / git-change-origin-url.sh
Created September 7, 2018 20:21
Git Change Origin URL
cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.com:bdombro/test.git
git push -u origin --all
git push -u origin --tags
@bdombro
bdombro / nginx-pm2-reverse-proxy-with-caching.conf
Last active July 20, 2018 22:20
NGINX PM2 Reverse Proxy with Caching
# Note: if using cloudfare, you MUST add a http redirect rule in cloudflare or
# cf will cache the 301 redirect for both HTTP AND HTTPS, causing an infinite 301 loop
# Ex rule: http://*domain.dev/* with action Always Use HTTPS
# Ref: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04
proxy_cache_path /var/cache/nginx/aii.globalintegrity.org_proxy levels=1:2 keys_zone=aii.globalintegrity.org_proxy:10m max_size=187108864 inactive=7d use_temp_path=off;
server {
listen 80;