Skip to content

Instantly share code, notes, and snippets.

View ricardodantas's full-sized avatar

Ricardo Dantas ricardodantas

View GitHub Profile
@ricardodantas
ricardodantas / requirejs-define-scaffold.js
Last active August 29, 2015 14:09
A RequireJS define scaffold.
define(
'MODULE_NAME',
[
'jquery',
'backbone'
],
function ($, Backbone) {
define(
'Footer', [
'jquery',
'backbone'
],
function($, Backbone) {
'use strict';
var FooterView = Backbone.View.extend({
define(
// Load any libraries or plugins you'd like to
// use on the page by adding them to the array.
// Reference: http://requirejs.org/docs/start.html
[
'$',
'devicejs',
'prefetcher',
'General/view'
],
// Please see https://cloud.mobify.com/docs/adaptivejs/ui-scripts/ for more information.
define([
// Modules marked with `external!` have already been built into the
// adaptation, and won't be built into the UI script.
'$',
'Home/view'
],
function($, HomeView) {
var homeUI = function() {
new HomeView();
@ricardodantas
ricardodantas / mobify-merged-tag.html
Created November 17, 2014 22:45
Mobify merge tag for mobile and tablet projects.
<!-- MOBIFY - DO NOT ALTER - PASTE IMMEDIATELY AFTER OPENING HEAD TAG -->
<script type="text/javascript">
/*<![CDATA[*/(function(c,f){function h(a){if(a.mode){var b=g("mobify-mode");b&&a[b]||(b=a.mode(d.ua));return a[b]}return a}function m(){function a(a){c.addEventListener(a,function(){d[a]=+new Date},!1)}c.addEventListener&&(a("DOMContentLoaded"),a("load"))}function n(){var a=new Date;a.setTime(a.getTime()+3E5);f.cookie="mobify-path=; expires="+a.toGMTString()+"; path=/";c.location.reload()}function p(){k({src:"https://preview.mobify.com/v7/"})}function g(a){if(a=f.cookie.match(RegExp("(^|; )"+a+"((=([^;]*))|(; |$))")))return a[4]||""}function l(a){f.write('<plaintext style="display:none">');setTimeout(function(){e.capturing=!0;a()},0)}function k(a,b){var c=f.getElementsByTagName("script")[0],d=f.createElement("script"),e;for(e in a)d[e]=a[e];b&&d.setAttribute("class",b);c.parentNode.insertBefore(d,c)}var e=c.Mobify={},d=e.Tag={};e.points=[+new Date];e.tagVersion=[7,0];d.ua=c.navigator.userAgent;d.getOption
@ricardodantas
ricardodantas / table-zebra.css
Created December 3, 2014 00:33
CSS3 Zebra Striping a Table
tbody tr:nth-child(odd) {
background-color: #ccc;
}
@ricardodantas
ricardodantas / scroll.css
Created December 4, 2014 12:25
Style scroll webkit
::-webkit-scrollbar {
width: 2px;
}
/* Track */
::-webkit-scrollbar-track {
-webkit-box-shadow: none;
-webkit-border-radius: 0px;
border-radius: 0px;
}
@ricardodantas
ricardodantas / paymo.js
Last active August 29, 2015 14:20 — forked from yisraeldov/paymo.js
//Paymo API
/**
* This is a quick wrapper for the Paymo 3.0 API
* Requires (jquery.rest)[https://github.com/jpillora/jquery.rest]
*
* Copyright (c) 2014 Yisrael Dov Lebow <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
@ricardodantas
ricardodantas / retry.trait.php
Last active August 4, 2017 19:59
Ruby retry alternative for PHP
<?php
namespace App\Traits\General;
trait Github {
function retry($f, $delay = 2, $retries = 10){
try {
return $f();
} catch (Exception $e) {
if ($retries > 0) {
sleep($delay);
@ricardodantas
ricardodantas / update-n-backup.sh
Created October 2, 2017 16:36
Update all folders which are a valid git repository and create a tar ball (package.tar)
#!/bin/bash
BACKUP_FOLDER=tmp-bkp
echo "=> Creating temp backup folder..."
mkdir -p $BACKUP_FOLDER
for f in *; do
if [[ -d $f ]]; then
echo "=> Updating $f..."
cd $f
if [ -d .git ]; then