Skip to content

Instantly share code, notes, and snippets.

View causztic's full-sized avatar
👋

yaojie causztic

👋
View GitHub Profile
@causztic
causztic / Lottery.sol
Created November 7, 2018 05:35
Simple lottery with debt collection at the end of grace period
pragma solidity ^0.4.17;
contract Lottery{
uint public MAX_PLAYERS = 2;
address[] public players;
address public manager;
uint public blockNumber;
constructor() public{
@causztic
causztic / gsoc-2018-actionable-errors.md
Last active April 2, 2019 15:39
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

Summary

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.

Description

@causztic
causztic / clockwork.rb
Last active December 18, 2019 02:00 — forked from rogercampos/clockwork.rb
Capistrano running clockwork as daemon with upstart
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/clockwork.pid"
set :rails_env, ENV['rails_env'] || ''
namespace :clockwork do
@causztic
causztic / example.css
Created January 9, 2020 05:07
Highlight label for radio buttons when selected with only CSS
input:checked + label {
color:red;
font-weight: bold;
}
@causztic
causztic / config
Created December 19, 2020 04:22
SSH - Config to suppress warnings + Disable checks for Hosts with frequent dynamic IP changes
Host hostname
IdentityFile ssh-key
User ec2-user
CheckHostIP no
StrictHostKeyChecking no
LogLevel ERROR
UserKnownHostsFile /dev/null
@causztic
causztic / .zshrc
Created September 9, 2021 09:37
Ensuring that pyenv loads correct python version on Mac
PATH=$(pyenv root)/shims:$PATH
@causztic
causztic / jest-multiple-mocks-single-file.js
Last active September 21, 2021 08:15
Jest: Mocking different behaviour in a single file
/*
* 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
*
*/
jest.mock("~/some/module");
@causztic
causztic / httparty_examples.rb
Created May 28, 2020 03:29
HTTParty Post examples
HTTParty.post(
"url",
{
headers: { "Content-Type" => "application/json " },
query: { api_key: "some api key" },
body: { some_data: "value" }
}.to_json
)
HTTParty.post(
@causztic
causztic / keybase.md
Last active September 15, 2022 10:33

Keybase proof

I hereby claim:

  • I am causztic on github.
  • I am causztic (https://keybase.io/causztic) on keybase.
  • I have a public key ASC0RZtX5UG6eDW5pNSV5tyCcKqj5Dei-EQ30UoOs1oKswo

To claim this, I am signing this object:

@causztic
causztic / README.md
Created September 22, 2022 02:57
Fix Apple Mail stuck on Moving Messages

This was what worked for me (I don't have mail for icloud)

  1. Exit the Mail app completely and launch Finder.
  2. Click on the Go menu and hold the Option key to make the ~Library option visible on the screen.
  3. Then open the Mail folder and select the V9 version (or older if you’re running an older OS version).
  4. Next, open the Mail Data folder, and delete all the filters that begin with the Envelope Index.
  5. Clear the Mail app from the library as well. Go to ~/Library/Saved Application State/ and remove com.apple.mail.
  6. Launch the Mail app again. Wait until the app finishes importing your messages.

from: https://appletoolbox.com/apple-mail-stuck-on-moving-messages-mac/