Skip to content

Instantly share code, notes, and snippets.

View NghiaTranUIT's full-sized avatar
💭
Workaholic 👨‍💻

Noah Tran NghiaTranUIT

💭
Workaholic 👨‍💻
View GitHub Profile

The correct way, install homebrew on apple m1.

# We'll be installing Homebrew in the /opt directory.
cd /opt

# Create a directory for Homebrew. This requires root permissions.
sudo mkdir homebrew

# Make us the owner of the directory so that we no longer require root permissions.
sudo chown -R $(whoami) /opt/homebrew
@NghiaTranUIT
NghiaTranUIT / JavaScriptCore+fetch.swift
Created October 22, 2020 01:55 — forked from yycking/JavaScriptCore+fetch.swift
add fetch, console.log and Promise.then/catch to JavaScriptCore on iOS/Mac
import JavaScriptCore
extension JSContext {
subscript(key: String) -> Any {
get {
return self.objectForKeyedSubscript(key)
}
set{
self.setObject(newValue, forKeyedSubscript: key as NSCopying & NSObjectProtocol)
}
@NghiaTranUIT
NghiaTranUIT / sslconnect.c
Created May 13, 2020 16:35 — forked from endSly/sslconnect.c
Example code for building a SSL connection and retrieving the server certificate
/* ------------------------------------------------------------ *
* file: sslconnect.c *
* purpose: Example code for building a SSL connection and *
* retrieving the server certificate *
* author: 06/12/2012 Frank4DD *
* *
* gcc -lssl -lcrypto -o sslconnect sslconnect.c *
* ------------------------------------------------------------ */
#include <sys/socket.h>
internal let DEFAULT_MIME_TYPE = "application/octet-stream"
internal let mimeTypes = [
"html": "text/html",
"htm": "text/html",
"shtml": "text/html",
"css": "text/css",
"xml": "text/xml",
"gif": "image/gif",
"jpeg": "image/jpeg",
@NghiaTranUIT
NghiaTranUIT / TaskConcurrencyManifesto.md
Created August 18, 2017 10:45 — forked from lattner/TaskConcurrencyManifesto.md
Task-based concurrency manifesto draft

Concurrency in Swift: One possible approach

Introduction

This document is published in the style of a "Swift evolution manifesto", outlining a long-term view of how to tackle a very large problem. It explores one possible approach to adding a first-class concurrency model to Swift, in an effort to catalyze positive discussion that leads us to a best-possible design. As such, it isn't an approved or finalized design

@NghiaTranUIT
NghiaTranUIT / gist:6085141eb8f319adad6603969bfc5b33
Created May 2, 2016 04:20 — forked from masonforest/gist:4048732
Installing a Gem on Heroku from a Private GitHub Repo

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

  1. Get an OAuth Token from GitHub

First you will need to get an OAuth Token from GitHub using your own username and "note"

Difference between Debounce and Throttle

Debounce

Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.

Throttle

@NghiaTranUIT
NghiaTranUIT / introrx.md
Created February 19, 2016 13:54 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@NghiaTranUIT
NghiaTranUIT / PSPDFUIKitMainThreadGuard.m
Created November 25, 2015 14:35 — forked from steipete/PSPDFUIKitMainThreadGuard.m
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
@NghiaTranUIT
NghiaTranUIT / BaseModel.h
Created November 16, 2015 12:53 — forked from onmyway133/BaseModel.h
BaseModel Model -> SQLite statement using property inspection
#import <Mantle.h>
@interface BaseModel : MTLModel <MTLJSONSerializing>
@property (nonatomic) int64_t id;
@property (nonatomic) NSTimeInterval createdUtc;
@property (nonatomic) NSTimeInterval modifiedUtc;
- (NSString *)createTableStatement;
- (NSString *)className;