Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
APP=$1
# This script is intended to temporarily bypass the "blank screen" bug in Anki on unsupported(?)
# GPUs (Dec 2021): <https://forums.ankiweb.net/t/anki-opens-but-all-windows-are-blank/8920/16>
#
# Adapted from a similar script by @ahihi for an app called "SuperCollider" that also uses qt on
# macOS: <https://github.com/supercollider/supercollider/issues/4136#issuecomment-605447703>
if [ -z "$APP" ]; then
@Ji-Yuhang
Ji-Yuhang / iamyuhang_go.go
Created April 18, 2020 14:39
go语言gin demo
package main
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/go-pg/pg"
)
type Word struct {
Id int64
//Content string
#include<iostream>
#include<vector>
#include<algorithm>
#include<list>
using namespace std;
static const int MAX = 10000;
vector<int> G[MAX];
list<int> out;
bool V[MAX];
@Ji-Yuhang
Ji-Yuhang / file_size.rb
Created September 4, 2019 08:15
对 dist文件下所有对文件按大小进行排序
#!/usr/bin/env ruby
data = Dir.glob("dist/**/*").map { |f| { file: f, size: File.size(f) } }.sort { |a, b| b[:size] <=> a[:size] }.each { |t| puts "size: #{t[:size]} , file: #{t[:file]}" }
total_size = data.reduce(0) { |s, f| f[:size] + s }
puts "Total size: #{total_size}"
@Ji-Yuhang
Ji-Yuhang / upload_assets_to_qinniu_cdn.rb
Last active September 4, 2019 08:14
批量拷贝src/assets下文件到temp下,文件名加上[hash:8]
#!/usr/bin/env ruby
require "fileutils"
require "digest"
def images
Dir.glob("src/assets/**/*").select { |f| !File.directory?(f) }
end
def unhashed_images
images.select { |f| f.slice(-8, 8) != sha1(f) }
@Ji-Yuhang
Ji-Yuhang / arrty_to_tree.js
Last active August 29, 2019 08:58
对含有parent_id 的数组进行拓扑排序,然后生成树状结构
const _ = require("lodash");
// 按扭ID(整型,不可重复),按扭名称(字符串),父ID(按扭之间的关系,可为空)
// 100,桌面,0
// 101,开启桌面整理,100
// 102,退出桌面整理,100
// 103,一键桌面整理,100
const file = [["按扭ID(整型,不可重复)", "按扭名称(字符串)", "父ID(按扭之间的关系,可为空)"], ["100", "桌面", "0"], ["101", "开启桌面整理", "100"], ["102", "退出桌面整理", "100"], ["103", "一键桌面整理", "100"], ["104", "新建分区", "100"], ["105", "新建分区-桌面右键", "104"], ["106", "新建分区-分区右键", "104"], ["107", "新建分区-标题栏", "104"], ["108", "解散分区", "100"], ["109", "解散分区-分区右键", "108"], ["110", "解散分区-菜单面板", "108"], ["111", "解散分区-标题栏", "108"], ["112", "锁定分区", "100"], ["113", "锁定分区-菜单面板", "112"], ["114", "锁定分区-标题栏", "112"], ["115", "重命名", "100"], ["116", "查看方式", "100"], ["117", "查看方式-分区右键", "116"], ["118", "大图标", "117"], ["119", "中等图标", "117"], ["120", "小图标", "117"], ["121", "查看方式-菜单面板", "116"], ["122", "大图标", "121"], ["123", "中等图标", "121"], ["124", "小图标", "121"], ["125", "查看方式-底部栏", "116"], ["126", "切换至图标模式", "125"], ["127", "切换至列表模式", "125"], ["128", "查看方式-桌面右键", "116"], ["129", "大图标", "128"], ["130", "中等图标", "128"], ["131", "小图标", "1
@Ji-Yuhang
Ji-Yuhang / oracle_pagination.sql
Created April 11, 2019 11:30
oracle数据库在排序后分页需要3层select from
select OuterWrap.*
from (
SELECT ROWNUM as AfterOrderRowNum, Wrap.*
FROM (
SELECT "RechargeOrder"."CREATE_TIME" AS "RechargeOrder_CREATE_TIME" ,
ROWNUM AS "BeforeOrderRowNum"
FROM "T_RECHARGE_ORDER" "RechargeOrder"
ORDER BY "RechargeOrder"."CREATE_TIME" DESC
) Wrap
@Ji-Yuhang
Ji-Yuhang / add_pg_trgm_extension_to_db.rb
Created October 17, 2017 05:29
pg_trgm gin postgre
class AddPgTrgmExtensionToDb < ActiveRecord::Migration[5.0]
# def change
# # execute "remove extension pg_trgm;"
# execute "create extension IF NOT EXISTS pg_trgm;"
# execute "CREATE EXTENSION IF NOT EXISTS btree_gin;"
#
# remove_index :words, :word
# add_index :words, :word, using: :btree_gin
# end
def up
utf8_msg = msg.dup.force_encoding(Encoding::GBK).encode('utf-8') # GBK to UTF-8
@Ji-Yuhang
Ji-Yuhang / mongo_id_get_all_model_names.rb
Created September 22, 2017 01:40
rails mongo get all model names
desc 'get Models'do
headers "Authentication-Token"=>{description: 'token',required: true }
end
get 'all_models' do
Rails.application.eager_load! if Rails.env.development?
models = Mongoid::Config.models
#fields.values.map{|f| o = f.options;{name: f.name,type: o[:type], kclass: o[:klass].to_s }}
present :models, models.map{|m|{model_name: m.to_s, relations: m.relations, field_names: m.fields.keys, fields: m.fields.values.map{|f| o = f.options;{name: f.name,type: o[:type].to_s, kclass: o[:klass].to_s }}}}
end