Skip to content

Instantly share code, notes, and snippets.

View zhuochun's full-sized avatar

Zhuochun zhuochun

View GitHub Profile

Read Code Moves Faster Than Understanding


Attention is the amount of human scrutiny required before an artifact should be trusted, approved, merged, published, or acted on.

It is not the severity of any single finding. It is not the verdict. A high-attention artifact can still be LGTM after careful review. A low-attention artifact can still request changes if a clear issue is found.

Attention should be based on blast radius, reversibility, observability, verification difficulty, evidence quality, and whether the artifact changes future engineering understanding.

// ==UserScript==
// @name Hacker News Comment Extractor
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Extract and copy comments from Hacker News threads
// @author YourName
// @match https://news.ycombinator.com/item*
// @grant GM_setClipboard
// ==/UserScript==
#!/usr/bin/env ruby
require 'net/http'
require 'json'
begin
uri = URI('https://cdn.rawgit.com/github/gemoji/master/db/emoji.json')
resp = Net::HTTP.get_response(uri)
emoji = JSON.parse(resp.body)
num = [ARGV.first.to_i, 1].max
@zhuochun
zhuochun / greeter_client.rb
Last active March 9, 2016 14:06
Ruby GRPC Memory Leak
# Sample app that connects to a Greeter service.
#
# Usage: $ path/to/greeter_client.rb
this_dir = File.expand_path(File.dirname(__FILE__))
lib_dir = File.join(this_dir, 'lib')
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
require 'grpc'
require 'helloworld_services'
# this is a dirty implementation of logger that
# compiles AR queries with trace into /last_request_log.html
# the snippet is useful when optimizing performance of the endpoint
class QueryLogSubscriber < ActiveSupport::LogSubscriber
TRACE_LEVEL = :app
LINES = 5
IGNORE_CACHED_QUERIES = false
def initialize
/*
* Custom Markdown Styles for Atom
*/
.editor .gfm {
@gfm_gray0f: #F0F0F0;
@gfm_gray0b: #B2B2B2;
@gfm_gray07: #767676;
@gfm_gray05: #545454;
@gfm_pink: #FB007A;
@gfm_red_dark: #C30071;
@zhuochun
zhuochun / README.md
Last active June 14, 2023 17:46
List all posts, tags and categories in Jekyll. https://github.com/zhuochun/md-writer

List all posts, tags and categories in Jekyll.

Octopress users: if you found " is escaped in the generated JSON file, please change them to \". Refer to this issue.

@zhuochun
zhuochun / rename.rb
Created April 28, 2014 15:41
Remove `%..` from files' filenames
files = Dir["*"].select { |filename| filename.include? "%" }
files.each do |filename|
new_name = filename.gsub(/%../, "")
File.rename(filename, new_name)
end
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using System.Windows.Threading;
using System.Collections.Generic;
namespace Ownskit.Utils
{
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rails'
require 'capybara/rspec'
require 'database_cleaner'
# Requires supporting ruby files with custom matchers and macros, etc,