Skip to content

Instantly share code, notes, and snippets.

View dehengxu's full-sized avatar
🐈
Focusing

DehengXu dehengxu

🐈
Focusing
  • BeiJing.China
View GitHub Profile
@dehengxu
dehengxu / codesign_gdb.md
Created July 15, 2018 04:51 — forked from hlissner/codesign_gdb.md
Codesign gdb on OSX

Note: these instructions are for pre-Sierra MacOS. Sierra Users: see https://gist.github.com/gravitylow/fb595186ce6068537a6e9da6d8b5b96d by @gravitylow.

If you are getting this in gdb on OSX while trying to run a program:

Unable to find Mach task port for process-id 57573: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
  1. Open Keychain Access

使用 gdb 在 macOS 上进行调试

步骤1: 为 gdb 签名

  1. 在你的系统KeyChain 中创建一个自签名的根证书,用途选择 代码签名codesign,我的证书常用名为 gdb-cert
  2. 配置该证书的 codesign 为始终信任
  3. 用这个证书来为 gdb 程序签名。 codesign -fs gdb-cert /usr/local/Cellar/gdb/8.0.1/bin/gdb

步骤2: 启动 gdb

  1. gdb
  2. 通过 file 指令加载目标执行文件。file ./build/a.out
@dehengxu
dehengxu / osx_setup.md
Last active February 20, 2019 05:20 — forked from mcls/osx_setup.md
Setup mac for ruby dev

Setup new Mac from scratch

Re-create admin user

  1. Reboot with command + s
  2. Enter /sbin/mount -uw in Terminal
  3. rm var/db/.AppleSetupDone Remove cache data.
  4. Reboot again.

Install Xcode

server {
listen 80;
server_name www.example.com;
root /var/www/vhosts/example.com/public/;
location /
{
index index.php index.html index.htm;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
NSString *identifier = @"_collection_view_cell_identifier";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
if (!cell) {
cell = [[UICollectionViewCell alloc] initWithFrame:CGRectMake(0, 0, 48, 48)];
}
return cell;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *identifier = @"_table_view_cell_identifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
if (cell) {