Skip to content

Instantly share code, notes, and snippets.

View upsuper's full-sized avatar

Xidorn Quan upsuper

View GitHub Profile
@upsuper
upsuper / LICENSE
Last active July 15, 2022 03:02
A Java implementation of SHA-224 message digest algorithm with Provider
Copyright (c) 2012 Xidorn Quan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@upsuper
upsuper / Makefile
Created August 22, 2012 09:23
"xor rax, rax" vs. "mov rax, 0"
all: mov xor
mov: mov.o
ld -o mov mov.o
xor: xor.o
ld -o xor xor.o
mov.o: mov.asm
yasm -f macho64 -o mov.o mov.asm
@upsuper
upsuper / af_alternate.c
Created October 12, 2012 16:27
Interesting Audio Filters for MPlayer
/*
* Copyright (C) 2012 Xidorn Quan <[email protected]>
*
* This file is part of MPlayer.
*
* MPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
@upsuper
upsuper / corestatus.sh
Created December 28, 2012 04:43
Switch number of CPU cores in Linux
#!/bin/bash
cat /proc/cpuinfo | grep processor | wc -l
@upsuper
upsuper / mkramdisk
Created January 6, 2013 02:30
Script for OS X to create ramdisk & mount to a given place. This script is also enabled to resize the ramdisk it creates by mounting a new one and copying files into it.
#!/bin/zsh
INITIAL_SIZE=5
VOLUME_NAME='ramdisk'
MOUNTPOINT='/tmp/upsuper'
MOUNTPOINT_FILE='/tmp/ramdisk.mountpoint'
# find a non-existent initial mount point
mountpoint=$(mktemp -dt ramdisk)
# set ramdisk size
diff -ur a/CPP/7zip/Archive/Zip/ZipItem.cpp b/CPP/7zip/Archive/Zip/ZipItem.cpp
--- a/CPP/7zip/Archive/Zip/ZipItem.cpp 2016-02-02 03:50:10.000000000 +1100
+++ b/CPP/7zip/Archive/Zip/ZipItem.cpp 2023-08-15 23:19:44.862769098 +1000
@@ -1,6 +1,7 @@
// Archive/ZipItem.cpp
#include "StdAfx.h"
+#include <iconv.h>
#include "../../../../C/CpuArch.h"
@upsuper
upsuper / gist:5069549
Last active December 14, 2015 10:09
Counting non-printable characters in .js and .css files.
class FileInfo
def initialize(name, data)
@name = name
@length = data.length
@space = data.each_char.inject(0) { |n, c|
n += case c
when '\t' then 8
when /\s/ then 1
else 0
end
@upsuper
upsuper / gist:5351509
Created April 10, 2013 03:22
Simplify IP segments by removing redundant segments and merging adjacent segments.
# coding: UTF-8
import socket
import struct
def aton(addr):
return struct.unpack('!l', socket.inet_aton(addr))
def ntoa(addr):
return socket.inet_ntoa(struct.pack('!l', addr))
@upsuper
upsuper / bgmrank.rb
Last active May 14, 2019 03:40
统计 Bangumi 上一个用户的收藏的评分分布情况,已移至 https://github.com/upsuper/bgmrank
#!/usr/bin/env ruby
require 'optparse'
require 'net/http'
CATEGORIES = [:anime, :book, :music, :game, :real]
STATES = [:wish, :collect, :do, :on_hold, :dropped]
progress = true
options = {
@upsuper
upsuper / progress_indicator.py
Created June 10, 2013 05:52
Graphic progress indicator in command line. It may only support OS X.
#!/usr/bin/python
# - * - coding: UTF-8 - * -
from sys import stdout
from time import sleep
from itertools import cycle
MOON = [u'\U0001F311', u'\U0001F312', u'\U0001F313', u'\U0001F314',
u'\U0001F315', u'\U0001F316', u'\U0001F317', u'\U0001F318']