Skip to content

Instantly share code, notes, and snippets.


yaojie causztic

View GitHub Profile
causztic / jest-multiple-mocks-single-file.js
Last active Sep 21, 2021
Jest: Mocking different behaviour in a single file
View jest-multiple-mocks-single-file.js
* Say that I want to test a component with an imported function that has different behaviours.
* e.g.
* import { authenticate } from "~/some/module"
* authenticate: (...) => boolean
causztic / .zshrc
Created Sep 9, 2021
Ensuring that pyenv loads correct python version on Mac
View .zshrc
PATH=$(pyenv root)/shims:$PATH
causztic /
Last active May 4, 2022
List of useful commands as a Rails developer

Here are some commands I use rather frequently.


git rebase --onto new-parent old-parent - Change parent branch of a fork

git remote prune origin - Clean up git remotes

git rebase -i <other-branch> - Dropping, squashing, rewording a list of commits

Gets all merges within a range of dates

causztic / config
Created Dec 19, 2020
SSH - Config to suppress warnings + Disable checks for Hosts with frequent dynamic IP changes
View config
Host hostname
IdentityFile ssh-key
User ec2-user
CheckHostIP no
StrictHostKeyChecking no
LogLevel ERROR
UserKnownHostsFile /dev/null
causztic / httparty_examples.rb
Created May 28, 2020
HTTParty Post examples
View httparty_examples.rb
headers: { "Content-Type" => "application/json " },
query: { api_key: "some api key" },
body: { some_data: "value" }

Keybase proof

I hereby claim:

  • I am causztic on github.
  • I am causztic ( on keybase.
  • I have a public key ASAqXaUIXcGl8AB7ttnu3U_vH91hKCQpRiNeurLqYsEwEAo

To claim this, I am signing this object:

causztic / example.css
Created Jan 9, 2020
Highlight label for radio buttons when selected with only CSS
View example.css
input:checked + label {
font-weight: bold;
causztic / Lottery.sol
Created Nov 7, 2018
Simple lottery with debt collection at the end of grace period
View Lottery.sol
pragma solidity ^0.4.17;
contract Lottery{
uint public MAX_PLAYERS = 2;
address[] public players;
address public manager;
uint public blockNumber;
constructor() public{
causztic /
Last active Apr 2, 2019
Actionable Errors and new Error Page Design for Ruby on Rails

During GSOC 2018 I have proposed and worked on a feature for Ruby on Rails - Actionable Errors. rails/rails#34788


Currently, errors with a defined flow to fix them have to be done manually (e.g. when there are pending migrations or when credentials are not found.)

With the new ActionableException concern in ActiveSupport, maintainers for various Ruby on Rails libraries with their special error classes will be able to extend this module and provide the appropriate Actions to take, which the user can activate by clicking on a button.


causztic / clockwork.rb
Last active Dec 18, 2019 — forked from rogercampos/clockwork.rb
Capistrano running clockwork as daemon with upstart
View clockwork.rb
after "deploy:stop", "clockwork:stop"
after "deploy:start", "clockwork:start"
after "deploy:restart", "clockwork:restart"
set :clockwork_roles, :blabla
set :cw_log_file, "#{current_path}/log/clockwork.log"
set :cw_pid_file, "#{current_path}/tmp/pids/"
set :rails_env, ENV['rails_env'] || ''
namespace :clockwork do