Skip to content

Instantly share code, notes, and snippets.

View gabrielhpugliese's full-sized avatar

Gabriel Pugliese gabrielhpugliese

View GitHub Profile
>>> import gc
>>> gc.isenabled()
True
>>> gc.get_count()
(411, 8, 0)
>>> def a():
... import functools
... return
...
>>> gc.get_count()
var tryReload = null;
function handleMigration () {
var pathsToNotReload = [Router.routes.coder.name, Router.routes.video.name];
if (_.contains(pathsToNotReload, Router.current().route.name)) {
Meteor._reload.onMigrate('session', function(reloadFunc) {
tryReload = reloadFunc;
return [false, {keys: []}];
});
} else {
@gabrielhpugliese
gabrielhpugliese / chatroom-that-raises.js
Last active December 25, 2015 02:29
First one raises: Uncaught TypeError: Cannot read property 'win' of null Uncaught TypeError: Cannot read property 'delaylist' of null
Meteor.startup(function () {
Session.set('chatroomRendered', false);
});
Template.chatroom.rendered = function () {
Session.set('chatroomRendered', true);
};
Deps.autorun(function () {
if (Session.equals('chatroomRendered', false)) {
function getFileExtension(i) {
// i will be a string, but it may not have a file extension.
// return the file extension (with no period) if it has one, otherwise false
var splitted = i.split('.');
return splitted.length > 1 && splitted[splitted.length - 1];
}
@gabrielhpugliese
gabrielhpugliese / ga.js
Last active December 23, 2015 05:29
client/compatibility.js
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXXXX-X']);
(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);
})();
@gabrielhpugliese
gabrielhpugliese / meteor_ytapi.js
Created September 7, 2013 21:17
Snippet for using Google Youtube APIs with Meteor rendering engine (not Meteor UI). Assume the template is called "channel". You only need to implement onPlayerReady of line 44. It uses jQuery.getScript();
Meteor.startup(function () {
Session.set('YTApiReady', false);
Session.set('channelRendered', false);
});
onYouTubeIframeAPIReady = function() {
Session.set('YTApiReady', true);
};
Template.channel.created = function () {
@gabrielhpugliese
gabrielhpugliese / restweek.js
Created September 7, 2013 17:36
Snippet pra consertar a busca do site do Restaurant Week
function OpenInNewTab(e){var t=window.open(e,"_blank");t.focus()}jQuery("#contentResultadoBusca li").unbind("click");jQuery("#contentResultadoBusca").delegate("li","click",function(e){e.preventDefault();OpenInNewTab("http://www.restaurantweek.com.br/2013/restaurante.asp?idEdicao=130&idRestaurante="+$(this).attr("id"))})
@gabrielhpugliese
gabrielhpugliese / mesosphere.js
Last active December 20, 2015 15:59
Validating if user submits form with date > now()
Mesosphere.registerRule('checkDate', function (fieldValue, ruleValue) {
console.log('checkDate')
if (!ruleValue) {
return true;
}
var date = fieldValue.split('-'),
today = new Date((new Date()).setHours(0, 0, 0, 0));
date = new Date(date[0], date[1] - 1, date[2]);
@gabrielhpugliese
gabrielhpugliese / index.html
Created July 10, 2013 20:55
mrt run --production with spiderable
TypeError: 'undefined' is not a function (evaluating 'function(){return Deps.depend(this.deps),this.path}.bind(this)')
http://localhost:3000/a7d200f413e11c8d7202715ef9d654ad851cf80a.js:12
http://localhost:3000/a7d200f413e11c8d7202715ef9d654ad851cf80a.js:12
http://localhost:3000/a7d200f413e11c8d7202715ef9d654ad851cf80a.js:12
<!DOCTYPE html><html><head>
<link rel="stylesheet" href="/e90bf69678257a5c934d9ef58a8acc0f501f56e4.css">
@gabrielhpugliese
gabrielhpugliese / index.html
Created July 10, 2013 20:40
spiderable meteorjs
TypeError: 'undefined' is not a function (evaluating 'function () {
Deps.depend(this.deps);
return this.path;
}.bind(this)')
http://localhost:3000/packages/superchat/client/application.js?da6559e5198eb638e4346c47d5b797c0491f6585:8
http://localhost:3000/packages/superchat/client/application.js?da6559e5198eb638e4346c47d5b797c0491f6585:20
http://localhost:3000/packages/superchat/client/application.js?da6559e5198eb638e4346c47d5b797c0491f6585:37
TypeError: 'null' is not an object (evaluating 'document.body.insertBefore')