Skip to content

Instantly share code, notes, and snippets.

View acotilla91's full-sized avatar

Alejandro Cotilla acotilla91

View GitHub Profile
@triwav
triwav / roku-proxy-setup.md
Created April 30, 2019 14:33
Roku Proxy Setup

This is largely based off of this article by Hulu and their roku-dev-cli tool.

Requirements:
The main requirement is a Mac with 2 available network interfaces WIFI <-> WIFI, LAN <-> WIFI, etc. This should work on other platforms as well but isn't covered here.

Setup
The first thing we need is Homebrew. If you've never used it before it's a great package manager for macOS that makes installing programs easier. Open Terminal and paste
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
and hit enter

@yusuke024
yusuke024 / ViewController.swift
Created November 16, 2018 03:15
Recording video with AVAssetWriter
import UIKit
import AVFoundation
class ViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .notDetermined:
@lanserxt
lanserxt / LoopedPlayerView.swift
Last active October 25, 2023 16:18
Loop playback with AVQueuePlayer and AVPlayerLooper
final class LoopedVideoPlayerView: UIView {
fileprivate var videoURL: URL?
fileprivate var queuePlayer: AVQueuePlayer?
fileprivate var playerLayer: AVPlayerLayer?
fileprivate var playbackLooper: AVPlayerLooper?
func prepareVideo(_ videoURL: URL) {
let playerItem = AVPlayerItem(url: videoURL)
@zenangst
zenangst / ImageView.swift
Last active April 14, 2021 21:33
Round corners for image views on tvOS (Swift 4)
// A Swift 4 version of https://gist.github.com/petergp/815ba3bf6b7280c2c01f
private class ImageView : UIImageView {
private class Layer: CALayer {
override func addSublayer(_ layer: CALayer) {
defer { super.addSublayer(layer) }
let cornerRadiusKey = "_cornerRadius"
guard let configuration = layer.value(forKey: "_configuration") as? NSObject,
configuration.responds(to: NSSelectorFromString(cornerRadiusKey)) else {
return
@frankrausch
frankrausch / String+Hyphenation.swift
Last active June 15, 2023 16:45
Returns a String with soft hyphens (U+00AD)
import Foundation
extension String {
func hyphenated(languageCode: String) -> String {
let locale = Locale(identifier: languageCode)
return self.hyphenated(locale: locale)
}
func hyphenated(locale: Locale) -> String {
@dneprDroid
dneprDroid / VideoPreviewView.swift
Last active July 13, 2023 14:43
VideoPreviewView - video capture and preview (swift 3)
// swift 3
import UIKit
import AVFoundation
class VideoPreviewView: UIView {
private var videoOutput: AVCaptureMovieFileOutput?
private var captureSession: AVCaptureSession?
private var previewLayer: AVCaptureVideoPreviewLayer?

Direct copy of pre-encoded file:

$ ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8

@TomCan
TomCan / restart-samba.sh
Created July 23, 2015 14:53
Restart Mac OS X smb service from terminal/cli
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.smbd.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.smbd.plist
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist EnabledServices -array disk
import UIKit
import AVFoundation
public extension AVCaptureVideoOrientation {
public init(interfaceOrientation: UIInterfaceOrientation) {
switch interfaceOrientation {
case .Unknown:
self = .LandscapeLeft
case .Portrait:
@soutar
soutar / proxy.js
Last active November 14, 2022 20:14
Redirect HTTP traffic on Internet Sharing to a local Charles proxy
#!/usr/bin/env node
var options = require('minimist')(process.argv.slice(2), { default: {
cport: 8888
}});
var disable = options.disable || options.d;
var enable = options.enable || options.e;
var status = options.s || options.status;
var child = require('child_process');