Skip to content

Instantly share code, notes, and snippets.

View joduplessis's full-sized avatar
Brewing coffee.

Jo du Plessis joduplessis

Brewing coffee.
View GitHub Profile
@joduplessis
joduplessis / gitty
Last active August 22, 2019 17:10
A super convenient script to automate committing to repos. Simply say: gitty "Commit my stuff" to commit your changes to the current branch.
#!/bin/bash
branch=$(git branch | grep \* | cut -d ' ' -f2)
echo "Commit to '$branch', with message '$1'"
read -p "Wnat to continue? (y): " choice
if [ $choice == "y" ]; then
env -i
git add -A
@joduplessis
joduplessis / Andromeda.itermcolors
Created August 19, 2019 06:33
The excellent iTerm Andromeda color scheme. Keeping it here for backup.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.0</real>
@joduplessis
joduplessis / pk_reset.sql
Created August 13, 2019 09:18
PostgreSQL needs to have its Primary Key reset after a table is duplicated - otherwise it runs into the PK ID taken issue. Here's how to reset it to the next highest PK..
SELECT setval('TABLENAME_id_seq', (SELECT MAX(id) FROM "TABLENAME"));
-- Literally replace TABLENAME with your table name:
-- SELECT setval('foo_id_seq', (SELECT MAX(id) FROM "foo"));
@joduplessis
joduplessis / .htaccess
Created August 11, 2019 16:51
Angular .htaccess file
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
@joduplessis
joduplessis / rename.sh
Created August 2, 2019 09:54
Handy little script to rename files on MacOS (haven't tested on other *nix systems - but should work) in bulk.
#!/bin/bash
# Renames all SVG files & convert commas to underscores, etc
find . -type f -name "*.svg" -print0 | while IFS= read -r -d '' file; do
mv "$file" "$(echo $(echo "$file" | tr ',' '_' | tr -d ' '))"
done
@joduplessis
joduplessis / fonts.css
Last active October 28, 2019 06:42
WebPack config file that handles web-font export from a fonts.css import in your main project.
@font-face {
font-family: 'HKGrotesk';
src:url('../fonts/hkgrotesk-light.eot');
src:url('../fonts/hkgrotesk-light.eot?#iefix') format('embedded-opentype'),
url('../fonts/hkgrotesk-light.woff2') format('woff2'),
url('../fonts/hkgrotesk-light.woff') format('woff');
font-weight: 400;
font-style: normal;
@joduplessis
joduplessis / .htaccess
Created July 30, 2019 07:49
Rules for directing all subdomains to a folder (wildcard subdomains) - and exclude a specific subdomain, like dev.
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# Dev app sub domain masking
RewriteCond %{HTTP_HOST} ^dev\.yourdomain\.com$ [NC]
RewriteRule ^((?!dev/).*)$ /dev/$1 [L,NC]
@joduplessis
joduplessis / index.js
Created July 15, 2019 11:47
Get a list of all cards on a Trello board (the easy way).
document.querySelectorAll(".list-card-title").forEach(n => console.log(n.textContent.substring(4)))
@joduplessis
joduplessis / index.js
Created June 12, 2019 16:27
Simple example for using an async call within the useEffect hook in React (runs once on mount)
useEffect(() => {
(async () => {
const result = await new Promise((res, rej) => res("Pretty neat"))
})()
}, []) // <- [] is important: https://reactjs.org/docs/hooks-effect.html
@joduplessis
joduplessis / load.component.js
Created June 2, 2019 07:53
Nice simple React HOC for using Suspense with React Router's routes.
import React from 'react'
import LoadingComponent from 'loading.component'
export default (fn, props) => {
const Component = React.lazy(fn)
return <React.Suspense fallback={<LoadingComponent />}><Component {...props} /></React.Suspense>
}
/**
* Example usage: