Skip to content

Instantly share code, notes, and snippets.

View Jaballadares's full-sized avatar

John Balladares Jaballadares

View GitHub Profile
@Jaballadares
Jaballadares / SCSScenterHack.markdown
Last active August 29, 2015 14:15
SCSS Center Hack from Codepen
@Jaballadares
Jaballadares / Ajax Template
Last active August 29, 2015 14:16
JQuery Snippets
$.ajax({
type: 'POST',
url: 'backend.php',
data: "q="+myform.serialize(),
success: function(data){
// on success use return data here
},
error: function(xhr, type, exception) {
// if ajax fails display error alert
alert("ajax error response type "+type);
@Jaballadares
Jaballadares / Array Concat (students example)
Created May 14, 2015 06:43
Joining Arrays - Teamtreehouse Javascript
var currentStudents = ['Joan', 'John', 'Joaquin'];
var newStudents = ['Samantha', 'Traci', 'Tiago'];
var allStudents = currentStudents.concat( newStudents );
console.log(allStudents);
@Jaballadares
Jaballadares / utm-tracking.js
Created August 12, 2016 01:46
Tracking Salesforce UTM Paramaters across pages
(function () {
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
@Jaballadares
Jaballadares / listing-results-snippet.php
Created June 12, 2017 22:28
Home Junction Listing Results Snippet
<?php
use \hji\ResponsiveIDX\ResponsiveIDX;
/**
* Begin template logic
*
* All $listing properties can be accessed directly as
* $listing->propertyName
* To view All Available Properties of the $listing object
* do: var_dump($listing->data);
@Jaballadares
Jaballadares / phoneNumberFinderRegex.txt
Last active February 14, 2018 23:12
Javascript Regex to Find Different Formats of Phone Numbers in String of Text
Option 1: (?=.*?\d{3}( |-|.)?\d{4})((?:\+?(?:1)(?:\1|\s*?))?(?:(?:\d{3}\s*?)|(?:\((?:\d{3})\)\s*?))\1?(?:\d{3})\1?(?:\d{4})(?:\s*?(?:#|(?:ext\.?))(?:\d{1,5}))?)\b
Option 2 (maybe better): \+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}
Option 3: (?:\+?(?<COUNTRY_CODE>\d{1})?-?\(?(?<AREA_CODE>\d{3})\)?[\s-\.]?)?(?<PART1>\d{3})[\s-\.]?(?<PART2>\d{4})[\s-\.]?
@Jaballadares
Jaballadares / exportAllAsanaTasksinProject.py
Created January 17, 2018 08:31
Blockspring - Export All Tasks for Particular Project
import google_sheets_app
import asana_app
def export():
sheets = google_sheets_app.get_spreadsheet_by_id(
"your_googlesheet_id_here"
).get_sheets()[0]
julian = asana_app.get_project_by_id("your_asana_project_id_here")
# ws = asana_app.get_current_workspace()
# projects = ws.get_projects()
@Jaballadares
Jaballadares / typekit-loading-animation.css
Created January 26, 2018 06:43
Avoid FOUT with Typekit and give this class text above the fold using typekit font
.article {
opacity: 1;
transition: transform .4s ease-in-out, opacity .4s ease-in-out;
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0);
}
.wf-loading .article {
opacity: 0;
@Jaballadares
Jaballadares / findObjectByStringinArray.js
Created January 9, 2019 22:31
Find an Object in Array by String in One of its Properties
const produce = [
{ name: 'apples', quantity: 2 },
{ name: 'bananas', quantity: 0 },
{ name: 'cherries', quantity: 5 }
];
function isCherries(fruit) {
return fruit.name === 'cherries';
}