Skip to content

Instantly share code, notes, and snippets.

View diogomoretti's full-sized avatar
🌎

Diogo Moretti diogomoretti

🌎
View GitHub Profile
@koraktor
koraktor / git-create-empty-branch.sh
Created March 26, 2009 08:04
Git: Creating an empty branch
git stash # Stash changes if any
git symbolic-ref HEAD refs/heads/${NEW_BRANCH} # Change head to a new, non-existing ref
git rm -rf . # Delete files from version control and working directory
rm -r . # Delete files from file system
git commit --allow-empty -m "Created new branch ${NEW_BRANCH}" # Commit changes in the new branch
@jasonclark
jasonclark / booklist.js
Last active May 4, 2020 00:11
booklist javascript (jQuery) - calling google spreadsheet api, parsing response
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
//source Google Sheets file is https://docs.google.com/spreadsheets/d/1rX4_fInsYS7vOGpnXm1UklZgvU27FXl3UYu9lx9RHHU/
$(function listBooks() {
$.getJSON( "https://spreadsheets.google.com/feeds/list/1rX4_fInsYS7vOGpnXm1UklZgvU27FXl3UYu9lx9RHHU/1/public/full?alt=json",
function (data) {
$('div#book-list').append('<ul class="items"></ul>');
$.each(data.feed.entry, function(i,entry) {
var item = '<span style="display:none">' + entry.id.$t + '</span>';
@chrislkeller
chrislkeller / README.md
Last active February 3, 2022 08:02
Displaying data from a flat JSON file on a Handlebars.js template file rendered with AJAX.

Demo: ajax-handlebars

This repo's location has changed.

//Vamos criar um objeto 'Humanoide' que extende o objeto 'Model'
//'initialize' é o construtor e 'defaults' é um OBJETO, não um método
//veja a diferença de declaração. Não tem 'function'!
var Humanoide = Backbone.Model.extend({
initialize: function(nome, nascimento){
//o método de Humanoide tem um construtor que recebe
//dois parâmetros 'nome' e 'nascimento'
@diogomoretti
diogomoretti / fonts.styl
Last active November 20, 2019 06:37
Stylus mixin @font-face
// Fonts mixin
font-url(file)
return '../fonts/' + file
webfont(family, file, hack-chrome-windows = false, weight = 'normal')
@font-face
font-family family
src url(font-url(file + '.eot'))
src url(font-url(file + '.eot?#iefix')) format('embedded-opentype'),
url(font-url(file + '.woff')) format('woff'),
define([
// jquery core is always required
'jquery/core',
// jquery utilities
'jquery/ajax',
'jquery/data'
], function(jq, ajax, data) {
@danielrohers
danielrohers / app.js
Last active February 13, 2017 13:57
My JavaScript Module Pattern
;(function (w, d, undefined) {
'use strict';
var app = (function () {
var exports = {};
var _privateMethod = function () {
return 'private method';
@cferdinandi
cferdinandi / umd-script-boilerplate.js
Last active December 10, 2023 10:23
A simple boilerplate for UMD JS modules.
(function (root, factory) {
if ( typeof define === 'function' && define.amd ) {
define([], factory(root));
} else if ( typeof exports === 'object' ) {
module.exports = factory(root);
} else {
root.myPlugin = factory(root);
}
})(typeof global !== "undefined" ? global : this.window || this.global, function (root) {
@acauamontiel
acauamontiel / mixins.styl
Last active May 5, 2018 12:28
Useful mixins for Stylus
/*
* Clearfix
*/
clearfix()
&:before,
&:after
content ' '
display table
&:after
@Jiert
Jiert / JavaScript-Tabs.js
Last active November 29, 2023 11:40
Creating Tabs with Vanilla JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<title>Tabs</title>
<style>
.nav .active a { color: red; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
</style>
</head>