Skip to content

Instantly share code, notes, and snippets.

View cupnoodle's full-sized avatar

soulchild cupnoodle

View GitHub Profile
@cupnoodle
cupnoodle / AuthCatPro.txt
Created August 8, 2020 17:36
Promo code for AuthCat Pro
E4FJWY7HTNR9
XFMYMLFR4NNX
H9RYJR3P3TMK
X9YLTNFNPL6M
3J3WRRFAHMEM
A47NLRR7HEE4
EEFAHPR6HKM4
9RYXHJTMTKHT
JPT9MRYPHL69
YLN6FYPXTMRL
@cupnoodle
cupnoodle / IAPHelper.swift
Created July 21, 2020 09:51
In app purchase helper class
// Created by Soulchild on 21/07/2020.
// Copyright © 2020 fluffy. All rights reserved.
//
import Foundation
import StoreKit
// Need to install the TPInAppReceipt library first
import TPInAppReceipt
@cupnoodle
cupnoodle / toggleSync.md
Last active November 13, 2023 15:11
Disable sync of NSPersistentCloudKitContainer at launch, then enable sync later

To disable iCloud sync of core data when the app launches, set the cloudKitContainerOptions to nil for the persistent store.

In your AppDelegate.swift file :

lazy var persistentContainer: NSPersistentCloudKitContainer = {

        let container = NSPersistentCloudKitContainer(name: "your core data container name")
        
        guard let description = container.persistentStoreDescriptions.first else {
            fatalError("###\(#function): Failed to retrieve a persistent store description.")
@cupnoodle
cupnoodle / proportional.md
Created July 4, 2020 15:32
Proportional Auto Layout Constraint

4 - Using proportion to make layout looks good across different screen size

Ever encounter this? You've put a lot of effort on designing layout / UI for your app in Xcode, finally it looks good after spending hours tweaking it, but when you view it in another device with different screen size, it either looks too cramped with UILabels overlapping each other, or it looks too spacious with a lot of blank space between each elements.

Say you have designed two views to align side by side in iPhone 8 with a fixed width for both of them :

fixedWidth8

<p><code class="highlight">&lt;span class="kd"&gt;struct&lt;/span&gt; &lt;span class="kt"&gt;Person&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;</code>
</p>
<p><code class="highlight"> &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;</code>
</p>
<p><code class="highlight"> &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;middleName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;</code>
</p>
<p><code class="highlight"> &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt;</code>
</p>
<p><code class="highlight">&lt;span class="p"&gt;}&lt;/span&gt;</code>
</p>
@cupnoodle
cupnoodle / convertkit.html
Created May 27, 2020 11:30
sample code highlight
<code class="highlight"><span class="kd">struct</span> <span class="kt">Person</span> <span class="p">{</span>
<span class="k">let</span> <span class="nv">firstName</span><span class="p">:</span> <span class="kt">String</span>
<span class="k">let</span> <span class="nv">middleName</span><span class="p">:</span> <span class="kt">String</span>
<span class="k">let</span> <span class="nv">lastName</span><span class="p">:</span> <span class="kt">String</span>
<span class="p">}</span></code>
@cupnoodle
cupnoodle / command.txt
Last active May 6, 2020 05:04
Install Ruby using Rbenv homebrew ssl
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept
brew install openssl
RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl)" rbenv install 2.6.5
brew install postgresql
brew services start postgresql
brew install redis
@cupnoodle
cupnoodle / solve_uninitialized_constant.md
Last active April 30, 2020 14:34
Solving Name Error Uninitialized constant for Sidekiq job

Solving Name Error Uninitialized constant for Sidekiq job

This guide is for you if you have attempted steps below but still has issue :

  1. Double checked the file name and folder structure, and it did follow Rails convention
  2. Added auto load and eager load path
  3. All previous jobs ran successfully, but only this new job you added has this uninitialized constant
  4. This issue only happens in your production / staging server , but it worked fine in your local development machine
  5. Sometimes the job executed successfully, sometimes you get the uninitialized constant error
@cupnoodle
cupnoodle / UILabel+isTruncated.swift
Created February 4, 2020 17:26
Check if UILabel is truncated
extension UILabel {
var isTruncated: Bool {
guard let labelText = text else {
return false
}
let labelTextSize = (labelText as NSString).boundingRect(
with: CGSize(width: frame.size.width, height: .greatestFiniteMagnitude),
options: .usesLineFragmentOrigin,
attributes: [.font: font!],
@cupnoodle
cupnoodle / imagemagick.sh
Created December 16, 2019 17:28
Install ImageMagick on Ubuntu 18.04 with HEIF / HEIC support
sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
sudo apt-get update
sudo apt-get install build-essential autoconf libtool git-core
sudo apt-get build-dep imagemagick libmagickcore-dev libde265 libheif
cd /usr/src/
sudo git clone https://github.com/strukturag/libde265.git
sudo git clone https://github.com/strukturag/libheif.git
cd libde265/
sudo ./autogen.sh
sudo ./configure