Skip to content

Instantly share code, notes, and snippets.

View VinnyFonseca's full-sized avatar
🏠
Working from home

Vinny Fonseca VinnyFonseca

🏠
Working from home
View GitHub Profile
@VinnyFonseca
VinnyFonseca / Facebook Implementation
Created June 10, 2013 13:06
Facebook Implementation
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : "XXXXXXXXX",
status : false,
cookie : true,
xfbml : true
});
@VinnyFonseca
VinnyFonseca / Twitter Implementation
Created June 10, 2013 13:06
Twitter Implementation Web Intents
<script type="text/javascript">
window.twttr = (function (d, s, id) {
var t, js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
return window.twttr || (t = {
_e: [],
@VinnyFonseca
VinnyFonseca / closest-element-behaviour.js
Last active March 15, 2018 13:54
Closest Element Behaviour
document.body.addEventListener('click', function(event) {
if ( !event.target.closest("SELECTOR").length && document.querySelector("SELECTOR").hasClass("active") ) {
// Your function here
};
});
@VinnyFonseca
VinnyFonseca / empty-object-check.js
Last active September 28, 2021 21:50
Empty Object Check
function isEmpty(obj) {
return (
(typeof obj == 'undefined' || obj === null || obj === '')
|| (typeof obj == 'number' && isNaN(obj))
|| (obj instanceof Date && isNaN(Number(obj)))
);
};
@VinnyFonseca
VinnyFonseca / ga.js
Last active December 7, 2017 12:40
Google Analytics Implementation
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
@VinnyFonseca
VinnyFonseca / Facebook Canvas Auto Height
Created June 18, 2013 14:34
Facebook Canvas Auto Height
<div id="fb-root"></div>
<script src="https://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
var appId = 'XXXXXXXXXXXXX';
window.fbAsyncInit = function() {
FB.init({
appId: appId,
status: true,
cookie: true,
@VinnyFonseca
VinnyFonseca / Facebook Create Page Tab URL
Created June 19, 2013 16:25
Facebook Create Page Tab URL
https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&next=YOUR_URL
@VinnyFonseca
VinnyFonseca / Standalone Cookie Implementation
Created June 27, 2013 14:17
Standalone Cookie Implementation Insert into Body, not Head
@VinnyFonseca
VinnyFonseca / fb-page-tab-like-gate.js
Last active December 7, 2017 12:38
Facebook Page Tab Like Gate
var appId = 'XXXXXXXXXXXXXXX';
// Taken from the App's configuration page
window.fbAsyncInit = function() {
FB.init({
appId: appId,
status: true,
cookie: true,
xfbml: true
});
@VinnyFonseca
VinnyFonseca / randomize.js
Last active December 7, 2017 12:35
Randomize
const rand = (min, max) => Math.floor(Math.random() * (max - min)) + min;