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
private func newPacketTunnelSettings(proxyHost: String, proxyPort: Int) -> NEPacketTunnelNetworkSettings {
let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: "127.0.0.1")
/* proxy settings */
let proxySettings = NEProxySettings()
proxySettings.httpServer = NEProxyServer(
address: proxyHost,
port: proxyPort
)
proxySettings.httpsServer = NEProxyServer(
@NghiaTranUIT
NghiaTranUIT / viewcontroller.swift
Created December 7, 2020 12:56
NSTextFiels check isFocus
import AppKit
// Credit: Vadim Shpakovski from AppKitAbusers
class ViewController: NSViewController {
let textField1: CustomTextField = .init(string: "Field 1")
let textField2: CustomTextField = .init(string: "Field 2")
var observation1: NSKeyValueObservation?
@NghiaTranUIT
NghiaTranUIT / script.js
Created October 23, 2020 06:03
Combine Map Local and Breakpoint with Scripting feature - Proxyman (https://proxyman.io)
// /Users/nghiatran/Library/Application Support/com.proxyman.NSProxy/users/D6B9C80C.default_message_683CE65F.json
const file = require("@users/D6B9C80C.default_message_683CE65F.json");
function onRequest(context, url, request) {
// Done
return request;
}
function onResponse(context, url, request, response) {
@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>
@NghiaTranUIT
NghiaTranUIT / proxyman_iOS_playground.swift
Created January 31, 2020 02:28
A workaround to enable SSL Proxying on iOS Swift Playground for Charles and Proxyman app. (swift 5)
// This workaround is only for iOS Swift Playground
// Don't need it on macOS Playground
import Foundation
// Accept all challenges from Charles or Proxyman for self-signed certificates
class NetworkSSlProxying: NSObject, URLSessionDelegate {
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
completionHandler(.useCredential, URLCredential(trust: challenge.protectionSpace.serverTrust!))
}
}
@NghiaTranUIT
NghiaTranUIT / iosCertTrustManager.py
Created December 12, 2019 04:37
iosCertTrustManager.py
#! /usr/bin/env python
# Script to manage additional trusted root certificate in the IOS simulator
#
# Allows to add/list/delete/export trusted root certificates to the IOS simulator
# TrustStore.sqlite3 file.
#
# Additionally, root certificates added to a device can be listed and exported from
# a device backup
#
This file has been truncated, but you can view the full file.
(lldb) thread backtrace
* thread #12
frame #0: 0x00007fff7d5c2304 libsystem_malloc.dylib`nanov2_size + 15
frame #1: 0x00007fff7d5b78a4 libsystem_malloc.dylib`free + 107
frame #2: 0x0000000100774be9 TogglDesktopLibrary.dylib`view_item_clear(item=0x0000600009c850c0) at toggl_api_private.cc:152:5
* frame #3: 0x0000000100774c4b TogglDesktopLibrary.dylib`view_item_clear(item=0x0000600009c85100) at toggl_api_private.cc:164:9
frame #4: 0x0000000100774c4b TogglDesktopLibrary.dylib`view_item_clear(item=0x0000600009c85140) at toggl_api_private.cc:164:9
frame #5: 0x0000000100774c4b TogglDesktopLibrary.dylib`view_item_clear(item=0x0000600009c85180) at toggl_api_private.cc:164:9
frame #6: 0x0000000100774c4b TogglDesktopLibrary.dylib`view_item_clear(item=0x0000600009c851c0) at toggl_api_private.cc:164:9
frame #7: 0x0000000100774c4b TogglDesktopLibrary.dylib`view_item_clear(item=0x0000600009c85200) at toggl_api_private.cc:164:9
@NghiaTranUIT
NghiaTranUIT / manifest.md
Created August 7, 2018 10:01
Android Certificate - Proxyman

Then adding this following code to your app's manifest.

<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
    <application android:networkSecurityConfig="@xml/network_security_config" ... >
        ...
    </application>
</manifest>