Skip to content

Instantly share code, notes, and snippets.

View lai3d's full-sized avatar
🎯
Focusing

Larry Lai lai3d

🎯
Focusing
  • Singapore
View GitHub Profile
@lai3d
lai3d / cpp_time_bomb
Created July 16, 2019 05:35 — forked from AlekseiCherkes/cpp_time_bomb
C++ time bomb
#include <ctime>
#include <iostream>
#include <string>
#include <sstream>
//-----------------------------------------------------------------------------
// Notes:
// 1) You should make full project rebuild during customer build
// 2) Keep error handling simple: just print message to cout and call exit(-1)
// 3) You can customize the number of days in evaluation period:
@lai3d
lai3d / GenerateCircleMesh.cs
Created January 21, 2019 04:24 — forked from olegknyazev/GenerateCircleMesh.cs
Generation of a circle mesh (Unity)
private const int CircleSegmentCount = 64;
private const int CircleVertexCount = CircleSegmentCount + 2;
private const int CircleIndexCount = CircleSegmentCount * 3;
private static Mesh GenerateCircleMesh()
{
var circle = new Mesh();
var vertices = new List<Vector3>(CircleVertexCount);
var indices = new int[CircleIndexCount];
var segmentWidth = Mathf.PI * 2f / CircleSegmentCount;
@lai3d
lai3d / FRP iOS Learning resources.md
Created September 11, 2017 09:29 — forked from JaviLorbada/FRP iOS Learning resources.md
The best FRP iOS resources.

Videos

@lai3d
lai3d / ioslocaleidentifiers.csv
Created December 6, 2016 09:21 — forked from JaseHadd/ioslocaleidentifiers.csv
iOS Locale Identifiers
localeIdentifier Description
eu Basque
hr_BA Croatian (Bosnia & Herzegovina)
en_CM English (Cameroon)
rw_RW Kinyarwanda (Rwanda)
en_SZ English (Swaziland)
tk_Latn Turkmen (Latin)
he_IL Hebrew (Israel)
ar Arabic
uz_Arab Uzbek (Arabic)
@lai3d
lai3d / Output Android Icons.jsx
Created July 27, 2016 03:16 — forked from tlinkner/Output Android Icons.jsx
Photoshop script to output Android icons
// Output Android Icons.jsx
// 2012 Todd Linkner
// License: none (public domain)
// v1.0
//
// This script is for Photoshop CS6. It outputs Android icons of the
// following sizes from a source PSD at least 512px x 512px
//
// store:
// Icon.png (512px x 512px)
@lai3d
lai3d / Create iOS Icons 2016 Sizes.jsx
Created May 16, 2016 06:38 — forked from alexsdesign/Create iOS Icons 2016 Sizes.jsx
Photoshop Script to Create iOS Icons from a source image
// Photoshop Script to Create iPhone Icons from iTunesArtwork
//
// WARNING!!! In the rare case that there are name collisions, this script will
// overwrite (delete perminently) files in the same folder in which the selected
// iTunesArtwork file is located. Therefore, to be safe, before running the
// script, it's best to make sure the selected iTuensArtwork file is the only
// file in its containing folder.
//
// Copyright (c) 2010 Matt Di Pasquale
// Added tweaks Copyright (c) 2012 by Josh Jones http://www.appsbynight.com
@lai3d
lai3d / Create iOS Icons.jsx
Created May 16, 2016 06:37 — forked from twonjosh/Create iOS Icons.jsx
Photoshop Script to Create iOS Icons from a source image
// Photoshop Script to Create iPhone Icons from iTunesArtwork
//
// WARNING!!! In the rare case that there are name collisions, this script will
// overwrite (delete perminently) files in the same folder in which the selected
// iTunesArtwork file is located. Therefore, to be safe, before running the
// script, it's best to make sure the selected iTuensArtwork file is the only
// file in its containing folder.
//
// Copyright (c) 2010 Matt Di Pasquale
// Added tweaks Copyright (c) 2012 by Josh Jones http://www.appsbynight.com
@lai3d
lai3d / Output iOS Icons.jsx
Last active May 16, 2016 08:49 — forked from tlinkner/Output iOS Icons.jsx
Photoshop script to output iOS icons, now with iOS 9 sizes.
// Output iOS Icons.jsx
// 2014 Todd Linkner
// 2016 Larry Lai
// License: none (public domain)
// v1.3
//
// This script is for Photoshop CC 2015. It outputs iOS icons of the following
// sizes from a source 1024px x 1024px PSD
//
// [name]-29.png

卤煮刚被web大潮淘汰到ios,当听说写oc要手动释放内存的时候如丧考妣,不过幸运的是ARC来了,妈妈再也不用担心我内存泄漏了。不过根据卤煮多年开发经验,和内存相关的不可能没有坑,开心之余还是得了解下oc是怎么搞内存的。

[TOC]

MRR和retainCount

OC对象都有一个属性 retainCount 表明这个对象还有几个引用, 当retainCount为0, 说明这个对象没人用了,runtime就会回收掉。而所谓的内存泄漏就是明明没人用了,retainCount却不是0,runtime没有回收掉这个对象。

retain and release

@lai3d
lai3d / pptpd.sh
Created August 3, 2013 11:54 — forked from yinhm/pptpd.sh
# Automaticlly install pptpd on Amazon EC2 Amazon Linux
#
# Ripped from http://blog.diahosting.com/linux-tutorial/pptpd/
# pptpd source rpm packing by it's authors
#
# WARNING:
# first ms-dns setting to 172.16.0.23, 172.16.0.23 was showing on my
# /etc/resolv.conf, I'm not sure this is the same on all Amazon AWS zones.
#
# You need to adjust your "Security Groups" which you are using too.