Skip to content

Instantly share code, notes, and snippets.

View dannyh79's full-sized avatar

Cheng-Hsuan "Danny" Han dannyh79

View GitHub Profile
@taiansu
taiansu / autoscript.sh
Last active April 24, 2020 07:54
webpack+babel configs for React
#!/usr/bin/env bash
# remove this file whenever you don't need it. you need json package to execute the last part.
echo 'installing npm dependencies...'
npm i -s react react-dom prop-types react-hot-loader
echo 'installing npm devDependencies...'
npm i -D @babel/cli @babel/core @babel/plugin-syntax-dynamic-import @babel/preset-env @babel/preset-react babel-loader clean-webpack-plugin html-webpack-plugin webpack webpack-cli webpack-dev-server
echo 'add scripts to package.json...'
json -f package.json -I -e "this.scripts.start=\"webpack-dev-server --mode development --open\""
json -f package.json -I -e "this.scripts.build=\"webpack --mode production\""

error info:

➜  hh (develop-hh) ✔ gem install libv8 -v '3.16.14.11'
Building native extensions.  This could take a while...
ERROR:  Error installing libv8:
	ERROR: Failed to build gem native extension.

    current directory: /Users/simonqian/.rvm/gems/ruby-2.2.2/gems/libv8-3.16.14.11/ext/libv8
/Users/simonqian/.rvm/rubies/ruby-2.2.2/bin/ruby -r ./siteconf20170410-48026-19k49a7.rb extconf.rb
creating Makefile
@dznz
dznz / gist:8552522
Last active December 16, 2020 09:15
Two different ways to plug in a simple Warden failure app to a Rails project.
##
# Simple Warden configuration, complex "controller"
# In config/initializers/warden.rb
Rails.application.config.middleware.use Warden::Manager do |manager|
manager.failure_app = UnauthorizedController
end
# app/controllers/unauthorized_controller.rb
class UnauthorizedController < ActionController::Metal
@vladikoff
vladikoff / gist:d3f5ec1f570e66fb7faff329d01012b7
Created May 1, 2017 16:15 — forked from crossjs/gist:0e11d36849db3fbf88fa64b63e121d5f
Generate an AUTHORS file based on the output of git shortlog.
#!/usr/bin/env sh
# Generate an AUTHORS file based on the output of git shortlog. It uses ABC
# order, strips out leading spaces and numbers, then filters out specific
# authors.
git shortlog -se \
| perl -spe 's/^\s+\d+\s+//' \
| sed -e '/^CommitSyncScript.*$/d' \
> AUTHORS
@Cogitri
Cogitri / .configalacrittyalacritty.yml
Created January 20, 2019 11:40
.config/alacritty/alacritty.yml
# Configuration for Alacritty, the GPU enhanced terminal emulator.
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty itself.
env:
# TERM variable
#
# This value is used to set the `$TERM` environment variable for
# each instance of Alacritty. If it is not present, alacritty will
@fernandoaleman
fernandoaleman / fix-libv8-mac.txt
Created May 5, 2016 15:14
Fixing libv8 and therubyracer on Mac
brew tap homebrew/versions
brew install v8-315
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315
bundle install
@Brainiarc7
Brainiarc7 / fstab-generate-arch.md
Last active March 18, 2024 13:51
Generate fstab in Arch Linux

First, install arch-install-scripts:

sudo pacman -S --needed arch-install-scripts

Secondly, mount your partitions in all the internal hard drives.

Thirdly, generate and validate your config by piping it out to stdout:

@lfender6445
lfender6445 / gist:9919357
Last active March 28, 2024 08:38
Pry Cheat Sheet

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@shaiguitar
shaiguitar / gist:627d52ebc0c03af488477b5d636a8909
Created August 31, 2017 22:27
Using docker compose to mount current working directory dynamically into the container
# mount volume PWD on host to /app in container.
shai@lappy ~/tmp/example-working-docker-compose-environment-vars [master *] ± % cat docker-compose.yml
version: "3"
services:
some_server:
...
volumes:
- $PWD:/app
@HaleTom
HaleTom / print256colours.sh
Last active April 14, 2024 13:35
Print a 256-colour test pattern in the terminal
#!/bin/bash
# Tom Hale, 2016. MIT Licence.
# Print out 256 colours, with each number printed in its corresponding colour
# See http://askubuntu.com/questions/821157/print-a-256-color-test-pattern-in-the-terminal/821163#821163
set -eu # Fail on errors or undeclared variables
printable_colours=256