Skip to content

Instantly share code, notes, and snippets.

output('r = 1')
get_remote_data('https://raw.githubusercontent.com/curran/data/gh-pages/worldFactbook/GDPPerCapita.csv', (csv_str) => {
let vals = [];
for (l of Papa.parse(csv_str).data) {
vals.push(l[1])
}
Calc.setExpression({
id: 'mytable',
type: 'table',
@xiejiangzhi
xiejiangzhi / Desmos Script
Last active May 21, 2022 09:45
Support javascript for Desmos
// ==UserScript==
// @name Desmos script
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://*.desmos.com/calculator*
// @icon https://www.google.com/s2/favicons?sz=64&domain=desmos.com
// @grant unsafeWindow
// @grant GM_xmlhttpRequest
local Names = {}
local CharIndex = {} -- { [index_str] = { word1, word2, word3, ...}, ... }
local CharIndexPos = {} -- { [index_str] = { char_pos1, char_pos2, char_pos3, ...}, ... }
local MaxIndexLen = 2 -- 1: start with {x}, 2: start with {xx}, 3: start with {xxx}
-- word: asdf asdf zxcv
-- fuzzy match: adfasf, aszx, asdfasdf, as as
local RandChars = 'abcdefghijklnmopqrstuvwxyz'
local function rand_word(n)
@xiejiangzhi
xiejiangzhi / t2csv.rb
Last active November 27, 2018 10:25
Convert excel(xls, xlsx, etc) to csv
#! /usr/bin/env ruby
# Support formats
# xlsx: Excel 2007 - 2013
# xlsm: Excel 2007 - 2013
# xls: Excel 97,
# ods: LibreOffice / OpenOffice.org
# xml: Excel 2002 2003 XML
#
# More see roo-rb/roo
@xiejiangzhi
xiejiangzhi / tls_cert_checker.rb
Last active November 27, 2018 09:35
a ruby https(tls/ssl) cert checker
#! /usr/bin/env ruby
# Usage:
# tls_cert_checker xjz.pw aliyun.com yourdomain.com
# tls_cert_checker /path/to/your_hosts
# hosts_file: split hosts with new line "\n", ignore empty line
require 'socket'
require 'openssl'
#!/usr/bin/env ruby
def generate_dir_links(dir)
level_names = []
last_level = 0
Dir['*.md'].sort.each_with_object([]) do |file, md|
next if file == 'Home.md'
path = file.split('--')
name = path.last
(function(){
var $toggle_btn = $("<a href='javascript: void(0);'>My Label Switch</a>");
$('.filter-item.reset-filters').append($toggle_btn);
$toggle_btn.click(function(e){
var $issues = $('li.issue[data-labels*=1290],li.issue[data-labels*=2697]');
if ($($issues[0]).hasClass('hide-issue')) {
$issues.removeClass("hide-issue");
} else {
$issues.addClass("hide-issue");
ITEMS = [
{ weight: 3, value: 200},
{ weight: 10, value: 500},
{ weight: 100, value: 30},
{ weight: 200, value: 2000},
{ weight: 300, value: 500},
{ weight: 50, value: 50},
{ weight: 190, value: 1000},
{ weight: 200, value: 1500},
]
@xiejiangzhi
xiejiangzhi / ga.rb
Last active February 16, 2017 08:06
# class Unit
# include GA
# attr_accessor :genome, :value
#
# def self.random_new
# self.new(10.times.map { rand(2) == 1 })
# end
#
# def initialize(genome)
# @genome = genome.dup
ITEMS = [
{ weight: 3, value: 200},
{ weight: 10, value: 500},
{ weight: 100, value: 30},
{ weight: 200, value: 2000},
{ weight: 300, value: 500},
{ weight: 50, value: 50},
{ weight: 190, value: 1000},
{ weight: 200, value: 1500},
]