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")
@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
@brandonvanha
brandonvanha / mailchimp-popup-for-wordpress.md
Created December 12, 2017 06:10 — forked from nickcernis/mailchimp-popup-for-wordpress.md
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.

@brandonvanha
brandonvanha / cssversioner.php
Created November 7, 2017 21:42 — forked from vidluther/cssversioner.php
Add a query string to the end of the theme's style.css when WordPress is loaded.
<?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