Skip to content

Instantly share code, notes, and snippets.

View schmidt1024's full-sized avatar

Schmidt schmidt1024

View GitHub Profile
@schmidt1024
schmidt1024 / us-states.sql
Created May 13, 2021 08:09
SQL insert of us states incl. short codes
CREATE TABLE `common_us_states` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` char(2) NOT NULL DEFAULT '',
`name` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into common_us_states (code,name) values ('AL','Alabama');
insert into common_us_states (code,name) values ('AK','Alaska');
insert into common_us_states (code,name) values ('AS','American Samoa');
@schmidt1024
schmidt1024 / de-bundeslaender.sql
Created May 13, 2021 08:07
SQL insert of german states aka Bundesländer incl. short codes
CREATE TABLE `common_de_bundeslaender` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` char(2) NOT NULL DEFAULT '',
`name` varchar(30) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into common_de_bundeslaender (code,name) values ('BW','Baden-Württemberg');
insert into common_de_bundeslaender (code,name) values ('BY','Bayern');
insert into common_de_bundeslaender (code,name) values ('BE','Berlin');
@schmidt1024
schmidt1024 / useDarkMode.js
Created April 14, 2021 14:49
custom react hook - get system prefered theme and use it
const matchDark = '(prefers-color-scheme: dark)'
function useDarkMode() {
const [isDark, setIsDark] = React.useState(
() => window.matchMedia && window.matchMedia(matchDark).matches
)
React.useEffect(() => {
const matcher = window.matchMedia(matchDark)
const onChange = ({ matches }) => setIsDark(matches)
@schmidt1024
schmidt1024 / useClickOutside.js
Created April 14, 2021 14:42
custom react hook - when clicking outside of an element -> do something
function useClickOutside(elRef, callback) {
const callbackRef = React.useRef()
callbackRef.current = callback
React.useEffect(() => {
const handleClickOutside = e => {
if (elRef?.current?.contains(e.target) && callbackRef.current) {
callbackRef.current(e)
}
@schmidt1024
schmidt1024 / terminal-git-branch-name.md
Created February 18, 2021 16:15 — forked from joseluisq/terminal-git-branch-name.md
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@schmidt1024
schmidt1024 / uBlacklist.txt
Last active November 5, 2020 18:42
uBlacklist
*://www.amazon.de/*
*://www.amazon.com/*
*://www.facebook.com/*
*://www.ebay.com/*
*://www.microsoft.com/*
*://www.apple.com/*
*://www.instagram.com/*
*://www.wikipedia.org/*
*://www.t-online.de/*
*://www.bild.de/*
@schmidt1024
schmidt1024 / settings.json
Created July 8, 2020 16:00
My VSCode Settings
{
"peacock.favoriteColors": [
{
"name": "Angular Red",
"value": "#b52e31"
},
{
"name": "Auth0 Orange",
"value": "#eb5424"
},
@schmidt1024
schmidt1024 / iterator.js
Created April 28, 2020 07:15 — forked from jed/iterator.js
Turning callbacks into async iterators, with a React hook-like API.
// Example usage:
//
// void async function() {
// let [clicks, onclick] = iterator()
// document.querySelector('button').addEventListener('click', onclick)
// for await (let click of clicks) console.log(click)
// }()
export default function iterator() {
let done = false
@schmidt1024
schmidt1024 / PhpStorm Keyboard Shortcuts.md
Created February 12, 2019 15:05 — forked from koomai/PhpStorm Keyboard Shortcuts.md
Frequently Used PhpStorm Keyboard Shortcuts

Note: Some of these shortcuts have been remapped for my own convenience (Preferences->Keymap). These are Mac shortcuts, just use the Windows/Linux equivalent of the Cmd/Option/Ctrl/Del keys.

####Search, Go to, Navigation ####

Cmd + P - Search file

Cmd + Shift + O - Search everywhere

(I swapped the above two recently because I use Cmd + P to search for files most of the time).

@schmidt1024
schmidt1024 / git-merge.txt
Created September 6, 2017 08:28
merge branch to master in git
// merge branch test to master
git checkout master
git pull origin master
git merge test
git push origin master
git branch -d test