Skip to content

Instantly share code, notes, and snippets.

View bdombro's full-sized avatar

Brian Dombrowski bdombro

View GitHub Profile
@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
@bdombro
bdombro / streamFilter.js
Created April 21, 2020 22:50
Easy stream filters for, say, file read streams/pipes
/**
* Easy stream filters for, say, file read streams/pipes
*/
const stream = require('stream')
class StreamFilter extends stream.Transform {
constructor(filterCallback) {
super({
readableObjectMode: true,
@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.
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 / 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
#!/usr/bin/php -q
<?php
// CUSTOM: Increase memory limit to improve likelyhood of success
ini_set('memory_limit','500M');
/**
* To run this script, execute something like this:
* `./srdb.cli.php -h localhost -u root -n test -s "findMe" -r "replaceMe"`
* use the --dry-run flag to do a dry run without searching/replacing.
@bdombro
bdombro / gist:f45dc7e16f2ed821d2c5d271302c38ce
Created May 24, 2018 18:40
Timeout - Run process and kill if it runs too long.
#!/bin/bash
# Src: http://www.ict.griffith.edu.au/anthony/software/timeout.sh
#
# timeout [-SIG] [time] [--] command args...
#
# Run the given command until completion, but kill it if it runs too long.
# Specifically designed to exit immediatally (no sleep interval) and clean up
# nicely without messages or leaving any extra processes when finished.
#
@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;