Skip to content

Instantly share code, notes, and snippets.

Working from home

Brandon Ha brandonvanha

Working from home
  • Toronto, Canada
Block or report user

Report or block brandonvanha

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
brandonvanha / FTPUpload.swift
Created Jul 24, 2018 — forked from Nirma/FTPUpload.swift
Upload a file via FTP on iOS or macOS
View FTPUpload.swift
import Foundation
import CFNetwork
public class FTPUpload {
fileprivate let ftpBaseUrl: String
fileprivate let directoryPath: String
fileprivate let username: String
fileprivate let password: String
brandonvanha /
Created Jul 14, 2018 — forked from mdang/
Ruby on Rails Cheatsheet

Ruby on Rails Cheatsheet


Create a new application

Install the Rails gem if you haven't done so before

View Simple Alamofire Calls in Swift 4
import Alamofire
func makeGetCallWithAlamofire() {
let todoEndpoint: String = ""
.responseJSON { response in
// check for errors
guard response.result.error == nil else {
// got an error in getting the data, need to handle it
print("error calling GET on /todos/1")
View typescript_singleton.ts
class MyClass
private static _instance: MyClass;
private constructor()
public static get Instance()
View generics_and_protocols.swift
protocol Numeric {
func *(lhs: Self, rhs: Self) -> Self
extension Double: Numeric {}
extension Float: Numeric {}
extension Int: Numeric {}
func genericMultiplier<T: Numeric>(lhs: T, rhs: T) -> T {
return lhs * rhs
brandonvanha / .swiftlint.yml
Created Jan 17, 2018 — forked from milanpanchal/.swiftlint.yml
SwiftLint's configuration rules example
View .swiftlint.yml
# Find all the available rules by running:
# swiftlint rules
disabled_rules: # rule identifiers to exclude from running
# - colon
# - comma
- control_statement
# - trailing_whitespace
opt_in_rules: # some rules are only opt-in
- empty_count
View getMinOrMaxFromJson.js
// Return min or max key's value
// calendar_date is just an example placeholder.
// result.recordet is array of JSON Object.
var minNum = Math.min.apply( Math, function ( o ) { return o.calendar_date; } ) );
var maxNum = Math.max.apply( Math, function ( o ) { return o.calendar_date; } ) );
// Return entire JSON Object.
brandonvanha /
Created Dec 12, 2017 — forked from nickcernis/
MailChimp Popup Script that works with WordPress sites

MailChimp's default popup scripts can break on WordPress sites that use jQuery/jQuery UI unless you include their embed code as the final elements before the closing body tag.

Including them in this way isn't always possible or easy with WordPress.

The code below is an alternative implementation of the loader that forces MailChimp's popup scripts to appear below all other scripts upon page load.

To use it, modify the baseUrl, uuid, and lid attributes with the ones from the original popup script that MailChimp supplies.

View ConvertSecondsToHHMMss.sql
DECLARE @SecondsToConvert int
SET @SecondsToConvert = 23651
-- Declare variables
DECLARE @Hours int
DECLARE @Minutes int
DECLARE @Seconds int
DECLARE @Time datetime
-- Set the calculations for hour, minute and second
brandonvanha / cssversioner.php
Created Nov 7, 2017 — forked from vidluther/cssversioner.php
Add a query string to the end of the theme's style.css when WordPress is loaded.
View cssversioner.php
* Add a filter to stylesheet_uri, which appends a query string to it automagically.
add_filter('stylesheet_uri', 'zk_css_versioner');
* the goal of this method is to append a query string to the css url for the site.
* the query string currently is determined by the last time the css file was modified
You can’t perform that action at this time.