Skip to content

Instantly share code, notes, and snippets.

View unixzii's full-sized avatar
🤔
Thinking...

Cyandev unixzii

🤔
Thinking...
View GitHub Profile
@unixzii
unixzii / ReadAndMark.swift
Created June 19, 2016 06:33
A simple solution for an interview question.
//: Playground - noun: a place where people can play
import Cocoa
import CoreGraphics
//: Sample input: `100, 100, 200, 200, 300, 300`
let inputFilepath = "/Users/unixzii/Desktop/test.csv"
let outputFilepath = "/Users/unixzii/Desktop/test.png"
func pointsFromSequence(sequence: String) -> [CGPoint]? {
@unixzii
unixzii / debouncing_and_throttling.playground.swift
Created December 8, 2016 07:07
debounce 与 throttle 高阶函数简易实现以及演示两者区别
//: 理解 Debouncing 与 Throttling 的区别
import Cocoa
import PlaygroundSupport
typealias Action = () -> ()
func debounce(threshold: TimeInterval, action: @escaping Action) -> Action {
var timer: DispatchSourceTimer?
return {
@unixzii
unixzii / grab_grades.go
Created August 22, 2017 16:00
Grab TJNU Student Grades
package main
import (
"flag"
"fmt"
"io/ioutil"
"net/http"
"strconv"
"strings"
"sync/atomic"
@unixzii
unixzii / NSString+Reverse.m
Last active July 20, 2018 03:57
The right way to reverse a string
#import <Foundation/Foundation.h>
void strrev(char *str) {
size_t start = 0;
size_t end = start + strlen(str) - 1;
while (start < end) {
char ch = str[start];
str[start++] = str[end];
str[end--] = ch;
@unixzii
unixzii / boot.c
Created June 18, 2019 13:20
A damn simple bootloader that prints "Hello, world!".
__asm__(
".code16gcc\n"
"jmpl $0, $main\n"
);
static const char * const msg = "Hello, world!";
void char_out(const char ch) {
__asm__(
"mov $0x0e, %%ah\n"
@unixzii
unixzii / SpringBoard-2019-09-07-002601.ips
Created September 8, 2019 14:14
Crash log of the SpringBoard process.
{"app_name":"SpringBoard","timestamp":"2019-09-07 00:26:01.40 +0800","app_version":"1.0","slice_uuid":"b1aecb6e-b0b1-352a-8400-d3ce659bcfa3","adam_id":0,"build_version":"50","bundleID":"com.apple.springboard","share_with_app_devs":false,"is_first_party":true,"bug_type":"109","os_version":"iPhone OS 13.1 (17A5821e)","incident_id":"1F205275-658C-4890-8E53-3433F5E2EAAE","name":"SpringBoard"}
Incident Identifier: 1F205275-658C-4890-8E53-3433F5E2EAAE
CrashReporter Key: 3b413ac1ea415b52a66c713dc330c82e87bddb37
Hardware Model: iPhone11,2
Process: SpringBoard [2939]
Path: /System/Library/CoreServices/SpringBoard.app/SpringBoard
Identifier: com.apple.springboard
Version: 50 (1.0)
Code Type: ARM-64 (Native)
Role: Foreground
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
[custom]
enable_rule_generator=true
overwrite_original_rules=true
# 白名单模式 PROXY,黑名单模式 DIRECT
custom_proxy_group=🧭Final`select`[]🌑Proxy`[]🌐Direct
# 节点选项
custom_proxy_group=🌑Proxy`select`[]🧯Fallback`[]🕹AutoTest`.*
# 国际流媒体服务
custom_proxy_group=🎞Streaming`select`[]🌑Proxy`[]🕹AutoTest`.*
@unixzii
unixzii / dock_actions.m
Last active November 4, 2022 04:45
Perform some of Dock actions programmatically.
#import <dlfcn.h>
void sendMessageToDock(NSString *message) {
static dispatch_once_t onceToken;
static void (*ptrCoreDockSendNotification)(CFStringRef, int) = NULL;
dispatch_once(&onceToken, ^{
void *handle = dlopen("/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices", RTLD_LAZY);
if (!handle) {
return;
}
@unixzii
unixzii / base64_cxx_tmp.cc
Last active February 18, 2023 06:44
A Base64 implementation using C++ template metaprogramming.
template<auto... Val>
struct List;
template<>
struct List<> {
template<auto Elem>
using Append = List<Elem>;
};
template<auto Head, auto... _Rest>