Skip to content

Instantly share code, notes, and snippets.

View kaishin's full-sized avatar

Reda Lemeden kaishin

View GitHub Profile
@kaishin
kaishin / ContentView.swift
Created June 10, 2022 07:59
PhotosPicker WWDC Sample
import PhotosUI
import CoreTransferable
import SwiftUI
struct ContentView: View {
@ObservedObject var viewModel: FilterModel = .shared
var body: some View {
NavigationStack {
Gallery()
@kaishin
kaishin / Example.swift
Last active March 18, 2023 12:14
StickySheet – A sticky sheet implementation for SwiftUI
enum PresentedSheet: String, Identifiable {
case sticky, standard
var id: String {
return self.rawValue
}
}
extension String: Identifiable {
public var id: String {
SwiftUI Headers
#snippets
import Combine
import CoreData
import CoreFoundation
import CoreGraphics
import CoreText
import Darwin
@kaishin
kaishin / ATS.plist
Created November 6, 2016 17:35
ATS Sample
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>redalemeden.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTKemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
@kaishin
kaishin / snapshot.swift
Created January 10, 2016 14:29
NSView Snapshot
extension NSView {
var snapshot: NSImage {
guard let bitmapRep = bitmapImageRepForCachingDisplayInRect(bounds) else { return NSImage() }
bitmapRep.size = bounds.size
cacheDisplayInRect(bounds, toBitmapImageRep: bitmapRep)
let image = NSImage(size: bounds.size)
image.addRepresentation(bitmapRep)
return image
}
}
#import <mach-o/dyld.h>
#import <objc/runtime.h>
#import <WebKit/WebKit.h>
@interface WKScriptMessage (WKScriptMessageLeakFix)
@end
@implementation WKScriptMessage (WKScriptMessageLeakFix)
+ (void)load {
#! /bin/sh
var1=`sudo du -sh /Users/$USER/Library/Logs`
var2=`sudo du -sh /Library/Caches`
var3=`sudo du -sh /Users/$USER/Library/Caches`
var4=`sudo du -sh /var/folders/*`
var5=`sudo du -sh /System/Library/Caches`
var7=`sudo du -sh /Users/$USER/Library/Safari/Downloads.plist`
var8=`sudo du -sh /Library/Logs`
sudo rm -rf /Library/Logs
@kaishin
kaishin / docker-compose-coreos.sh
Last active August 29, 2015 14:16
Docker Snippets
$ curl -s -L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
$ sudo mkdir -p /opt/bin
$ sudo mv ~/docker-compose /opt/bin/docker-compose
$ sudo chown root:root /opt/bin/docker-compose
$ sudo chmod +x /opt/bin/docker-compose
@kaishin
kaishin / ffmpeg.sh
Created February 23, 2015 15:34
ffmpeg 2-pass encoding
ffmpeg -i source.mp4 -pass 1 -codec:v libvpx -b:v 650k -codec:a libvorbis -b:a 100k -s 640x360 -f webm -y /dev/null
ffmpeg -i source.mp4 -pass 2 -codec:v libvpx -b:v 650k -codec:a libvorbis -b:a 100k -s 640x360 -y output.webm
GIT_RELEASE_VERSION=$(git describe --tags --always --abbrev=0)
COMMITS=$(git rev-list HEAD | wc -l)
COMMITS=$(($COMMITS+1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${COMMITS}" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${GIT_RELEASE_VERSION#*v}" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"