Skip to content

Instantly share code, notes, and snippets.

@robotzhang
robotzhang / Tailwindcssunreset.scss
Created April 27, 2022 01:28 — forked from swyxio/Tailwindcssunreset.scss
Tailwind CSS Un-Reset - un-reset Tailwind's Preflight CSS Reset so that autogenerated HTML looks consistent with the rest of your Tailwind site. - https://www.swyx.io/writing/tailwind-unreset
.unreset {
a {
@apply text-blue-700 underline;
}
p {
@apply my-4;
}
blockquote,
figure {
@robotzhang
robotzhang / npm.taobao.sh
Created April 21, 2022 06:44 — forked from lvxianchao/npm.taobao.sh
设置 npm 和 yarn 的镜像源为淘宝镜像源
# ==========================================================
# NPM
# ==========================================================
npm set registry https://r.npm.taobao.org # 注册模块镜像
npm set disturl https://npm.taobao.org/dist # node-gyp 编译依赖的 node 源码镜像
## 以下选择添加
npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass # node-sass 二进制包镜像
npm set electron_mirror https://npm.taobao.org/mirrors/electron/ # electron 二进制包镜像
@robotzhang
robotzhang / html-languages.txt
Created January 25, 2021 12:28 — forked from JamieMason/html-languages.txt
HTML lang attribute / ISO language code reference / Culture names
CULTURE SPEC.CULTURE ENGLISH NAME
--------------------------------------------------------------
Invariant Language (Invariant Country)
af af-ZA Afrikaans
af-ZA af-ZA Afrikaans (South Africa)
ar ar-SA Arabic
ar-AE ar-AE Arabic (U.A.E.)
ar-BH ar-BH Arabic (Bahrain)
ar-DZ ar-DZ Arabic (Algeria)
ar-EG ar-EG Arabic (Egypt)
# install build dependencies
sudo yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
# clone and install rbenv environment
cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
@robotzhang
robotzhang / my_db.rake
Created March 26, 2020 15:50 — forked from jay16/my_db.rake
rails backup DB
#encoding: utf-8
require "fileutils"
namespace :my_db do desc "Backup project database. Options: DIR=backups RAILS_ENV=production MAX=7"
desc "usage - bundle exec rake my_db:backup RAILS_ENV=production MAX=15 DIR=db/db.bak"
task :backup => [:environment] do
# config base dir
datestamp = Time.now.strftime("%Y%m%d%H%M")
base_path = Rails.root
backup_folder = File.join(base_path, ENV["DIR"] || "backups")
FileUtils.mkdir_p(backup_folder) unless File.exist?(backup_folder)
@robotzhang
robotzhang / react-hook.md
Last active January 19, 2020 14:48
React Hook 相关的知识
@robotzhang
robotzhang / useClipboard.js
Created January 16, 2020 11:45
clipboard.js 兼容性很好,可惜整个实现和使用的逻辑是基于 DOM 的,在 React 中不是很好用,React 16.8 推出了 hook 之后使得这个事情变得极其简单了。
import {
useRef, useLayoutEffect, useCallback, useState,
} from 'react';
import Clipboard from 'clipboard';
/**
* 复制到粘贴板
* @usage
* const clipboard = useClipboard({
* copiedTimeout: 1000,
module CachingHelper
def with_caching
cache_store_type_origin = Rails.application.config.cache_store
cache_store_origin = Rails.cache
Rails.application.config.cache_store = [
:memory_store, {:size => 64.megabytes }
]
Rails.cache = ActiveSupport::Cache::MemoryStore.new(
:expires_in => 1.minute
)

Keybase proof

I hereby claim:

  • I am robotzhang on github.
  • I am robotzhang (https://keybase.io/robotzhang) on keybase.
  • I have a public key ASB40NW4XTWAtf-MXBKNOLL06W3cxoawacFaiWGh3bWjgwo

To claim this, I am signing this object:

@robotzhang
robotzhang / local_precompile.rake
Last active August 4, 2017 17:55 — forked from tyler-boyd/deploy.rb
Compile assets locally with Capistrano 3.8.1 and Rails 5.1.1
#!!
# put the file to /lib/capistrano/tasks
# Resolve the conflict between local precompile as production mode and webpack/hot/dev-server
# you must edit config/webpacker.yml
# development:
# <<: *default
# public_output_path: packs-dev
#
# Clear existing task so we can replace it rather than "add" to it.