Skip to content

Instantly share code, notes, and snippets.

View martin-cotta's full-sized avatar

Martin Cotta martin-cotta

  • San Francisco Bay Area
View GitHub Profile
@martin-cotta
martin-cotta / kill-process-by-port.sh
Last active April 6, 2022 15:59
Kill process on specific port
# sudo lsof -i :<PortNumber>
# kill -9 <PID>
# or
# kill -9 $(lsof -ti:<Port>, <Port>)
# The -t flag removes everything but the PID from the lsof output
# Error: listen EADDRINUSE: address already in use ::::3000
$ lsof -i tcp:3000
# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
@martin-cotta
martin-cotta / delete-node-modules.md
Created February 13, 2021 20:11
Delete node_modules folders recursively

Delete node_modules recursively

cd directory-to-prune

# delete all node_modules in a single rm command
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +

# or delete folders one by one printing the folder being deleted
find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' \;
@martin-cotta
martin-cotta / android-read-apk-permission.md
Last active October 6, 2020 05:20
Android: Read APK permissions

Read the permissions from the manifest of my-app.apk

aapt2 d permissions my-app.apk

package: com.google.app
uses-permission: name='android.permission.RECEIVE_BOOT_COMPLETED'
uses-permission: name='android.permission.ACCESS_WIFI_STATE'
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
@martin-cotta
martin-cotta / secinternal.md
Created September 17, 2018 00:22
Xcode signing error: /usr/bin/codesign failed with errSecInternalComponent

errSecInternalComponent = -2070
An internal component experienced an error

This may occurs when the login keychain is locked, unlocked with:

security unlock-keychain login.keychain

or, Go to Keychain Access and toggle once the lock/unlock icon for Login (keep it unlock)

@martin-cotta
martin-cotta / script.sh
Created September 3, 2018 00:24
Create a shell script file
#!/bin/bash
echo "Hello World"
# make it executable: chmod +x script.sh or chmod u+x script.sh
# Place it under /usr/local/bin folder.(optional)
@martin-cotta
martin-cotta / delete-form-data.md
Created August 30, 2018 21:27
Delete saved form data

When you type in a form field, a menu may appear, containing past text that you've typed in the field. To delete a specific piece of saved text, select it in the menu using the arrows on your keyboard, then press Shift+Delete.

@martin-cotta
martin-cotta / ssh-keys.sh
Last active August 29, 2018 04:57
Set up an SSH key
# Generate public/private rsa key pair
ssh-keygen
# Add the key to the ssh-agent
eval `ssh-agent`
ssh-add -K ~/.ssh/id_rsa
# Copy public key content
pbcopy < ~/.ssh/id_rsa.pub
@martin-cotta
martin-cotta / apple-remote-desktop.md
Created September 5, 2017 02:24
Apple's Remote Desktop Software

Go to /System/Library/CoreServices/Applications/

In that folder, you’ll see an app called Screen Sharing, create a shortcut in your Applications folder (drag & drop with Command+Option)

This App works just like Remote Desktop, and can even save passwords in your system’s Keychain.
Just enter a hostname and remember to enable "Screen Sharing" on the destination machine before starting!

#!/bin/bash
set -e
# all the available versions at: https://nodejs.org/dist
NODE_VERSION="v8.1.0"
CURRENT_VERSION=""
install_node() {
echo "downloading and installing node $NODE_VERSION, sudo password might be required"
curl "https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}.pkg" > "$HOME/Downloads/node-installer.pkg"
import Foundation
import React
@objc(MyModule)
class MyModule: RCTEventEmitter {
@objc func loadProducts(_ orderId: NSNumber, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
let products = // load products somehow ...
if products {
resolve(products);