顯示Library
chflags nohidden ~/Library
取消dock的延遲
defaults write com.apple.Dock autohide-delay -float 0 && killall Dock
還原dock的延遲
defaults delete com.apple.Dock autohide-delay && killall Dock
防止chrome不小心誤操作,跳到上/下一頁
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WPS = Win32API.new('kernel32', 'WriteProfileString', ['P'] * 3, 'L') | |
WPS.call('Fonts', font_name + ' (TrueType)', font_file_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTTP status code symbols for Rails | |
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
Status Code Symbol | |
1xx Informational | |
100 :continue | |
101 :switching_protocols | |
102 :processing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'httparty' | |
class ApiService | |
include HTTParty | |
base_uri 'http://vote.2018.nat.gov.tw/mobile/zh_TW/TC' | |
def load(code) | |
response = self.class.get("/#{code}.html").parsed_response | |
response =~ /已送\/應送: (\d+)\/(\d+)/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
def require_outer_gem(path) | |
gem_path = "#{Gem.path.first}/gems" | |
extract_gem_name = ->(gems_paths){ gems_paths.map{|s| s[/gems\/([^\/]+)\/lib$/, 1] }.compact } | |
outer_gems = extract_gem_name[Dir["#{gem_path}/*/lib"]] - extract_gem_name[$LOAD_PATH] | |
outer_gems = outer_gems.lazy | |
.map{|s| s.rpartition('-') } | |
.map{|gem_name, _, version| [gem_name, version] } | |
.sort_by{|_, v| Gem::Version.new(v) } # 多版本的話選最新版號 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
======= Prolbem ================================================================================================================= | |
I have installed : ruby-2.0.0,postgres-9.2 , now in rails app when I execute: | |
rake db:create , command I get: | |
PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII) | |
HINT: Use the same encoding as in the template database, or use template0 as template. | |
: CREATE DATABASE "my_db_name" ENCODING = 'unicode'....... | |
bin/rake:16:in `load' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[2020-03-02 03:45:28] __rvm_make | |
__rvm_make () | |
{ | |
\make "$@" || return $? | |
} | |
current path: /home/khiav/.rvm/src/ruby-1.8.7-p374 | |
GEM_HOME=/home/khiav/.rvm/gems/ruby-2.5.5 | |
GEM_PATH=/home/khiav/.rvm/gems/ruby-2.5.5:/home/khiav/.rvm/gems/ruby-2.5.5@global | |
PATH=/home/khiav/.rvm/gems/ruby-2.5.5/bin:/home/khiav/.rvm/gems/ruby-2.5.5@global/bin:/home/khiav/.rvm/rubies/ruby-2.5.5/bin:/home/khiav/.rvm/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files (x86)/Razer/ChromaBroadcast/bin:/mnt/c/Program Files/Razer/ChromaBroadcast/bin:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/mnt/c/Program Files (x86)/Razer Chroma SDK/bin:/mnt/c/Program Files/Razer Chroma SDK/bin:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c |
Deploy key is a SSH key set in your repo to grant client read-only (as well as r/w, if you want) access to your repo.
As the name says, its primary function is to be used in the deploy process, where only read access is needed. Therefore keep the repo safe from the attack, in case the server side is fallen.
- Generate a ssh key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
def kmp_table(pattern) | |
i = 0 | |
j = 1 | |
table = [0] | |
while j < pattern.size | |
if pattern[i] == pattern[j] | |
i += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Migrating from Travis CI to GitHub Actions | |
git checkout -b feature/migrate_from_travis_to_github_actions | |
rm .travis.yml | |
ruby -e "File.write('README.md', File.read('README.md').gsub('travis-ci.org', 'github.com').sub('.svg?branch=master', '/workflows/Ruby/badge.svg').sub(/(khiav223577\/\w+)\)/, '\1/actions)'))" | |
git add . | |
git commit -m 'remove travis' | |
OlderNewer