Skip to content

Instantly share code, notes, and snippets.

View catcarbon's full-sized avatar
📡
N90 FLTDATA

catcarbon

📡
N90 FLTDATA
View GitHub Profile
@catcarbon
catcarbon / SequenceRemoval.py
Last active April 26, 2020 04:16
Remove the shortest non-descending subsequence from original sequence to make all its elements unique
import unittest
from collections import deque
from typing import List
def remove_subsequence_length(nums: List[int]) -> int:
"""
Remove the shortest non-descending subsequence in nums to make elements of nums unique.
:param nums:
@catcarbon
catcarbon / p2.c
Created April 2, 2019 06:42
multithread transpose matrix multiplication
#define N 2000;
float a[N][N], b[N][N], c[N][N];
void p2(int threads) {
int tid;
int block=100; // L1$ 12x32x1024, 4x32x1024 for each array, 32x1024 floats, about 181^2
int i,j,k,ii,jj;
float temp[block];
double sum,C,y,t;
@catcarbon
catcarbon / gpg-agent.conf
Last active March 8, 2019 07:18
GnuPG Setup
enable-ssh-support
pinentry-program /usr/local/bin/pinentry
default-cache-ttl 60
max-cache-ttl 120
@catcarbon
catcarbon / enumerate.py
Last active November 8, 2018 19:14
5522
events = enumerate(events, None)
current = next(events)
for index, frame in enumerate(frames):
while current and current['frame_number'] == index:
# do something
current = next(events)
# do everything else
{
"name":"北京市",
"eng_name":"Beijing",
"id":"11"
}
{
"name":"天津市",
"eng_name":"Tianjin",
"id":"12"
}
@catcarbon
catcarbon / timed_push.php
Created December 26, 2016 02:26
mysql+php message queue test
<?php
// $this_omc = SELECT q_omc FROM queue ORDER BY q_omc ASC LIMIT 1
// $uploader_uid = SELECT upload_uid FROM video WHERE id = $this_omc
// SELECT urel_from_id FROM user_rel WHERE urel_to_id = $uploader_uid
// foreach $res as $item:
// INSERT INTO push (push_uid, push_omc) VALUES($item["urel_from_id"], $this_omc)
include '../config.php';
include '../SQLModel.php';
@catcarbon
catcarbon / keybase.md
Last active October 7, 2017 21:44
keybase.md

Keybase proof

I hereby claim:

  • I am catcarbon on github.
  • I am zhayi (https://keybase.io/zhayi) on keybase.
  • I have a public key ASB20NkFWsc8KWsyPXxYUEqniXhMPdxaDov8LeFKBHdgMQo

To claim this, I am signing this object:

@catcarbon
catcarbon / cuesplit.py
Last active January 15, 2016 21:49
Split ape by cue sheet and convert
import codecs
import subprocess, os, sys
cue_file = sys.argv[1]
d = codecs.open(cue_file, 'r', 'gbk')
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
general = {}
tracks = []
current_file = None
@catcarbon
catcarbon / xmacj.py
Last active January 7, 2016 20:34
Batch correct file name encoding
# Licensed under DON'T BE A DICK PUBLIC LICENSE
# A full description of the license is available at http://www.dbad-license.org/
# by catcarbon, Jan 6 2016: v2
import sys, os
# Why would you do this?
invalid_ext = ['.py', '.cst']
if len(sys.argv) != 2 or re.match('^.\w+$', sys.argv[1]) is None or sys.argv[1] in invalid_ext: