Skip to content

Instantly share code, notes, and snippets.

View mansourmoufid's full-sized avatar
💭
I may be slow to respond.

Mansour Moufid mansourmoufid

💭
I may be slow to respond.
View GitHub Profile
@mansourmoufid
mansourmoufid / bs4-abbr.py
Last active March 29, 2024 16:05
Add abbr tags to an HTML document using BeautifulSoup
import functools
import re
# import sys
import typing
import bs4
html = '''
<html>
import ctypes
import struct
import typing
import AVFoundation
import CoreMediaIO
import objc
Boolean = ctypes.c_ubyte
@mansourmoufid
mansourmoufid / macos-13.3.1-unicode-bug.py
Created April 30, 2023 18:24
macOS 13.3.1 can't open files with names in Unicode normal form C
import os
import unicodedata
def dump(s):
for character in s:
print('\t{}\t{}\t{}'.format(
character,
' '.join([hex(x) for x in character.encode('utf-8')]),
unicodedata.name(character),
))
@mansourmoufid
mansourmoufid / cvpixelbuffercreate.py
Created March 15, 2023 02:41
CVPixelBufferCreate in Python
import ctypes
import ctypes.util
import objc
# MacTypes.h
# typedef UInt32 FourCharCode
FourCharCode = ctypes.c_uint32
# typedef FourCharCode OSType;
@mansourmoufid
mansourmoufid / icns-Makefile
Last active February 28, 2023 21:28
Make a Mac app icon from an image
ICON?= bigimage.png
NAME:= myapp
SIPS:= sips --setProperty format png --setProperty formatOptions best
$(NAME).iconset: $(ICON)
$(SIPS) -Z 16 $(ICON) --out $(NAME)-16x16.png
$(SIPS) -Z 32 $(ICON) --out $(NAME)-32x32.png
$(SIPS) -Z 64 $(ICON) --out $(NAME)-64x64.png
$(SIPS) -Z 128 $(ICON) --out $(NAME)-128x128.png
class FourCC:
def __init__(self, code):
if isinstance(code, str):
code = sum([ord(c) << (i * 8) for i, c in enumerate(code)])
self.code = int(code)
def __int__(self):
return self.code

Keybase proof

I hereby claim:

  • I am eliteraspberries on github.
  • I am mansourmoufid (https://keybase.io/mansourmoufid) on keybase.
  • I have a public key ASDtNjLsWCSXX2es_FoRrHq57EJ9ERibJPLV452H6K-SQQo

To claim this, I am signing this object:

#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "str2long.h"
#if LONG_MAX == 9223372036854775807UL
#define LONG_MAX_DIGITS 19