Skip to content

Instantly share code, notes, and snippets.

View donly's full-sized avatar
🎯
Focusing

Tung donly

🎯
Focusing
View GitHub Profile
import Foundation
/**
Set FourCharCode/OSType using a String.
Examples:
let test: FourCharCode = "420v"
let test2 = FourCharCode("420f")
print(test.string, test2.string)
*/
@donly
donly / getMacUUID.swift
Last active April 7, 2022 07:09 — forked from ericdke/getMacUUID.swift
Swift: get the Mac UUID
func getSystemUUID() -> String? {
let dev = IOServiceMatching("IOPlatformExpertDevice")
let platformExpert: io_service_t = IOServiceGetMatchingService(kIOMasterPortDefault, dev)
let serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert, kIOPlatformUUIDKey as CFString, kCFAllocatorDefault, 0)
IOObjectRelease(platformExpert)
guard let ser: CFTypeRef = serialNumberAsCFString?.takeUnretainedValue() else { return nil }
if let result = ser as? String {
return result
@donly
donly / sh.sh
Last active February 14, 2023 20:38 — forked from scottopell/sh.sh
Embed SRT file into mp4 with ffmpeg
# got this from http://stackoverflow.com/questions/8672809/use-ffmpeg-to-add-text-subtitles
ffmpeg -i infile.mp4 -f srt -i infile.srt -c:v copy -c:a copy -c:s mov_text -metadata:s:s:0 language=chi outfile.mp4
# confirmed working with the following ffmpeg
# (installed using `brew 'ffmpeg', args: ['with-libvorbis', 'with-libvpx']` )
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libx
@donly
donly / default.custom.yaml
Created July 13, 2016 05:23 — forked from lotem/default.custom.yaml
在Rime輸入方案選單中添加五筆、雙拼、粵拼、注音,保留你需要的
# default.custom.yaml
# save it to:
# ~/.config/ibus/rime (linux)
# ~/Library/Rime (macos)
# %APPDATA%\Rime (windows)
patch:
schema_list:
- schema: luna_pinyin # 朙月拼音
- schema: luna_pinyin_simp # 朙月拼音 简化字模式
@donly
donly / routeOnMap.m
Last active January 20, 2016 07:45 — forked from siqin/routeOnMap.m
Draw route on MKMapView
#pragma mark -
- (void)drawTestLine
{
// test code : draw line between Beijing and Hangzhou
CLLocation *location0 = [[CLLocation alloc] initWithLatitude:39.954245 longitude:116.312455];
CLLocation *location1 = [[CLLocation alloc] initWithLatitude:30.247871 longitude:120.127683];
NSArray *array = [NSArray arrayWithObjects:location0, location1, nil];
[self drawLineWithLocationArray:array];
}
@donly
donly / gist:1367070
Created November 15, 2011 13:28 — forked from wwhhjj/gist:1366956
再次提醒注意代码书写风格!
#include <stdio.h>
int main (int argc, const char * argv[]) {
int a, b, i, t;
scanf("%d%d", &a, &b);
if (a < b) {
t = a;
@donly
donly / good.c
Created October 26, 2011 08:50 — forked from wwhhjj/gist:1315802
注意代码风格!
#include<stdio.h>
int main(void)
{
float a,r1,r2,m;
char b,c;
printf("请输入加油量,汽油类型(a,b,c)以及服务类型(f,m,e)\n");
printf("***************************************************\n");
printf("请输入:");
#include<stdio.h>
#include<windows.h>
#include<malloc.h>
int main(void)
{
int c;
int i;
int j;
nihao: