Skip to content

Instantly share code, notes, and snippets.

View scsskid's full-sized avatar
:octocat:

Benedikt Gregor scsskid

:octocat:
View GitHub Profile

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 / _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
@scsskid
scsskid / 👋.gif
Last active September 28, 2020 11:50
👋.gif
@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 / 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 / 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 / parse-html-form-data.js
Last active June 2, 2021 14:30
[Parse HTML FormData] #forms
function parseFormData(formData) {
const formEntries = new FormData(formData).entries();
const data = {};
for (var [formElementName, value] of formEntries) {
data[formElementName] = value;
}
return data;
}
const events = new Map();
class EventBus {
/**
* Register an event handler for the given type.
*
* @param {String} type Type of event to listen for.
* @param {Function} handler Function to call in response to given event.
*/
on(type, handler) {
@scsskid
scsskid / kill.sh
Created November 14, 2020 14:40
[Kill all Users' Procceses] #macos
sudo pkill -9 -u user
function NumberFormatter(locale, opts) {
var formatNumber,
defaults = {
style: 'currency',
currency: 'EUR'
};
opts = opts || {};
opts = Object.assign({}, defaults, opts);
formatNumber = new Intl.NumberFormat(locale, opts);