Skip to content

Instantly share code, notes, and snippets.

🇲🇿
Peace for Mozambique!

Helder Oliveira heldrida

🇲🇿
Peace for Mozambique!
View GitHub Profile
View optimizelyExperiment
import React, { PropTypes } from 'react'
export const insertScriptHelper = (projectId) => {
const el = document.querySelector('[data-optimizely-snippet]')
if (!isReadyHelper() && !el) {
const protocol = `${document.location.protocol}//`
const scriptTag = document.createElement('script')
scriptTag.type = 'text/javascript'
scriptTag.async = true
scriptTag.src = `${protocol}cdn.optimizely.com/js/${projectId}.js`
@heldrida
heldrida / timed-recursive-calls-with-timer.babel.js
Last active Feb 28, 2017
A helper function that make's timed recursive calls, if a given condition does not pass, after a given amount of time in milliseconds. When the condition test pass, a callback function is called. For each recursive step call, there is a stepCallback if required.
View timed-recursive-calls-with-timer.babel.js
let global = {
stop: false
}
const timedCaller = (params) => {
params.debug && console.log('[DEBUG ' + params.name + '] fn call')
// Test condition, if true run the callback
if (params.condition.test()) {
params.debug && console.log('[DEBUG ' + params.name + '] condition test passed!')
if (typeof params.condition.callback === 'function') {
params.debug && console.log('[DEBUG ' + params.name + '] callback is fn, should call!')
@heldrida
heldrida / famousjs-lesson101(starterKit-picasa-album)
Created Sep 16, 2014
Famo.us lesson 101 (Starter kit), picasa album link is invalid! Here's a solution
View famousjs-lesson101(starterKit-picasa-album)
define(function(require, exports, module) {
var SlideData = {
picasaUrl: 'https://picasaweb.google.com/data/feed/api/all',
queryParams: '?kind=photo&q=puppy&max-results=5&imgmax=720&alt=json',
defaultImage: 'https://lh4.googleusercontent.com/-HbYp2q1BZfQ/U3LXxmWoy7I/AAAAAAAAAJk/VqI5bGooDaA/s1178-no/1.jpg'
};
SlideData.getUrl = function() {
return SlideData.picasaUrl + SlideData.queryParams;
};
@heldrida
heldrida / Gruntfile.js
Created Aug 21, 2014
Gruntfile.js: Basic watch configuration, observing html, sass and javascript files
View Gruntfile.js
/*globals module, grunt*/
'use strict';
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
@heldrida
heldrida / javascript
Last active Jan 29, 2020
Facebook Javascript SDK: Basic Login and Logout example
View javascript
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: 'xxxxxxxxxxxxx',
status: true,
cookie: true,
xfbml: true
});
@heldrida
heldrida / gist:6232505
Created Aug 14, 2013
Facebook: Post on behalf
View gist:6232505
<?php
$facebook = new Facebook(array(
'appId' => 'xxxxx',
'secret' => 'xxxxx'
)
);
$facebook->setExtendedAccessToken();
$access_token = $facebook->getAccessToken();
@heldrida
heldrida / gist:5188729
Created Mar 18, 2013
videojs, with fallback firefox safari
View gist:5188729
var link = document.createElement('link'),
script = document.createElement('script');
link.href = 'http://vjs.zencdn.net/c/video-js.css';
link.rel = 'stylesheet';
document.body.appendChild(link);
script.src = 'http://vjs.zencdn.net/c/video.js';
script.onload = function() {
var video = document.createElement('video');
@heldrida
heldrida / jquery.ba-tinypubsub.js
Created Mar 21, 2012 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
View jquery.ba-tinypubsub.js
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
You can’t perform that action at this time.