Skip to content

Instantly share code, notes, and snippets.

View stdrc's full-sized avatar
😁

Richard Chien stdrc

😁
View GitHub Profile
@stdrc
stdrc / build_unopt_bc.sh
Last active November 6, 2021 02:55
从 wllvm 编出的 binary 获得(重新编译)未优化的 LLVM bitcode
#!/bin/bash
#
# 声明
#
# 本脚本主要来自 https://blog.xiexun.tech/linux-bc-custom-opt.html,
# 这里只是收藏一下(并做了一点点小修改)。
#
# 用法
#
@stdrc
stdrc / CMakeLists.txt
Created February 25, 2021 01:23 — forked from baiwfg2/CMakeLists.txt
How to use add_custom_target and add_custom_command correctly in cmake
# References:
# https://cmake.org/cmake/help/latest/command/add_custom_target.html
# https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/
# https://gist.github.com/socantre/7ee63133a0a3a08f3990
# https://stackoverflow.com/questions/24163778/how-to-add-custom-target-that-depends-on-make-install
# https://stackoverflow.com/questions/30719275/add-custom-command-is-not-generating-a-target
# https://stackoverflow.com/questions/26024235/how-to-call-a-cmake-function-from-add-custom-target-command
# https://blog.csdn.net/gubenpeiyuan/article/details/51096777
cmake_minimum_required(VERSION 3.10)
@stdrc
stdrc / commands.md
Last active September 19, 2022 02:46
常用命令

常用小命令

SSH 相关

打开 sock5 代理:

ssh -D 1337 -q -C -N remote-hostname
# -D sock5 代理端口
# -q 不输出任何内容
@stdrc
stdrc / mount.md
Last active April 10, 2021 15:38
在 macOS 上挂在 NTFS 分区为可写

Write to NTFS support MacOS

1. Get the partition UUID

Connect the external drive to MacOS. It should mount read-only. Start "System Information", clic on Hardware -> Storage, select your drive in the list and copy its UUID.

Another way to get the UUID is to use the diskutil CLI tool:

~$ diskutil list 
~$ diskutil info diskXsY
@stdrc
stdrc / 1linenotepad.txt
Created November 4, 2015 03:33 — forked from richardtape/1linenotepad.txt
A 1line notepad for in-browser copy and pasteyness
data:text/html;charset=utf-8, <title>TextEditor</title> <link rel="shortcut icon" href="http://g.etfv.co/https://docs.google.com"/> <style> html{height: 100%;} body{background: -webkit-linear-gradient(#f0f0f0, #fff); padding: 3%; height: 94%;} .paper { font: normal 12px/1.5 "Lucida Grande", arial, sans-serif; width: 50%; height: 80%; margin: 0 auto; padding: 6px 5px 4px 42px; position: relative; color: #444; line-height: 20px; border: 1px solid #d2d2d2; background: #fff; background: -webkit-gradient(linear, 0 0, 0 100%, from(#d9eaf3), color-stop(4%, #fff)) 0 4px; background: -webkit-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -moz-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -ms-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: -o-linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; background: linear-gradient(top, #d9eaf3 0%, #fff 8%) 0 4px; -webkit-background-size: 100% 20px; -moz-background-size: 100% 20px; -ms-background-size: 100% 20px; -o-background-size: 100% 20p
@stdrc
stdrc / gist:fb9a64ab20e752d02a3b
Last active September 10, 2015 07:19
PHP 获取字符串长度(而非字节数)
<?php
$str = 'Hello,世界!';
preg_match_all('/./us', $str, $match);
echo count($match[0]); // 输出9
?>
@stdrc
stdrc / gist:ab006e9dfe64a613522b
Last active November 24, 2022 09:47
将 NSString 字符串转换成 Unicode 编码(形如 \u597d)
+ (NSString *)unicodeStringWithString:(NSString *)string {
NSString *result = [NSString string];
for (int i = 0; i < [string length]; i++) {
result = [result stringByAppendingFormat:@"\\u%04x", [string characterAtIndex:i]];
/*
因为 Unicode 用 16 个二进制位(即 4 个十六进制位)表示字符,对于小于 0x1000 字符要用 0 填充空位,
所以使用 %04x 这个转换符, 使得输出的十六进制占 4 位并用 0 来填充开头的空位.
*/
}
return result;
@stdrc
stdrc / gist:cf8628436d0abcbb0ee2
Last active August 29, 2015 14:25
UITextField 点击 Return 后隐藏键盘
// 首先把 UITextField 的 delegate 设置成当前的 ViewController,
// 然后在 ViewController.m 里添加下面一个代理方法:
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
// 如果有多个文本框需要输入, 希望点`Return`跳到下一个, 就给下一个文本框的 outlet 发送 becomeFirstResponder 消息即可.
@stdrc
stdrc / gist:48543ed23872fb9b6d7a
Last active August 29, 2015 14:25
NSURLConnection 发送异步请求
// 代码如下:
[NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]
queue:[[NSOperationQueue alloc] init]
completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
//异步请求完成后的操作
}];
// 如果要在 completionHandler 中更改界面, 需要用以下代码:
@stdrc
stdrc / gist:017c6c2a714483a07f75
Last active August 29, 2015 14:25
UITextField 或 UITextView 中禁用部分指定操作(如复制、剪切)
// Create a subclass of `UITextField` or `UITextView`,
// and override the `canPerformAction:withSender:` method like following:
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if (action == @selector(copy:))
return NO;
return [super canPerformAction:action withSender:sender];
}