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
// 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 / 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.

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 / 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
@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 / Install Composer using MAMP's PHP.md
Created October 23, 2017 06:12 — forked from irazasyed/Install Composer using MAMP's PHP.md
Instructions on how to change preinstalled Mac OS X PHP to MAMP's PHP Installation and then install Composer Package Management

Change default Mac OS X PHP to MAMP's PHP Installation and Install Composer Package Management


Instructions to Change PHP Installation


First, Lets find out what version of PHP we're running (To find out if it's the default version).

To do that, Within the terminal, Fire this command:

which php

@brandonvanha
brandonvanha / .eslintrc
Created March 24, 2017 18:02 — forked from cletusw/.eslintrc
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@brandonvanha
brandonvanha / Refreshing.swift
Created April 5, 2015 20:39
Pull to refresh
class UserTableViewController: UITableViewController {
var refresher: UIRefreshControl!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
refresher = UIRefreshControl()
@brandonvanha
brandonvanha / Dragging.swift
Last active August 29, 2015 14:18
Dragging controls
import UIKit
class ViewController: UIViewController {
var xFromCenter: CGFloat = 0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
@brandonvanha
brandonvanha / sharedArrays.js
Created October 23, 2014 22:25
Be aware of sharing clearing arrays
Clearing shared arrays
You need to be aware of the fact that setting an array’s length to zero affects everybody
who shares the array:
> var a1 = [1, 2, 3];
> var a2 = a1;
> a1.length = 0;
> a1
[]
> a2