Skip to content

Instantly share code, notes, and snippets.

View scsskid's full-sized avatar
:octocat:

Benedikt Gregor scsskid

:octocat:
View GitHub Profile
@scsskid
scsskid / viewport.js
Last active October 27, 2020 21:51
[ViewPort Height Related Snippets] if -webkit-fill-available isnt enough...
function appHeight() {
document.documentElement.style.setProperty(
'--vh',
window.innerHeight * 0.01 + 'px'
);
}
React.useEffect(() => {
// window.addEventListener('resize', appHeight);
// appHeight();
@scsskid
scsskid / useLocalStorageState.js
Created October 27, 2020 14:26
[useLocalStorageState] #react
function useLocalStorageState(
key,
defaultValue = '',
{ serialize = JSON.stringify, deserialize = JSON.parse } = {}
) {
const [state, setState] = React.useState(() => {
const valueInLocalStorage = window.localStorage.getItem(key);
if (valueInLocalStorage) {
return deserialize(valueInLocalStorage);
@scsskid
scsskid / react.jsx
Last active October 27, 2020 08:44
[Random React Snippets] #react
// Elegant Composition
const UnorderedList = ({children}) => (
<ul>
{
children.map((child, i) => <li key={i}>{child}</li>
}
</ul>
)
const App = () => (
@scsskid
scsskid / 👋.gif
Last active September 28, 2020 11:50
👋.gif
@scsskid
scsskid / _headers
Created September 19, 2020 16:57 — forked from robsonsobral/_headers
Netlify headers
/*
# Only connect to this site and subdomains via HTTPS for the next one year
Strict-Transport-Security: max-age=31536000; includeSubDomains
# Block site from being framed with X-Frame-Options and CSP
Content-Security-Policy: frame-ancestors 'self'
# X-Frame-Options tells the browser whether you want to allow your site to be framed or not. By preventing a browser from framing your site you can defend against attacks like clickjacking.
X-Frame-Options: SAMEORIGIN

Keybase proof

I hereby claim:

  • I am scsskid on github.
  • I am scsskid (https://keybase.io/scsskid) on keybase.
  • I have a public key ASCcp5anr3F3NE5NpFCCBxsrWTiLEN71zRCdc5QVXas0Wwo

To claim this, I am signing this object:

@scsskid
scsskid / log-data-to-screen.js
Last active September 28, 2020 11:54
[Log Data To Screen] #debug
return `
<pre>
<code>${JSON.stringify(props, null, 4)}</code>
</pre>
`
@scsskid
scsskid / reset-right-font.sh
Last active October 27, 2020 21:53
[Right Font App Data Reset] #macos
rm -R ~/Library/Application\ Support/RightFont
@scsskid
scsskid / delay.sh
Last active October 27, 2020 21:52
[MacOS Remove Delay Dock Autohide] #macos
defaults write com.apple.dock autohide-delay -float 0; killall Dock
@scsskid
scsskid / Date get Monday as 0th day.js
Last active September 28, 2020 11:57
[Date get Monday as 0th day]
const date = new Date();
date = (date.getDay() + 6) % 7
// src: https://stackoverflow.com/a/24481597/2823589