Skip to content

Instantly share code, notes, and snippets.

View natterstefan's full-sized avatar
🟨
getting things done 💪🏻

Stefan Natter natterstefan

🟨
getting things done 💪🏻
View GitHub Profile
@przbadu
przbadu / react-on-docker.md
Last active December 16, 2023 13:44
Setup Docker for React development

STEP 2: setup docker to run react app (dev and production) configuration: https://gist.github.com/przbadu/929fc2b0d5d4cd78a5efe76d37f891b6

Setup Docker for React development

Because we are using Docker, we are not going to install node, npm, create-react-app in our development machine, not even for generating create-react-app scaffold.

For this purpose I am using 2-step docker configuration:

  • In first step, we will create a simple docker container, that does only one thing, install create-react-app
@LawJolla
LawJolla / gatsby-ssr.js
Created October 2, 2017 19:34
Gatsby + Apollo + Styled Components SSR
import React from "react";
import { renderToString } from "react-dom/server";
import ApolloClient, { createNetworkInterface } from "apollo-client";
import { ApolloProvider, getDataFromTree } from "react-apollo";
import { ServerStyleSheet, StyleSheetManager } from "styled-components";
// function to generate hydrated state for client side Apollo
function makeApolloState(ssrClient) {
const state = { apollo: ssrClient.getInitialState() }
// appends apollo state to the global client window object
@ncochard
ncochard / babel-webpack.md
Last active September 29, 2023 05:15
The correct way to compile ES6 using babel...

When you create a npm package, remember it might be used in a browser or a server, or even a command line utility… For each package you create, please pay attention at what it will be used for:

  1. Is it going to be used as a dependency to a nodejs application that is not bundled? (e.g. command line utilities)
  2. Is it going to be used as a dependency to a nodejs application that is bundled? (e.g. AWS Lambdas)
  3. Is it going to be used as a dependency to a browser application (always bundled)?.
  • In cases 2) and 3) you want to allow for tree shaking.
  • In cases 1) and 2) you want to benefit from the "ES6"/"ES next" features supported natively by nodejs.
  • In case 3) you also want to benefit from the native support of "ES6" from your browser.
@ivanalejandro0
ivanalejandro0 / toggle-mic-mute.applescript
Created January 25, 2018 17:44
Toggle mic mute on OSX
-- Thanks to:
-- https://coolaj86.com/articles/how-to-control-os-x-system-volume-with-applescript/
-- https://robservatory.com/silently-mute-the-mic-input-via-applescript/
-- https://macscripter.net/viewtopic.php?id=16588
--
-- For integration with the system see: http://eddmann.com/posts/creating-a-mac-microphone-mute-keyboard-shortcut/
--
-- In order to keep the `storedInputLevel` value you need to use it compiled:
-- $ osacompile -o toggle-mic.scpt toggle-mic.applescript
-- And then run:
@amcvitty
amcvitty / password_autofill_expo_how_to.md
Last active March 31, 2024 10:17
Configure Password Autofill on a React Native Expo app

Password Autofill on a React Native Expo app

Developing an app to accompany our website, worried that we would lose people in the transition if they couldn't remember their password, we were looking to make our app do Password AutoFill, a feature in iOS.

A talk from WWDC introducing the feature: https://developer.apple.com/videos/play/wwdc2017/206/

It works well, but there were a few bumps in the road making it work for React Native on Expo, so here are some notes to help out.

Apple's docs are here: https://developer.apple.com/documentation/security/password_autofill and they say something like this:

@ademilter
ademilter / .storybook
Last active September 7, 2021 12:11
postcss config for storybook
- webpack.config.js
- postcss.config.js
- config.js
- addons.js
@d4rekanguok
d4rekanguok / webpack.config.js
Last active March 11, 2023 09:52
Config Storybook to avoid conflicts with SVGR
const path = require('path');
const pathToInlineSvg = path.resolve(__dirname, '../resources/icons');
module.exports = (_, _, defaultConfig) => {
const rules = defaultConfig.module.rules;
// modify storybook's file-loader rule to avoid conflicts with svgr
const fileLoaderRule = rules.find(rule => rule.test.test('.svg'));
fileLoaderRule.exclude = pathToInlineSvg;
@rstacruz
rstacruz / README.md
Last active January 17, 2024 22:27
Setting up Babel and TypeScript

Install Babel 7 and TypeScript

yarn add --dev \
  @babel/core \
  @babel/cli \
  @babel/preset-env \
  @babel/preset-typescript \
  typescript
@danielmconrad
danielmconrad / unifi-pi.md
Last active March 14, 2023 15:52
Installing Unifi Controller + Pi-hole on a Raspberry Pi

Installing Unifi Controller + Pi-hole

Update Packages

sudo rpi-update
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get autoremove && sudo apt-get autoclean
sudo apt-get install vim -y
@levelsio
levelsio / getRandomFollower.php
Created January 11, 2020 10:22
get random Twitter follower from your exported followers.js
<?
// str_replace removes the JS part and makes it into a normal JSON file
$followers=json_decode(str_replace('window.YTD.follower.part0 = ','',file_get_contents(__DIR__.'/followers.js')),true);
echo "\n\n";
echo number_format(count($followers)).' followers';
echo "\n\n";