Skip to content

Instantly share code, notes, and snippets.

View rcholic's full-sized avatar

Tony Wang rcholic

View GitHub Profile
@rcholic
rcholic / gist:c81d0cc8bc521898aa477161a84f9cc1
Created September 24, 2022 21:41 — forked from jonswaff/gist:8582072
Modal dialog for iOS.
- (void)presentModalView
{
CGFloat bounceDistance = 10.0;
CGFloat modalWidthPercentage = 0.9;
CGFloat modalHeightPercentage = 0.8;
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
CGRect frame = keyWindow.bounds;
// The screenView is a plain black view with opacity
@rcholic
rcholic / UIView+Intersection.swift
Created September 8, 2022 22:59 — forked from calosth/UIView+Intersection.swift
Extension of UIView to detect collisions between them, including rotated(transformed) views.
import UIKit
// Conform the `Polygon` protocol to specify the vertices of the polygon.
protocol Polygon {
var vertices: [CGPoint] { get }
}
// UIView conforms the protocol `Polygon` to specified the vertices of the rectangle.
extension UIView: Polygon {
@rcholic
rcholic / gist:8aafaa9af7d8dfc28ef76bcc8ce9d43b
Created July 24, 2022 06:27 — forked from snikch/gist:3661188
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
@rcholic
rcholic / simulate_options_ic_trading.py
Last active June 21, 2022 01:35
simulation of options trading with Iron Condor strategy
from typing import List
import numpy as np
import random
import math
def perform_iron_condor(
trade_days: int,
initial_capital: float,
spread: float = 50.0,
profit_rate_daily: float = 0.02,
@rcholic
rcholic / aws.py
Created June 20, 2022 01:27 — forked from rizerzero/aws.py
check S3 bucket exists with python
from aws import bucket_exists, upload_path
bucket_name = 'cnns-music-vids'
directory_to_upload = 'data/'
output_s3_directory = 'data/'
if bucket_exists(bucket_name):
print('the bucket exists!')
else:
raise ValueError('nah the bucket does not exist')
@rcholic
rcholic / kubeadm.md
Created August 22, 2018 22:15 — forked from jamesbuckett/kubeadm.md
kubeadm

Deploy a Kubernetes cluster and Microservices Application

image

What Problem are we solving

What is Kubernetes?

Agenda

  • Deploy a Kubernetes cluster on Digital Ocean using kubeadm
@rcholic
rcholic / git-bc.cmd
Created June 6, 2018 23:25 — forked from aaronhoffman/git-bc.cmd
Configure Beyond Compare 4 as git diff tool on windows 10
git config --global diff.tool bc
git config --global difftool.bc.path "C:\Program Files\Beyond Compare 4\BComp.exe"
git config --global merge.tool bc
git config --global mergetool.bc.path "C:\Program Files\Beyond Compare 4\BComp.exe"
git config --global alias.mydiff "difftool --dir-diff --tool=bc --no-prompt"
@rcholic
rcholic / basket.ts
Created April 16, 2018 21:21 — forked from mrcrowl/basket.ts
Example of using vuex-type to create strongly-typed vuex store access
// path: store/basket/basket.ts (module)
import { RootState } from "../../store"
import inventory, { Product } from "../inventory/inventory"
export interface Item { productId: string, quantity: number }
export interface DisplayItem { product: Product, quantity: number }
export interface BasketState { items: Item[], isLoading: boolean }
const initialBasketState: BasketState = { items: [], isLoading: false }
package main
import (
"fmt"
"io"
"os"
)
var path = "/Users/novalagung/Documents/temp/test.txt"
package main
import (
"fmt"
"io"
"os"
)
var path = "/Users/novalagung/Documents/temp/test.txt"