Skip to content

Instantly share code, notes, and snippets.

View xNekOIx's full-sized avatar
🇺🇦

Konstantin Bychkov xNekOIx

🇺🇦
View GitHub Profile
@marlosirapuan
marlosirapuan / gist:778d6beda5f8ab95695748011c864b19
Last active June 26, 2024 12:49
Download .m3u8 files on MacOS

Install ffmpeg

brew install ffmpeg

Download file through url, like this:

ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -i "http://url-file.domain.m3u8" -c copy video.mp4
@steipete
steipete / ios-xcode-device-support.sh
Last active December 12, 2023 03:36
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)
extension Future {
func then<U>(f: T -> Future<U>) -> Future<U> {
let promise = Promise<U>()
self.onFail { promise.fail() }.onSuccess {
f($0).onFail { promise.fail() }.onSuccess { promise.resolve($0) }
}
return promise.future
}
}
import Foundation
public struct Future<T> {
public let onFail: (() -> ()) -> Future<T>
public let onSuccess: (T -> ()) -> Future<T>
}
public class Promise<T> {
private var onFails = [] as [() -> ()]
private var onSuccesses = [] as [T -> ()]
@esavelyeva
esavelyeva / fs.to.playlist.script
Last active November 10, 2016 13:59
Go to http://bookmarklets.org/maker/ to generate the bookmarklet
//download.js v3.0, by dandavis; 2008-2014. [CCBY2] see http://danml.com/download.html for tests/usage
// v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime
// v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs
// v3 added dataURL and Blob Input, bind-toggle arity, and legacy dataURL fallback was improved with force-download mime and base64 support
// data can be a string, Blob, File, or dataURL
//: [Previous](@previous)
import Foundation
// One per function
final class Stub {
let name: String
let cmp: (AnyCall, AnyCall) -> Bool
init(name: String, cmp: (AnyCall, AnyCall) -> Bool) {
self.name = name
; ModuleID = 'main.m'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.11.0"
%0 = type opaque
%struct._class_t = type { %struct._class_t*, %struct._class_t*, %struct._objc_cache*, i8* (i8*, i8*)**, %struct._class_ro_t* }
%struct._objc_cache = type opaque
%struct._class_ro_t = type { i32, i32, i32, i8*, i8*, %struct.__method_list_t*, %struct._objc_protocol_list*, %struct._ivar_list_t*, i8*, %struct._prop_list_t* }
%struct.__method_list_t = type { i32, i32, [0 x %struct._objc_method] }
%struct._objc_method = type { i8*, i8*, i8* }
//: Playground - noun: a place where people can play
import UIKit
// Simple struct to be fullfilled from JSON
struct User {
let name: String
let age: Int
}
@oleksii-demedetskyi
oleksii-demedetskyi / ServiceLocator.swift
Last active December 12, 2020 05:04
Service locator in swift
//: Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
class ServiceLocator {
private var registry : [String: Any] = [:]
func registerService<T>(service: T) {
@mattt
mattt / regex.swift
Created August 11, 2014 18:08
Creating a regular expression object from a String literal
class Regex {
let pattern: String
let options: NSRegularExpressionOptions!
private var matcher: NSRegularExpression {
return NSRegularExpression(pattern: self.pattern, options: nil, error: nil)
}
required init(pattern: String, options: NSRegularExpressionOptions = nil) {
self.pattern = pattern