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
@brandonvanha
brandonvanha / index.html
Created November 7, 2017 18:14 — forked from miguelmota/index.html
MailChimp sign up popup on click + clear expire cookie
<button id="open-popup">Sign Up</button>
<script type="text/javascript" src="//s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script>
<script>
function showMailingPopUp() {
var config={"baseUrl":"mc.us5.list-manage.com","uuid":"0b1e10820775a3f...","lid":"738208..."}
require(["mojo/signup-forms/Loader"], function(L) {
L.start(config)
@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
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
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.

// 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, result.recordset.map( function ( o ) { return o.calendar_date; } ) );
var maxNum = Math.max.apply( Math, result.recordset.map( function ( o ) { return o.calendar_date; } ) );
// Return entire JSON Object.
@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
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
class MyClass
{
private static _instance: MyClass;
private constructor()
{
//...
}
public static get Instance()
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 / 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