Skip to content

Instantly share code, notes, and snippets.

View tsnieman's full-sized avatar
🗿
living.

Tyler Nieman tsnieman

🗿
living.
View GitHub Profile
@tsnieman
tsnieman / oh-my-zsh and spaceship prompt.md
Created May 9, 2023 15:49
oh-my-zsh + spaceship prompt

Make your zsh better in a few short steps 🚀

Use oh-my-zsh:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Install spaceship-prompt:

# download:
@tsnieman
tsnieman / advanced-memo.md
Created December 28, 2020 21:35 — forked from slikts/advanced-memo.md
Advanced memoization and effects in React

nelabs.dev

Advanced memoization and effects in React

Memoization is a somewhat fraught topic in the React world, meaning that it's easy to go wrong with it, for example, by [making memo() do nothing][memo-pitfall] by passing in children to a component. The general advice is to avoid memoization until the profiler tells you to optimize, but not all use cases are general, and even in the general use case you can find tricky nuances.

Discussing this topic requires some groundwork about the technical terms, and I'm placing these in once place so that it's easy to skim and skip over:

  • Memoization means caching the output based on the input; in the case of functions, it means caching the return value based on the arguments.
  • Values and references are unfortunately overloaded terms that can refer to the low-level implementation details of assignments in a language like C++, for example, or to memory
@tsnieman
tsnieman / logid.cfg
Last active October 13, 2023 07:50
Logiops (Linux driver) configuration example for Logitech MX Master 3. Includes gestures, smartshift, DPI. Tested on logid v0.2.2-35-g1c209ed. File location: `/etc/logid.cfg`
// Logiops (Linux driver) configuration for Logitech MX Master 3.
// Includes gestures, smartshift, DPI.
// Tested on logid v0.2.2-35-g1c209ed.
// File location: /etc/logid.cfg
devices: ({
name: "Wireless Mouse MX Master 3";
smartshift: {
@tsnieman
tsnieman / rollup.config.js
Created October 11, 2019 23:40
Rollup + rollup-plugin-postcss + babel-plugin-react-css-modules. I wanted to use `styleName` in a library that was using CSS modules but was encountering issues of generated scoped names being mismatched. This got babel and the css loader in-sync.
```
import postcss from 'rollup-plugin-postcss';
import genericNames from 'generic-names';
// ...
postcss({
extract: true,
modules: {
// Special scoped name generation function used to sync
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
This is a little script to download every song from every playlist
if your Google Play Music account. Songs are organized as follows:
<playlist>/<artist>/<album>/<song>.mp3
I Highly recomend putting this file in your %USER%\Music folder
before running.
@tsnieman
tsnieman / App.jsx
Last active April 10, 2018 20:48
React 16.3 context example in ~30 lines of code.
import * as React from 'react';
import SomeContext from './SomeContext.jsx';
const App = () => (
<SomeContext.Provider value={{ foo: 'bar' }}>
<App />
</SomeContext.Provider>
);
export default App;
@tsnieman
tsnieman / compile and install vim8 with language support
Last active March 12, 2018 15:45
Install Vim 8 with Python, Python 3, Ruby and Lua support on Ubuntu 16.04
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-gui-common
sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev ruby-dev libperl-dev libncurses5-dev libatk1.0-dev libx11-dev libxpm-dev libxt-dev
#Optional: so vim can be uninstalled again via `dpkg -r vim`
sudo apt-get install checkinstall
sudo rm -rf /usr/local/share/vim /usr/bin/vim
cd ~

Keybase proof

I hereby claim:

  • I am tsnieman on github.
  • I am tsnieman (https://keybase.io/tsnieman) on keybase.
  • I have a public key ASA5SFROUnA_bZNbvS5XuDyOHY-LKIrLAfGDM8Hi5I8G9go

To claim this, I am signing this object:

@tsnieman
tsnieman / app.js
Created December 31, 2016 03:53 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@tsnieman
tsnieman / remove-composes.js
Created July 30, 2016 22:26
Custom loader to remove 'composes' from CSS modules. Created for testing because of this bug https://github.com/istarkov/babel-plugin-webpack-loaders/issues/97
// Custom webpack loader which simply removes any use of 'composes'.
// This is because this bug https://github.com/istarkov/babel-plugin-webpack-loaders/issues/97
// causing issues with testing.
module.exports = function removeComposes(source) {
if (process.env.NODE_ENV === 'test') {
const hasComposes = source.indexOf('composes') > 0;
if (!hasComposes) return source;
var numOfOccurences = source.match(/composes/g).length;