Skip to content

Instantly share code, notes, and snippets.

View ichn-hu's full-sized avatar
🏠
Working from home

ichn-hu

🏠
Working from home
View GitHub Profile
@ichn-hu
ichn-hu / heap.c
Created July 6, 2021 13:56
algos
#include <stdio.h>
const int MAXN = 10000000;
int heap[MAXN+1];
int heapSize;
int n;
void swap(int *a, int *b) {
Go 4 hrs 54 mins ██████▉░░░░░░░░░░░░░░ 33.3%
Other 3 hrs 45 mins █████▎░░░░░░░░░░░░░░░ 25.6%
SQL 2 hrs 33 mins ███▋░░░░░░░░░░░░░░░░░ 17.4%
TypeScript 1 hr 42 mins ██▍░░░░░░░░░░░░░░░░░░ 11.6%
Python 28 mins ▋░░░░░░░░░░░░░░░░░░░░ 3.2%
@ichn-hu
ichn-hu / audio.js
Last active July 20, 2019 05:49
Auto download vocabulary.com audio
var data = document.querySelector('.audio').attributes['data-audio'].value;
if (data) {
var url = 'https://audio.vocab.com/1.0/us/' + data + '.mp3';
var filename = document.title.split('-')[0].trim() + '.mp3';
download(filename, url);
}
function download(filename, text) {
var pom = document.createElement('a');
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
pom.setAttribute('download', filename);
@ichn-hu
ichn-hu / test.py
Created January 13, 2019 19:55
test_and_compare
from pathlib import Path
dce_cmd = "{opt_path} -load {lib_path} -mem2reg -live {test_file} -S"
import os
import subprocess
import argparse
import pickle
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("--opt_path", type=str, help="the executable for opt, if not specified will just use \"opt\"", default="opt")
@ichn-hu
ichn-hu / .zshrc
Created October 19, 2018 19:04
Remove nasty background color of zsh on WSL
#Change ls colours
LS_COLORS="ow=01;36;40" && export LS_COLORS
#make cd use the ls colours
zstyle ':completion:*' list-colors "${(@s.:.)LS_COLORS}"
autoload -Uz compinit
compinit
@ichn-hu
ichn-hu / pytorch.py
Created August 9, 2018 15:39
have fun in ipython!
import torch as th
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
h = help
ones = th.ones
zeros = th.zeros
randn = th.randn
@ichn-hu
ichn-hu / Swap ctrl and caps.md
Last active August 5, 2018 16:43
Win10 Configuration

Run in powershell:

$hexified = "00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00,00,00,00,00".Split(',') | % { "0x$_"};
$kbLayout = 'HKLM:\System\CurrentControlSet\Control\Keyboard Layout';
New-ItemProperty -Path $kbLayout -Name "Scancode Map" -PropertyType Binary -Value ([byte[]]$hexified);

Scan code can be found here.