Skip to content

Instantly share code, notes, and snippets.

View Cosmo's full-sized avatar
📎
It looks like you're looking at my profile. Would you like help?

Devran Cosmo Uenal Cosmo

📎
It looks like you're looking at my profile. Would you like help?
View GitHub Profile
@Cosmo
Cosmo / blender-auto-floor.py
Created June 9, 2023 08:25
Blender: Move Object to the floor's center (0,0,0)
import bpy
# Get the current context
current_context = bpy.context
# Iterate through all selected objects
for obj in current_context.selected_objects:
# Get the object's world matrix
world_matrix = obj.matrix_world
@Cosmo
Cosmo / TakeScreenshot.swift
Last active July 13, 2022 13:26
Take screenshot with Xcode Test Plans
#!/usr/bin/env xcrun swift
import Foundation
// Todos
// [ ] Create missing simulators if needed
// [ ] Test on fresh new install of macOS / Xcode
// [ ] Get scheme and testPlan from command line argument
@Cosmo
Cosmo / gist:fe78cde71085faf87a042d606e66edda
Created December 31, 2019 14:51
Betrunkener Engländer (Trinkspiel)
= Betrunkener Engländer (Trinkspiel)
Stell dir vor, Englisch hätte es nie gegeben.
== Regeln
- _ALLES_ wird übersetzt
- Sinngemäße als auch wortwörtliche Übersetzungen sind erlaubt
- Englische Redewendungen dürfen benutzt werden, wenn sie übersetzt werden
- Sollte es keine Übersetzung geben, muss eine Umschreibung benutzt werden.
@Cosmo
Cosmo / SwiftUI Interface.swift
Created November 15, 2019 08:26
SwiftUI Interface (Module Names removed)
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.1.1 (swiftlang-1100.2.274.2 clang-1100.2.32.1)
// swift-module-flags: -target arm64e-apple-ios13.2 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Osize -module-name SwiftUI
import Combine
import CoreData
import CoreFoundation
import CoreGraphics
import CoreText
import Darwin
import Foundation
@Cosmo
Cosmo / SwiftUI-SymbolTable.swift
Created November 7, 2019 06:50
Name List / Symbol Table of SwiftUI
(extension in :Animatable< where A.AnimatableData == EmptyAnimatableData>.animatableData.getter : EmptyAnimatableData
(extension in :Animatable< where A.AnimatableData == EmptyAnimatableData>.animatableData.modify : EmptyAnimatableData
(extension in :Animatable< where A.AnimatableData == EmptyAnimatableData>.animatableData.setter : EmptyAnimatableData
(extension in :Animatable< where A: VectorArithmetic>.animatableData.getter : A
(extension in :Animatable< where A: VectorArithmetic>.animatableData.modify : A
(extension in :Animatable< where A: VectorArithmetic>.animatableData.setter : A
(extension in :Button< where A == PrimitiveButtonStyleConfiguration.Label>.init(PrimitiveButtonStyleConfiguration) -> Button<PrimitiveButtonStyleConfiguration.Label>
(extension in :Button< where A == Text>.init(_: LocalizedStringKey, action: () -> ()) -> Button<Text>
(extension in :Button< where A == Text>.init<A where A1: StringProtocol>(_: A1, action: () -> ()) -> Button<Text>
(extension in :CoreGraphics.CGFloat.magnitudeSqu
import Combine
import CoreData
import CoreFoundation
import CoreGraphics
import CoreText
import Darwin
import Foundation
import SwiftUI
import UIKit
import os.log
@Cosmo
Cosmo / moin.rb
Last active July 31, 2019 07:08
Different ways to say "moin" (hello in german) in Ruby.
# July 16, 2019
"bdic".tr("a-e", "l-p")
# July 17, 2019
require 'zlib'
Zlib.inflate("x\x9C\xCB\xCD\xCF\xCC\x03\x00\x04E\x01\xB4")
# July 18, 2019
"$;6]I;@``\n".unpack1("u")
@Cosmo
Cosmo / moin.swift
Last active July 30, 2019 06:28
Different ways to say "moin" (hello in german) in Swift.
import Foundation
// July 1, 2019
print([109, 111, 105, 110].map { String(UnicodeScalar($0)) }.joined())
// July 2, 2019
var hex: UInt32 = 0x6E696F6D
let data = Data(bytes: &hex, count: MemoryLayout<UInt32>.size)
String(data: data, encoding: String.Encoding.ascii)
@Cosmo
Cosmo / Microsoft-Teams-GPU-Fixer.sh
Last active August 11, 2022 00:25
Disable GPU usage for Microsoft Teams
APP=TeamsFixer
mkdir -vp ${APP}.app/Contents/MacOS ${APP}.app/Contents/Resources
PATH="$PATH:/usr/libexec"
printf '#!/usr/bin/env bash\nexec /Applications/Microsoft\ Teams.app/Contents/MacOS/Teams --disable-gpu' > ${APP}.app/Contents/MacOS/${APP}
chmod +x ${APP}.app/Contents/MacOS/${APP}
cp /Applications/Microsoft\ Teams.app/Contents/Resources/icon.icns ${APP}.app/Contents/Resources/icon.icns
PlistBuddy ${APP}.app/Contents/Info.plist -c "add CFBundleDisplayName string ${APP}"
PlistBuddy ${APP}.app/Contents/Info.plist -c "add CFBundleIconFile string icon.icns"
PlistBuddy ${APP}.app/Contents/version.plist -c "add ProjectName string ${APP}"
find ${APP}.app
@Cosmo
Cosmo / DataExtensions.swift
Last active March 19, 2019 01:17
Shift [UInt8] / Data in Swift
extension Data {
/// Returns a new `Data` shifted by the number of given bits.
///
/// - parameter bits: Number of bits the data to be shifted.
/// - returns: The shifted data.
func shifted(byBits bits: Int) -> Data {
let bitWidth = UInt8.bitWidth
var previousByte = UInt8()
return Data(bytes: self.shifted(byBytes: bits / bitWidth).map {
let result: UInt8 = ($0 >> (bits % bitWidth)) | (previousByte << (bits % bitWidth))