Skip to content

Instantly share code, notes, and snippets.

@lccxx
lccxx / README.md
Last active November 10, 2021 15:29
COVID-19 cases table generator
require "http/client"
sum = 0
100.times {
spawn {
10000.times {
HTTP::Client.get("http://127.0.0.1/") { |res| sum += 1 }
}
}
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
bindkey -v
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/liuchong/.zshrc'
# End of lines added by compinstall
@lccxx
lccxx / extend_300.js
Last active August 11, 2019 10:57
telegram 狼人杀群的自动续命脚本,续满5人就不续了,并且会自动删除多余的续命消息(避免影响正常聊天),以及清理过多的历史记录(节约内存)
var all_msgs = () => { return $(".im_history_message_wrap:visible"); };
var send = (cmd) => { $(".composer_rich_textarea").text(cmd); $(".im_submit").mousedown(); };
var ex_text = "/extend 299";
var ex_regexp = new RegExp(ex_text);
var own_regexp = /lccc/;
var del_regexp = new RegExp(ex_text + "|延長 299 秒|剩餘 \\d+ 秒|剩餘一分鐘");
(async function work() {
@lccxx
lccxx / ap.rb
Last active April 18, 2017 14:15
#!/usr/bin/ruby
Thread.new { system "create_ap wlp12s0 enp9s0 lc_wlan lc123789 >/dev/null 2>&1" }
999.times.each {
break if `ifconfig | grep ap0`.length != 0
sleep 1
}
@lccxx
lccxx / telegram_math_battle.js
Created October 17, 2016 06:36
Telegram bot "Math Battle" cheat script
window.setInterval(function() { var vx = document.getElementById("task_x").innerText, op = { "+": "+", "–": "-", "×": "*", "/": "/" }[document.getElementById("task_op").innerText], vy = document.getElementById("task_y").innerText, res = document.getElementById("task_res").innerText, r_btn = document.getElementById("button_correct"), w_btn = document.getElementById("button_wrong"); console.log(vx, op, vy, res, r_btn, w_btn); if (eval(vx + op + vy) == res * 1) r_btn.click(); else w_btn.click() }, 500)
@lccxx
lccxx / lcs.rb
Created July 12, 2016 09:53
Longest common subsequence problem
x, y = "CATCGA", "GTACCGTCA"
table = [ ]
(0..x.length).each { table << row = [ ]; (0..y.length).each { row << 0 } }
x.chars.each_with_index { |xc, xi|
y.chars.each_with_index { |yc, yi|
pxv = table[xi][yi + 1]
pyv = table[xi + 1][yi]
pvg = pxv > pyv ? pxv : pyv
pvl = pxv <= pyv ? pxv : pyv
@lccxx
lccxx / obj2str.js
Created March 17, 2016 06:04
js obj with function stringify
function obj2str(obj) {
var fString = function(objj) {
if (!objj) return objj;
var newObj = Array.isArray(objj) ? [] : {}
Object.keys(objj).map(function(k) {
if (typeof(objj[k]) == "function") newObj[k] = objj[k].toString();
else if (typeof(objj[k]) == "object") newObj[k] = fString(objj[k]);
else newObj[k] = objj[k];
})
return newObj;
@lccxx
lccxx / PlagueInc.yml
Last active December 17, 2015 20:39
PlagueInc.yml
---
Type:
Bacteria: Most common cause of Plague. Unlimited potential
Virus: A rapidly mutating pathogen which is extremely hard to control
Fungus: Fungal spores struggle to travel long distances without special effort
Parasite: Parasitic lifestyle prevents DNA alteration from everyday infection
Prion: Slow, subtle and extremely complex pathogen hidden inside the brain
"Nano-Virus": Out of control, microscopic machine with a built in kill switch
"Bio-Weapon": Exceptionally lethal pathogen that kills everything it touches
"Neurax Worm": Manipulative organism that burrows into the brain
@lccxx
lccxx / step_1.sh
Created August 5, 2012 23:55
Linux From Scratch - Version 7.1, console history shell script
#!/bin/bash
function tip { echo -e '\E[37;44m'"\033[1m$1\033[0m"; }
set +h
umask 022
export LFS="/srv/lfs/6.6"
export LC_ALL=POSIX
export LFS_TGT=$(uname -m)-lfs-linux-gnu
export PATH=/tools/bin:/bin:/usr/bin