Skip to content

Instantly share code, notes, and snippets.

View brandonvanha's full-sized avatar
🏠
Hello

Brandon Ha brandonvanha

🏠
Hello
  • Toronto, Canada
View GitHub Profile
chrome.tabs.query(
{ active: true, windowId: chrome.windows.WINDOW_ID_CURRENT },
function(tabs) {
const { id: tabId } = tabs[0].url;
let code = `document.querySelector('h1')`;
// http://infoheap.com/chrome-extension-tutorial-access-dom/
chrome.tabs.executeScript(tabId, { code }, function (result) {
// result has the return value from `code`
@brandonvanha
brandonvanha / date_time_formats.rb
Created August 20, 2021 00:57 — forked from eliotsykes/date_time_formats.rb
Real World Rails DATE_FORMAT samples
~/dev/real-world-rails (master)
$ ag -G 'config/initializers/' ::DATE_FORMATS
apps/accelerated_claims/config/initializers/date_formats.rb
1:Date::DATE_FORMATS[:printed] = '%d %B %Y'
apps/advocate-defence-payments/config/initializers/date_time.rb
2:Date::DATE_FORMATS[:default] = Settings.date_format
5:DateTime::DATE_FORMATS[:default] = Settings.date_time_format
8:Time::DATE_FORMATS[:default] = Settings.date_time_format
@brandonvanha
brandonvanha / jq_vs_js.md
Created February 15, 2021 21:30 — forked from joyrexus/jq_vs_js.md
Comparison of jQuery and vanilla JS for basic DOM manipulation.

jQuery vs native JS

Selecting Elements

var divs = $("div");

var divs = document.querySelectorAll("div");
@brandonvanha
brandonvanha / Gemfile
Created June 25, 2020 05:40 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@brandonvanha
brandonvanha / FTPUpload.swift
Created July 24, 2018 04:19 — forked from Nirma/FTPUpload.swift
Upload a file via FTP on iOS or macOS
import Foundation
import CFNetwork
public class FTPUpload {
fileprivate let ftpBaseUrl: String
fileprivate let directoryPath: String
fileprivate let username: String
fileprivate let password: String
@brandonvanha
brandonvanha / RAILS_CHEATSHEET.md
Created July 14, 2018 22:18 — forked from mdang/RAILS_CHEATSHEET.md
Ruby on Rails Cheatsheet

Ruby on Rails Cheatsheet

Architecture

Create a new application

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

import Alamofire
func makeGetCallWithAlamofire() {
let todoEndpoint: String = "https://jsonplaceholder.typicode.com/todos/1"
Alamofire.request(todoEndpoint)
.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")
class MyClass
{
private static _instance: MyClass;
private constructor()
{
//...
}
public static get Instance()
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
brandonvanha / .swiftlint.yml
Created January 17, 2018 05:50 — forked from milanpanchal/.swiftlint.yml
SwiftLint's configuration rules example
# 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