Skip to content

Instantly share code, notes, and snippets.

View manfromanotherland's full-sized avatar
🤏

Edmundo Santos manfromanotherland

🤏
View GitHub Profile
@rothschild86
rothschild86 / cf-hubspot.php
Created May 12, 2016 01:46
Caldera Forms to HubSpot CRM integration
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//required plugins: code snippets, caldera forms, caldera forms run action
add_action('consult_req_submitted', 'consult_req_submitted_sync_hubspot');
function consult_req_submitted_sync_hubspot( $data ){
$hubspot_api_key = 'ffffffff-27a0-4591-9b68-27d4bb31ed76';
$hubspot_list_id = '1'; //optional
@umayr
umayr / recover-deleted-branch.sh
Created April 1, 2016 11:41
How to recover a deleted branch
## Pre-requisite: You have to know your last commit message from your deleted branch.
git reflog
# Search for message in the list
# a901eda HEAD@{18}: commit: <last commit message>
# Now you have two options, either checkout revision or HEAD
git checkout a901eda
# Or
git checkout HEAD@{18}
@electerious
electerious / debounce.js
Last active December 12, 2018 08:18 — forked from jasonwyatt/debouncer.js
How to **correctly** debounce an event that will be triggered many times with identical arguments.
const debounce = function(fn, duration) {
let timeout = null
return (...args) => {
clearTimeout(timeout)
timeout = setTimeout(() => fn(...args), duration)
@electerious
electerious / select.js
Last active January 24, 2017 09:04
Select multiple elements and receive an array
const select = (query, elem = null) => {
elem = (elem==null ? document : elem)
let elems = elem.querySelectorAll(query)
if (elems==null) return []
else return Array.prototype.slice.call(elems, 0)
}
@electerious
electerious / toggler.js
Last active January 24, 2017 09:04
Toggle between true and false
const toggler = (initState) => {
initState = initState!==false
let state = initState
return {
get : () => state,
reset : () => state = initState,
toggle : () => state = !state,
@electerious
electerious / counter.js
Last active January 24, 2017 09:04
Count up and down between two numbers
const counter = (min, max, initial) => {
let index = initial - min
let length = max - min + 1
return (modifier = 0) => {
index = (index + modifier) % length
if (index>=0) index = 0 + index
@electerious
electerious / limit.js
Created November 13, 2015 10:45
Limit a number between a min and max value
const limit = (min, max, num) => Math.min(Math.max(num, min), max)
@MarioAraque
MarioAraque / index.js
Last active April 18, 2017 09:51
Detect when hubspot form is submitted successfully
hbspt.forms.create({
portalId: '', //Your portal ID
formId: '', // Your form ID
css: '',
onFormReady: function(form, ctx) {
form.parents('.hbspt-form:first').on('DOMSubtreeModified', function() {
var hsForm = $(this);
if(hsForm.find('.submitted-message').length) {
//Your code.
}
@electerious
electerious / stopEvent.js
Last active January 24, 2017 09:04
Stop event propagation and prevent the default
const stopEvent = (e = {}) => {
if (typeof e.stopPropagation==='function') e.stopPropagation()
if (typeof e.preventDefault==='function') e.preventDefault()
}