Skip to content

Instantly share code, notes, and snippets.

View tmm1's full-sized avatar

Aman Gupta Karmani tmm1

View GitHub Profile
@chriso
chriso / http.go
Last active September 9, 2023 17:16
// Go HTTP Hello World Server + non-blocking I/O test.
//
// This requires gotip (https://pkg.go.dev/golang.org/dl/gotip) for:
// - https://github.com/golang/go/commit/41893389
// - https://github.com/golang/go/commit/c5c21845
// - https://github.com/golang/go/commit/a17de43e
//
// Compile http.wasm:
//
// $ GOOS=wasip1 GOARCH=wasm gotip build -o http.wasm http.go
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active March 11, 2024 22:57
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@sgdan
sgdan / gzip.kts
Last active February 10, 2024 20:16
Kotlin code to compress/uncompress a string with gzip
import java.io.ByteArrayOutputStream
import java.io.File
import java.nio.charset.StandardCharsets.UTF_8
import java.util.zip.GZIPInputStream
import java.util.zip.GZIPOutputStream
fun gzip(content: String): ByteArray {
val bos = ByteArrayOutputStream()
GZIPOutputStream(bos).bufferedWriter(UTF_8).use { it.write(content) }
return bos.toByteArray()
#import <Foundation/Foundation.h>
@interface KKSimpleAirPlay2Player : NSObject
- (id)initWithURL:(NSURL *)inURL;
- (void)play;
- (void)pause;
@property (readonly, getter=isStopped) BOOL stopped;
@end
@KatelynHaworth
KatelynHaworth / notifyAddrChange.go
Created June 22, 2017 05:03
A simple go program leveraging the Window API to listen for IPv4 network address change events
package main
import (
"log"
"syscall"
"unsafe"
"golang.org/x/sys/windows"
)
From c259a69c7e75f29d45fd0bbf47899d15e71e2e79 Mon Sep 17 00:00:00 2001
From: Llorx <dallorx@gmail.com>
Date: Sat, 6 Aug 2016 14:34:50 +0200
Subject: [PATCH] Bitrate on-the-fly PoC
---
ffmpeg.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 74 insertions(+), 1 deletion(-)
diff --git a/ffmpeg.c b/ffmpeg.c
#include <android/log.h>
#include <jni.h>
#include <binder/Binder.h>
#include <binder/Parcel.h>
#include <binder/IServiceManager.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@lrytz
lrytz / z-automator.png
Last active February 4, 2023 21:20
Shortcut for Syntax Highlighting in Keynote
@adelcambre
adelcambre / 00_tokyo.md
Last active August 29, 2015 14:06
Surviving tokyo

Some basics on Tokyo

Your phone should work

Just like in Europe. It's the same normal international data plan for most carriers (I've done it on At&t and Verizon).

Cash is king

And you get cash from 7-11 (yes I'm serious). American cards very very frequently don't work. Especially in any sort of machine, particularly vending machines and the train ticket machines. Many atm's won't take american cards either. But, every single 7-11 (which are everywhere) has an atm which takes american cards. They sometimes say 7-i, or Seven and i holdings. It's all the same thing (7-11 is actually a japanese company, and they are everywhere). Other than 7-11, every Post office should have an ATM that works too, but they are way less common.

@svagionitis
svagionitis / Create_Iframe_Index_M3U8.bash
Last active January 13, 2024 13:42
Segment an mp4 file to HLS streaming files
#!/bin/bash
# Create an Iframe index from HLS segmented streams
# $1: Filename to be created
# $2: Location of segmented ts files
# Check how many arguments
if [ $# != 2 ]; then
echo "Usage: $0 [Input filename] [Location of segmented streams]"
exit 1;
fi