Skip to content

Instantly share code, notes, and snippets.

View AndrewThian's full-sized avatar
🎯
Focusing

AndrewThian AndrewThian

🎯
Focusing
  • Singapore
View GitHub Profile
@tannerlinsley
tannerlinsley / README.md
Last active March 27, 2024 10:07
Replacing Create React App with the Next.js CLI

Replacing Create React App with the Next.js CLI

How dare you make a jab at Create React App!?

Firstly, Create React App is good. But it's a very rigid CLI, primarily designed for projects that require very little to no configuration. This makes it great for beginners and simple projects but unfortunately, this means that it's pretty non-extensible. Despite the involvement from big names and a ton of great devs, it has left me wanting a much better developer experience with a lot more polish when it comes to hot reloading, babel configuration, webpack configuration, etc. It's definitely simple and good, but not amazing.

Now, compare that experience to Next.js which for starters has a much larger team behind it provided by a world-class company (Vercel) who are all financially dedicated to making it the best DX you could imagine to build any React application. Next.js is the 💣-diggity. It has amazing docs, great support, can grow with your requirements into SSR or static site generation, etc.

So why

@lcarsos
lcarsos / restore_functionality.sh
Last active March 28, 2024 17:32
Repeatedly kill sentinelone so you can actually use the processor and ram on your mac
#!/usr/bin/env bash
# Usage: sudo ./restore_functionality.sh
#ps aux | grep sentinel | awk -F " +" '{print $2}' | xargs kill
while true; do
launchctl kill SIGKILL system/com.crowdstrike.falcond
launchctl kill SIGKILL system/com.crowdstrike.userdaemon
launchctl kill SIGKILL system/com.sentinelone.sentineld
launchctl kill SIGKILL system/com.sentinelone.sentineld-helper
@gaearon
gaearon / uselayouteffect-ssr.md
Last active March 28, 2024 11:44
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
@astoilkov
astoilkov / readme.md
Last active March 13, 2024 10:19
Async Operations with useReducer Hook

Async Operations with useReducer Hook

9 March, 2019

We were discussing with @erusev what we can do with async operation when using useReducer() in our application. Our app is simple and we don't want to use a state management library. All our requirements are satisfied with using one root useReducer(). The problem we are facing and don't know how to solve is async operations.

In a discussion with Dan Abramov he recommends Solution 3 but points out that things are fresh with hooks and there could be better ways of handling the problem.

Problem

@sz332
sz332 / index.js
Last active August 29, 2019 07:53
Working example of bull and external processor
// index.js
const path = require('path');
const Queue = require('bull');
let queue = new Queue('test queue', 'redis://192.168.99.100:6379');
queue.process(1, path.join(__dirname, './processor.js'))
queue.on('completed', function(job, result) {
console.log("Completed: " + job.id + ", result = " + JSON.stringify(result));
@elijahmanor
elijahmanor / index-0-non-debounced.js
Last active December 20, 2022 21:14
React Debouncing Events
import React, { Component } from "react";
import { render } from "react-dom";
import "./index.css";
class Widget extends Component {
state = { text: "" };
handleChange = (e) => {
this.setState({ text: e.target.value });
};
render() {
@DusanMadar
DusanMadar / TorPrivoxyPython.md
Last active March 23, 2024 11:11
A step-by-step guide how to use Python with Tor and Privoxy

A step-by-step guide how to use Python with Tor and Privoxy

Latest revision: 2021-12-05.

Tested on Ubuntu 18.04 Docker container. The Dockerfile is a single line FROM ubuntu:18.04. Alternatively, you can simply run docker run -it ubuntu:18.04 bash.

NOTE: stopping services didn't work for me for some reason. That's why there is kill $(pidof <service name>) after each failed service <service name> stop to kill it.

References

@acdlite
acdlite / coordinating-async-react.md
Last active March 20, 2022 12:27
Demo: Coordinating async React with non-React views

Demo: Coordinating async React with non-React views

tl;dr I built a demo illustrating what it might look like to add async rendering to Facebook's commenting interface, while ensuring it appears on the screen simultaneous to the server-rendered story.

A key benefit of async rendering is that large updates don't block the main thread; instead, the work is spread out and performed during idle periods using cooperative scheduling.

But once you make something async, you introduce the possibility that things may appear on the screen at separate times. Especially when you're dealing with multiple UI frameworks, as is often the case at Facebook.

How do we solve this with React?

@nikhita
nikhita / update-golang.md
Last active March 26, 2024 15:36
How to update the Go version

How to update the Go version

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

@thorsten
thorsten / setUserAgent.js
Created May 9, 2016 15:12
Override user agent on all browsers
function setUserAgent(window, userAgent) {
// Works on Firefox, Chrome, Opera and IE9+
if (navigator.__defineGetter__) {
navigator.__defineGetter__('userAgent', function () {
return userAgent;
});
} else if (Object.defineProperty) {
Object.defineProperty(navigator, 'userAgent', {
get: function () {
return userAgent;