Skip to content

Instantly share code, notes, and snippets.

View jinhucheung's full-sized avatar
🏗️
Building

jim jinhucheung

🏗️
Building
View GitHub Profile
@jinhucheung
jinhucheung / clash.service
Created June 6, 2022 02:26 — forked from akillcool/clash.service
clash auto start and update subcribe configuration
# edit and save this file to /usr/lib/systemd/system/clash.service
[Unit]
Description=clash
After=network.target
[Service]
WorkingDirectory="your home directory"/.config/clash
ExecStart="your home directory"/.config/clash/start-clash.sh
ExecStop="your home directory"/.config/clash/stop-clash.sh
Environment="HOME=your home directory"
@jinhucheung
jinhucheung / gist:d3714032bf04aa83f7d94df4bd91fb73
Created May 31, 2022 16:11 — forked from 480/gist:3b41f449686a089f34edb45d00672f28
MacOS X + oh my zsh + powerline fonts + visual studio code terminal settings

MacOS X + oh my zsh + powerline fonts + visual studio code (vscode) terminal settings

Thank you everybody, Your comments makes it better

Install oh my zsh

http://ohmyz.sh/

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
require 'matrix'
def regression x, y, degree
x_data = x.map {|xi| (0..degree).map{|pow| (xi**pow) }}
mx = Matrix[*x_data]
my = Matrix.column_vector y
((mx.t * mx).inv * mx.t * my).transpose.to_a[0].reverse
end
@jinhucheung
jinhucheung / polymorphic_primary_key_alias.rb
Last active June 2, 2021 02:37
polymorphic_primary_key_alias.rb
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails", branch: "main"
@jinhucheung
jinhucheung / polymorphic_mixed_id_types.rb
Last active June 2, 2021 02:20 — forked from HParker/polymorphic_mixed_id_types.rb
Mixed typed polymorphic keys
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails", branch: "main"
@jinhucheung
jinhucheung / keybase.md
Last active February 23, 2020 08:09
keybase.md

Keybase proof

I hereby claim:

  • I am jinhucheung on github.
  • I am jimcheung (https://keybase.io/jimcheung) on keybase.
  • I have a public key ASDIzFeTb1RCv3e6DqnACC5VHEdUPy5x605V-s4Fn4YW4Qo

To claim this, I am signing this object:

@jinhucheung
jinhucheung / base.rb
Last active December 27, 2018 13:27
Call method of a Ruby Singleton without instance
require 'singleton'
require 'forwardable'
class Postman
include Singleton
class << self
extend Forwardable
def_delegators :instance, :post, :delete