Skip to content

Instantly share code, notes, and snippets.

@eddieh
eddieh / chroot-env-on-mac.org
Created July 28, 2021 19:43
chroot Environments on macOS (draft)

chroot Environments on macOS

This is a draft.

macOS doesn’t have many of the advanced Linux or UNIX features that have come about in the past 20 years. So getting a proper chroot environment up and running takes a little more work.

@DusanBrejka
DusanBrejka / ffmpeg-format-to-mimetype.js
Last active November 28, 2023 05:12
FFMPEG - map of formats to default mime types
// INCOMPLETE
// This command will give you list of available FFMPEG formats and their default Mime types
// ffmpeg -formats -hide_banner | tail -n +5 | cut -c5- | cut -d' ' -f1 | xargs -i{} ffmpeg -hide_banner -h demuxer={} | pcregrep -o2 -o4 -M '(Muxer (\w+) )|(Mime type:( .*).)'
// And then parse the output with regex to JSON format in JavaScript for example:
// str.match(/(.*)\n (.*)/gm).map(m => `"${m.replace(/\n /, '": "')}"`).join(',\n');
// Combine the output with MDN - Common MIME types
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
// And with IANA:
@murphypei
murphypei / safe_queue.h
Last active August 16, 2023 17:28
C++ thread safe queue
#ifndef SAFE_QUEUE
#define SAFE_QUEUE
#include <condition_variable>
#include <mutex>
#include <queue>
// A threadsafe-queue.
template <class T>
class SafeQueue
@WoonHaKim
WoonHaKim / example.ios.yml
Last active July 17, 2023 03:43
GitHub Action iOS build workflow example
name: Example iOS Build
on:
push:
branches:
- development
jobs:
build-ios:
runs-on: macos-latest
@romainthomas
romainthomas / libg.patch.py
Last active July 22, 2021 06:57
Disable Frida checks
# Patch libg.so to remove Frida server checks
import lief
MOV_R0_ERROR = [0x4f, 0xf0, 0xff, 0x30] # MOV.W R0, #-1
PATCHES = [
# bind() syscall
(0x0BE000 - 2, MOV_R0_ERROR), # MOV R0, #-1
(0x0bb2e2 - 2, MOV_R0_ERROR), # MOV R0, #-1
(0x2518f6 - 2, MOV_R0_ERROR), # MOV R0, #-1
]
@LiewJunTung
LiewJunTung / RgbConversion.kt
Created July 13, 2019 18:21
Best solution YUV -> RGB
class RgbConversion(val rs: RenderScript, private val feedSize: Size, private val hasRotate: Boolean = true) {
private var mInputAllocation: Allocation? = null
private var mOutputAllocation: Allocation? = null
private var mRotatedAllocation: Allocation? = null
private val yuvToRgb = ScriptIntrinsicYuvToRGB.create(rs, Element.U8_4(rs))
private val rotator = ScriptC_rotator(rs)
var bufferCallback: ((ByteBuffer) -> Unit)? = null
val inputSurface: Surface
get() = mInputAllocation!!.surface
@ctrleffive
ctrleffive / android.java
Last active April 21, 2023 03:19
Flutter platform channel sample code.
// ...
import io.flutter.app.FlutterActivity;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
// ...
public class MainActivity extends FlutterActivity {
@cprovatas
cprovatas / BlockBasedSelector.h
Last active June 1, 2023 01:34
Block-Based Selectors in Swift
//
// BlockBasedSelector.h
//
// Created by Charlton Provatas on 11/2/17.
// Copyright © 2017 CharltonProvatas. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface BlockBasedSelector : NSObject
@tomykaira
tomykaira / java2smali.sh
Created September 9, 2017 17:52
Java to smali conversion, one liner.
#!/bin/sh
set -e
JAVA_HOME='/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home'
cd /tmp
cat > input_tmp.java <<EOF
public class input_tmp {
public static void main(String[] args) {
@danielgalasko
danielgalasko / RepeatingTimer.swift
Last active March 28, 2024 10:26
A repeating GCD timer that can run on a background queue
/// RepeatingTimer mimics the API of DispatchSourceTimer but in a way that prevents
/// crashes that occur from calling resume multiple times on a timer that is
/// already resumed (noted by https://github.com/SiftScience/sift-ios/issues/52
class RepeatingTimer {
let timeInterval: TimeInterval
init(timeInterval: TimeInterval) {
self.timeInterval = timeInterval
}