Skip to content

Instantly share code, notes, and snippets.

View ldenoue's full-sized avatar
🏔️

Laurent Denoue ldenoue

🏔️
View GitHub Profile
@ldenoue
ldenoue / getYouTubeStreams.js
Created December 28, 2024 16:58
Getting playable YouTube streams from the browser
/* get playable urls from any YouTube video in the browser (no CORS issues) */
const videoId='tEzs3VHyBDM';
const payload = {
videoId,
context: {
client: {
hl: "en",
clientName: "iOS",
clientVersion: "19.45.4"
@ldenoue
ldenoue / ContentView.swift
Created July 6, 2024 09:10
How to detect which mouse button is pressed over a SwiftUI button
struct ContentView: View {
@State private var localMonitor: Any?
@State var hovering = false
@State var mouseButton = -1
var body: some View {
Text("Mouse button")
Button(mouseButton > 1 ? "Button\(mouseButton)" : "Configure") {
}
.foregroundColor(.blue)
.frame(width: 96)
enter recovery mode on your Mac: restart and hold Cmd R
open Utilities -> Terminal
in the terminal, type: `csrutil disable`
restart your Mac
open a Terminal window and type: `systemextensionsctl list`
It will show something like:
```
1 extension(s)
--- com.apple.system_extension.cmio
if [ "$#" -eq 2 ]
then
mkdir $2
ffmpeg -y -i $1 -vf scale=16x16 $2/[email protected]
ffmpeg -y -i $1 -vf scale=32x32 $2/[email protected]
ffmpeg -y -i $1 -vf scale=32x32 $2/[email protected]
ffmpeg -y -i $1 -vf scale=64x64 $2/[email protected]
ffmpeg -y -i $1 -vf scale=128x128 $2/[email protected]
@ldenoue
ldenoue / ViewController.swift
Last active November 27, 2024 05:38
CATextLayer that scrolls text up as more text is added, constrained to n visible lines
override func viewDidLoad() {
super.viewDidLoad()
let text = """
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
"""
let fontSize = 88.0
let font = NSFont.systemFont(ofSize: fontSize)
let layer = makeScrollingTextLayer(text: text, width: 800, visibleLines: 3, font: font, timing: 0.2)
self.view.wantsLayer = true
self.view.layer?.addSublayer(layer)
import Foundation
import CoreMediaIO
let CMIOExtensionPropertyCustomPropertyData_just: CMIOExtensionProperty = CMIOExtensionProperty(rawValue: "4cc_just_glob_0000")
let CMIOExtensionPropertyCustomPropertyData_dust: CMIOExtensionProperty = CMIOExtensionProperty(rawValue: "4cc_dust_glob_0000")
...
class cameraStreamSource: NSObject, CMIOExtensionStreamSource {
{
"hello": "Salut",
"common.copy_url": "Copier l'URL de la salle de chat",
"common.copy_succ_hint": "Copié dans le presse-papiers",
"com.room_card.join_btn": "Joindre",
"index": {
"faq_title": "FAQ",
@ldenoue
ldenoue / showSpinner.m
Last active December 17, 2019 14:27
show and hide a fullscreen overlay UIView with a spinner; works even in Action/Share extensions that don't have [UIApplication sharedApplication]
#define OVERLAY_VIEW_TAG 298739
-(void)showSpinner
{
UIView *back = [[UIView alloc]initWithFrame:CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height)];
back.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
back.tag = OVERLAY_VIEW_TAG;
[self.view addSubview:back];
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.center = back.center;
@ldenoue
ldenoue / sharewkwebview.m
Created November 8, 2019 13:11
Capture and share the full content of a WKWebView as a UIImage
-(void)shareHighlightsAsImage:(NSDictionary *)note
{
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"quotes" ofType:@"html"];
NSString *fileContents = [NSString stringWithContentsOfFile: filePath encoding:NSUTF8StringEncoding error:nil];
fileContents = [fileContents stringByReplacingOccurrencesOfString:@"{{url}}" withString:note[@"url"]];
fileContents = [fileContents stringByReplacingOccurrencesOfString:@"{{title}}" withString:note[@"title"]];
fileContents = [fileContents stringByReplacingOccurrencesOfString:@"{{datetime}}" withString:note[@"datetime"]];
fileContents = [fileContents stringByReplacingOccurrencesOfString:@"{{highlights}}" withString:note[@"highlights"]];
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
@ldenoue
ldenoue / make-app-icon-ffmpeg.sh
Last active June 25, 2019 09:00
make app icon for iOS using ffmpeg
if [ "$#" -eq 2 ]
then
mkdir $2
ffmpeg -y -i $1 -vf scale=20x20 $2/[email protected]
ffmpeg -y -i $1 -vf scale=40x40 $2/[email protected]
ffmpeg -y -i $1 -vf scale=60x60 $2/[email protected]
ffmpeg -y -i $1 -vf scale=29x29 $2/[email protected]
ffmpeg -y -i $1 -vf scale=58x58 $2/[email protected]