Skip to content

Instantly share code, notes, and snippets.

@hyuni
hyuni / .zshrc
Created August 5, 2018 01:16 — forked from kidager/.zshrc
ZSH Powerline installation
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="agnoster"
# Uncomment the following line to use case-sensitive completion.
@hyuni
hyuni / UIView+RoundedCorners.h
Created July 30, 2018 05:35 — forked from bobmoff/UIView+RoundedCorners.h
Add rounded corners to any view using layer mask.
#import <UIKit/UIKit.h>
@interface UIView (RoundedCorners)
- (void)setRoundedCorners:(UIRectCorner)corners radius:(CGSize)size;
@end
func switchRootViewController(rootViewController: UIViewController, animated: Bool, completion: (() -> Void)?) {
if animated {
UIView.transitionWithView(window, duration: 0.5, options: .TransitionCrossDissolve, animations: {
let oldState: Bool = UIView.areAnimationsEnabled()
UIView.setAnimationsEnabled(false)
self.window!.rootViewController = rootViewController
UIView.setAnimationsEnabled(oldState)
}, completion: { (finished: Bool) -> () in
if completion {
completion!()
@hyuni
hyuni / wwdc.sh
Created July 18, 2018 13:31 — forked from idiomatic/wwdc.sh
Fetch WWDC videos, slides, and sample code.
#!/bin/bash
# usage: get [ RESOLUTION [ YEAR [ IDS... ] ] ]
resolution=${1:-SD}
year=${2:-2015}
shift
shift
ids=$*
RESOLUTION=$(echo $resolution | tr '[:lower:]' '[:upper:]')
@hyuni
hyuni / scrollView
Created July 18, 2018 13:31 — forked from chrisswong/scrollView
WWDC scrollView sessions
2009 - Mastering iPhone Scroll Views
UIScrollView Basics
2010 - Designing Apps with Scroll Views
Photo browsing
Tiling
2011 - Advanced Scroll View Techniques
Infinite scrolling
Stationary header views
@hyuni
hyuni / detect-string-language.swift
Created July 13, 2018 14:46 — forked from ethanhuang13/detect-string-language.swift
Detect string language with Swift
//: Playground - noun: a place where people can play
//
// The result is not guaranteed to be accurate. Typically, the function requires 200-400 characters to reliably guess the language of a string.
// Reference: [CFStringTokenizerCopyBestStringLanguage(_:_:)](https://developer.apple.com/reference/corefoundation/1542136-cfstringtokenizercopybeststringl)
//
import Foundation
extension String {
func guessLanguage() -> String {
@hyuni
hyuni / Extensions.swift
Last active July 3, 2018 05:38 — forked from brocoo/Extensions.swift
Swift UIImage extension for base64 conversion
public enum ImageFormat {
case png
case jpeg(CGFloat)
}
extension UIImage {
public func base64(format: ImageFormat) -> String? {
var imageData: Data?
import UIKit
public struct TextStyle {
let font: UIFont
let color: UIColor
let kerning: CGFloat?
let lineHeight: CGFloat?
}
import UIKit
public struct TextStyle {
let font: UIFont
let color: UIColor
let kerning: CGFloat?
let lineHeight: CGFloat?
}

These are notes while researching a way to convert a browser/website to a stream. This could be used for Facebook Live or for webrecording. TL'DR:

  • I started with Phantomjs - but that didn't support the html5 video tag
  • SlimerJS supports it, but there is no way to record audio directly (though this might come from desktop audio)
  • So I moved to research ffmpeg/X11/XVFB to record it with linux which works
  • But ffmpeg has no easy way to mix streams/overlays to I moved on to OBS with overlay browser support
  • I started researching options OBS in docker and it needed best a GPU , so I move to nvidia-docker
  • And so came across building game servers on EC2/AWS using GPUs and managed to run OBS inside of GPU g2x.large machine
  • I tried streaming to twich , which works great and managed to restream 4K 60FPS youtube on an AWS instance
  • Remote control works through OBS-Remote but OBS has kinda limit in types of features