Skip to content

Instantly share code, notes, and snippets.

View macromogic's full-sized avatar
👨‍💻

Weijie Huang macromogic

👨‍💻
  • Bloomington, IN, US / Chengdu, Sichuan, China
  • 16:37 (UTC -04:00)
View GitHub Profile
@macromogic
macromogic / _setup.sh
Last active September 26, 2025 14:57
Shell Setup
# oh-my-zsh & plugins & p10k
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
cat <<EOF
omz plugin enable z sudo zsh-autosuggestions zsh-syntax-highlighting
omz theme set powerlevel10k/powerlevel10k
EOF | zsh
@macromogic
macromogic / my.sh
Last active April 3, 2024 16:21
Bash Snippets
offsets () {
local pid=${1:-self}
cat "/proc/$pid/maps" |
awk '/ 00000000 / {
if ($5 != 0) {
split($1, a, "-");
print a[1], $6};
}' |
while read -r addr f
do
@macromogic
macromogic / IMP.py
Last active November 26, 2020 12:33
CS303 Project 2: IMP
import argparse
import multiprocessing as mp
from _queue import Empty
from math import sqrt, log, log2, e
from typing import List, Tuple, Callable, Set
from time import time
from imputil import get_subprocess_queue, comb, ic, lt
from imputil.entity import RR, Graph, HeapEntity, Heap
Process: Itsycal [6288]
Path: /Applications/Itsycal.app/Contents/MacOS/Itsycal
Identifier: com.mowglii.ItsycalApp
Version: 0.12.2 (2022)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Itsycal [6288]
User ID: 501
Date/Time: 2019-11-18 10:52:36.865 +0800
@macromogic
macromogic / AVL.cpp
Created November 6, 2019 12:07
Awfully implemented AVL tree (SUSTech CS203 Lab 08 F)
namespace bt
{
#define __AVL_ALLOWS_DUPLICATE
inline int __max(int lhs, int rhs)
{
return lhs < rhs ? rhs : lhs;
}
@macromogic
macromogic / E21p3.java
Last active December 5, 2018 14:47
CS102A Exercise 12: Count keywords in Java source file, ignoring the comments and strings.
import java.util.Scanner;
import java.io.File;
import java.util.Arrays;
import java.util.ArrayList;
import java.io.IOException;
import java.util.stream.Stream;
public class E21p3 {
public static void main(String[] args) throws IOException {
if (args.length == 0) {
@macromogic
macromogic / judge0.sh
Last active November 19, 2017 01:50
Simple judge in Bash for OIers
#!/bin/bash
prog=$1
points=$2
cnt=0
# Compile
g++ -g3 $prog/$prog.cpp -o $prog.o -lm
if [ $? != 0]; then
echo Compilation error.
@macromogic
macromogic / rbtree.h
Last active January 16, 2017 11:34
RBT
#ifndef BSTREE_H_
#define BSTREE_H_
#include<cstdlib>
#include<algorithm>
namespace fsa
{
template<class _tp>
class bstree
@macromogic
macromogic / HDU2571
Created September 15, 2016 06:41
HDU2571_WA
#include<iostream>
#include<vector>
#include<algorithm>
//#define CERR_DEBUG
using namespace std;
vector<vector<int> > matrix, res;