Skip to content

Instantly share code, notes, and snippets.

View blissdev's full-sized avatar

Jordan Arentsen blissdev

View GitHub Profile
@jackkinsella
jackkinsella / .vimrc
Created February 5, 2020 11:17
.vimrc
" Location for installing plugins
call plug#begin('~/.vim/plugged')
" Other plugins are specified with user/repo on Github or x.vim on vimscripts
" Git integration (status bar and commands like Gblame)
Plug 'tpope/vim-fugitive'
" Add info to sidebar about git
Plug 'airblade/vim-gitgutter'
" Add file-management commands like :Delete, :Move, and :Rename
Plug 'tpope/vim-eunuch'
import React from "react";
import { Link } from "react-router-dom";
export function createResource(getPromise) {
let cache = {};
let inflight = {};
let errors = {};
function load(key) {
inflight[key] = getPromise(key)
@SarasArya
SarasArya / handler.js
Last active May 15, 2021 22:05
Serverless Sentry Error Handler example
// Node version 10.x AWS Lambda Serverless framework
const Sentry = require('@sentry/node'); // sentry version "@sentry/node": "^5.5.0",
Sentry.init({
dsn: 'https://randomstuff@sentry.io/1234567',
async beforeSend(event) {
console.log('\n Caught an exception \n');
return event;
},
@Whoaa512
Whoaa512 / Stacked-diff-steps.md
Last active September 28, 2023 08:05
Cheatsheet for the stacked diffs workflow in phabricator at Fictiv

stack diff steps

  1. Checkout & pull latest master
git checkout master && git pull --rebase origin master
  1. Cut branch from master
arc branch stacked_feature_1
  1. Make changes, add commits
const {useCallback, useEffect, useReducer, useRef} = require('react');
let effectCapture = null;
exports.useReducerWithEmitEffect = function(reducer, initialArg, init) {
let updateCounter = useRef(0);
let wrappedReducer = useCallback(function(oldWrappedState, action) {
effectCapture = [];
try {
let newState = reducer(oldWrappedState.state, action.action);
class InjectUrlDataMixin:
"""Used for POST on nested router (so it can take infromation from URL instead of repeting in serializer).
overrides `get_serializer`
(ps.: does not make sense for PUT/PATCH -- as the instance is selected by url-kwargs)
"""
def get_serializer(self, *args, **kwargs):
# standart `get_serializer` logic
serializer_class = self.get_serializer_class()
kwargs['context'] = self.get_serializer_context()

Being able to flush promise resolution (or rejection) in tests is really, really handy, and even essential sometimes. Jest has an open issue for this but I'm impatient.

Setting this up in userland is possible but non-trivial - an adventure, even. I'll lay out what I had to do for any future intrepid types. I'll try to explain the reasoning for all of this and have nothing be magical.

The over-all target is to do task scheduling entirely in userland so that the task queue can be synchronously run to exhaustion. This entails faking timers and swapping out the native promise implementation for one that'll use the faked timers. All of this will be assuming you're using Jest, but the general ideas are test library agnostic.

Runtime performance seems near to native, though there's significantly more transpilation to be done - first runs will be much slower. If you're seeing significant slowdowns, something's probabl

@willeccles
willeccles / alfred-kitty.scpt
Last active February 26, 2024 11:47
AppleScript for using Kitty in Alfred. This was made for bash, but can easily be made to work with any shell.
(* 2019-06-07: Added nohup and output redirection to fix a bug with "Open Terminal here" feature.
Thanks to @fools-mate for bringing the issue to my attention. *)
on alfred_script(q)
do shell script "cd ~; nohup /Applications/kitty.app/Contents/MacOS/kitty /bin/bash -c \"source ~/.bashrc && " & q & ";/bin/bash\" > /dev/null 2>&1 &"
end alfred_script
@parmort
parmort / tmux_tc.md
Created March 26, 2018 21:47
Tmux TrueColor Setup

Tmux TrueColor (a.k.a. 24-bit color) Support

Prerequisites

To enable TrueColor for Tmux, you must make sure that you have two things:

  1. Tmux version 2.2 or higher. You can find out your version by running tmux -V
  2. You have a terminal that supports TrueColor (it may also be referenced by 24 bit color. To check if you do, run

Using chunkwm with khd on macOS High Sierra

To use chunkwm, you have to go to considerably more trouble than you will be used to if you are coming from the older (but very nice) kwm version 3. If you are coming from kwm 4, you are probably right at home.

Note: these instructions have now been added to the chunkwm wiki: https://github.com/koekeishiya/chunkwm/wiki/Instructions:-chunkwm-with-(s)khd-on-macOS-High-Sierra

Understanding the daemon and plugin concept

chunkwm is heavily modularised. It consists of a daemon, chunkwm, and a command-line control tool, chunkc. Neither will directly interact with the user: you need to use khd for that. chunkc is used to send commands to chunkwm, which is listening on a socket (and chunkc sends to that socket).