Skip to content

Instantly share code, notes, and snippets.

View gasolin's full-sized avatar

gasolin gasolin

View GitHub Profile
@sorenlouv
sorenlouv / determine-changed-props.js
Last active April 18, 2024 16:21
Determine which props causes React components to re-render
import React, { Component } from 'react';
export default function withPropsChecker(WrappedComponent) {
return class PropsChecker extends Component {
componentWillReceiveProps(nextProps) {
Object.keys(nextProps)
.filter(key => {
return nextProps[key] !== this.props[key];
})
.map(key => {
@joelash
joelash / app.js
Last active December 14, 2021 11:46
React Native Detect Backgrounding/Foregrounding
import React from 'react';
import {
AppState,
} from 'react-native';
import Expo from 'expo';
class App extends React.Component {
constructor(props) {
<div class="entries">
<div class="entry">
<div class="title">2011</div>
<div class="body">
<p>Neque sunt voluptatibus repellat pariatur ut enim. Eveniet rerum suscipit eveniet amet dignissimos. Doloremque et distinctio quod molestiae ut.</p>
</div>
</div>
<div class="entry">
<div class="title">2012</div>
<div class="body">
@albertorestifo
albertorestifo / propdiff.js
Created April 12, 2017 15:55
Logs the diff between current and previous props on a react element
componentDidUpdate(prevProps) {
console.log('Rrow update diff:');
const now = Object.entries(this.props);
const added = now.filter(([key, val]) => {
if (prevProps[key] === undefined) return true;
if (prevProps[key] !== val) {
console.log(`${key}
- ${JSON.stringify(val)}
@LottieVixen
LottieVixen / README.md
Last active February 19, 2023 17:44
xrandr enable and disable second screen as vnc display

Use a second laptop or headed computer as another monitor via vnc

Firstly check that xrandr has the modeline you need (resolution of the screen you want to use)

$ xrandr
Screen 0: minimum 320 x 200, current 2732 x 768, maximum 16384 x 16384
eDP connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 309mm x 173mm
   1366x768      60.00*+
 1280x720 59.86 
@tanyuan
tanyuan / fcitx-chewing.png
Last active February 26, 2023 14:20
Ubuntu: fcitx + chewing 新酷音輸入法
fcitx-chewing.png
@miglen
miglen / clouds.md
Last active April 15, 2023 20:05
AWS & GCP explained in simple English

Amazon Web Services (AWS) & Google Cloud Platform (GCP) explained in simple English

This guide is only representative from my point of view and it may not be accurate and you should go on the official AWS & GCP websites for accurate and detailed information. It's initially inspired by AWS in simple English and GCP for AWS professionals. The idea is to compare both services, give simple one-line explanation and examples with other software that might have similiar capabilities. Comment below for suggestions.

Category Service AWS GCP Description It's like
Compute IaaS Amazon Elastic Compute Cloud (EC2) Google Compute Engine Type-1 virtual servers VMware ESXi, Citrix XenServer
  PaaS AWS Elastic Beanstalk Google App Engine Running your app on a platform
@pierrebeaucamp
pierrebeaucamp / LeanCanvas.md
Created November 12, 2015 04:05
A Lean Canvas in markdown

Lean Canvas

The Lean Canvas is a version of the Business Model Canvas adapted by Ash Maurya specifically for startups. You can read more about it here.

Problem

Top 3 Problems

@paulirish
paulirish / what-forces-layout.md
Last active April 26, 2024 17:33
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@carcinocron
carcinocron / debugger pause beforeunload
Last active April 25, 2024 16:48
Chrome: pause before redirect
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { debugger; }, false)