Skip to content

Instantly share code, notes, and snippets.

@davidtingsu
davidtingsu / prettier-diff-branch-vs-main.sh
Last active January 11, 2024 08:48
fix flles in git diff feature branch against main jsx|.tsx|.js$|.ts$ with prettier
# run prettier against the changed files between your branch and main
# tested on macosx
git diff --name-status `git merge-base HEAD main` HEAD | awk '{print $2}' | grep -E '.jsx|.tsx|.js$|.ts$' | xargs npx prettier --write
@davidtingsu
davidtingsu / git-commit-body-oneline.sh
Created January 23, 2019 22:13
get git commits in time range and output description in oneline
# https://devhints.io/git-log-format
# https://stackoverflow.com/a/19169532/1123985
git rev-list master --author=Name --before="12/31/2018" --after="1/1/2018" |
while read sha1; do
git show -s --format='"%s","%ci","%B"' $sha1 | tr \n' ''; echo
done
@davidtingsu
davidtingsu / add-configure-to-enzyme-imports.js
Created January 16, 2019 01:28
gist to add 'configure' to enzyme imports using jscodeshift
// https://astexplorer.net/#/gist/55b79bb6a2287057b4459d5ef87528a1/34173b57c114657bd47b0441ad35cb88037e7832
// Press ctrl+space for code completion
export default function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
.find(j.ImportDeclaration)
.forEach(importStatement => {
const specifiers = j(importStatement).find(j.ImportSpecifiers);
@davidtingsu
davidtingsu / .arclint yaml
Last active August 4, 2017 00:04
how to setup .arclint for yaml
# install yamllint at https://github.com/adrienverge/yamllint
{
"linters": {
"yaml": {
"type": "script-and-regex",
"include": [
"(\\.yaml?$)"
],
"exclude": [],
"script-and-regex.script": "sh -c 'yamllint -f parsable \"$0\" || true'",
@davidtingsu
davidtingsu / soda-rails-setup.sh
Created September 15, 2013 01:47
install rails on soda lab computers running ubuntu 12.
#!/bin/bash
# to install rails and node on ubuntu in Soda Hall (UC Berkeley) without root access
# constraints: no root access. ~1536 MB limit.
# TODO: handle all cs169 dependencies
# https://github.com/saasbook/courseware/blob/5e6cd1f533cc86f8caa0ad0ed0a9fb84baf2a662/vm-setup/configure-image-0.10.2.sh
### RVM INSTALLATION ###
# https://rvm.io/rvm/install # single user installation
echo "Installing rvm ..."
@davidtingsu
davidtingsu / .vimrc.bundles.local
Last active December 20, 2015 18:29
.vimrc.local for ruby development using spf13-vim distribution
Bundle 'brookhong/cscope.vim'
Bundle 'chazy/cscope_maps'
#put in <project_directory>/lib/tasks
namespace :export do
desc "Export ActiveRecord model records to a CSV file. Pass model name: model=ModelName"
task :to_csv => :environment do
require 'exportable'
model_name = ENV['model']
open( "#{::Rails.root}" + '/log/export.pid', "w") do |file|
file << Process.pid
end