Skip to content

Instantly share code, notes, and snippets.

View bigsan's full-sized avatar

San Chen bigsan

  • LearningTech
  • Taiwan
View GitHub Profile
@bigsan
bigsan / UIImageExtension.swift
Created April 2, 2019 15:44
UIImage extension that creates a UIImage from a UIView
extension UIImage {
// UIImage extension that creates a UIImage from a UIView
convenience init (view:UIView) {
UIGraphicsBeginImageContext(view.frame.size)
view.layer.render(in: UIGraphicsGetCurrentContext()!)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
self.init(cgImage: image!.cgImage!)
}
@bigsan
bigsan / String+Extensions.swift
Last active March 26, 2019 06:45
[String Extensions] #string #subscript #encoding
import Foundation
extension CFStringEncodings {
var encoding: String.Encoding {
return String.Encoding(rawValue: CFStringConvertEncodingToNSStringEncoding(CFStringEncoding(self.rawValue)))
}
}
public extension String.Encoding {
public static let big5 = CFStringEncodings.big5.encoding
@bigsan
bigsan / CoreLocation+Extensions.swift
Last active March 18, 2019 15:17
[CoreLocation enum description] #corelocation #enum
import Foundation
import CoreLocation
extension CLRegionState : CustomStringConvertible {
public var description: String {
switch self {
case .unknown:
return "unknown"
case .inside:
return "inside"
@bigsan
bigsan / cleanup.sh
Created December 5, 2018 01:25 — forked from superseb/cleanup.sh
Cleanup host added as custom to Rancher 2.0
#!/bin/sh
docker rm -f $(docker ps -qa)
docker volume rm $(docker volume ls -q)
cleanupdirs="/var/lib/etcd /etc/kubernetes /etc/cni /opt/cni /var/lib/cni /var/run/calico /opt/rke"
for dir in $cleanupdirs; do
echo "Removing $dir"
rm -rf $dir
done
@bigsan
bigsan / tmux.md
Created July 9, 2018 01:18 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@bigsan
bigsan / video_preview.html
Last active May 15, 2018 07:20 — forked from martinsik/video_preview.html
[Movie Preview with ffmpeg] Source code for Binpress tutorial: http://www.binpress.com/tutorial/generating-nice-movie-previews-with-ffmpeg/138 #ffmpeg
<!--
Tutorial code for: http://www.binpress.com/tutorial/generating-nice-movie-previews-with-ffmpeg/138
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
</head>
<body>
<a href="https://www.youtube.com/watch?v=v1uyQZNg2vE" target="_blank" class="video-preview" data-frames="100" data-source="http://i.imgur.com/BX0pV4J.jpg"></a>
@bigsan
bigsan / launch.json
Created August 27, 2017 15:15 — forked from comfortablejohn/launch.json
Debug config for VSCode Chrome Debugger
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3000",
"sourceMaps": true,
"webRoot": "${workspaceRoot}/dist",
@bigsan
bigsan / fibonacci.js
Last active February 13, 2017 02:11
fibonacci using es6 generator
const fibonacci = {
[Symbol.iterator]: function* () {
yield 0;
yield 1;
let [pre, cur] = [0, 1];
while (true) {
[pre, cur] = [cur, pre + cur]
yield cur;
}
}

Comparison of ASP.NET and Node.js for Backend Programming

We will compare ASP.NET and Node.js for backend programming.
Source codes from examples.

Updates

This document was published on 21.09.2015 for a freelance employer. Some changes since then (14.02.2016):

  1. Koa.js no longer uses co-routines, it has switched to Babel's async/await. yield and await are used almost in the same way, so I see no point to rewrite the examples.
@bigsan
bigsan / gist:d7eaf948bf3c8f0fc5c8248bccf69740
Created August 7, 2016 11:38 — forked from acj/TrimVideo.swift
Trim video using AVFoundation in Swift
//
// TrimVideo.swift
// VideoLab
//
// Created by Adam Jensen on 3/28/15.
// Copyright (c) 2015 Adam Jensen. All rights reserved.
//
import AVFoundation
import Foundation