Skip to content

Instantly share code, notes, and snippets.

View gabrielhpugliese's full-sized avatar

Gabriel Pugliese gabrielhpugliese

View GitHub Profile
#!/bin/bash
sudo apt-get update
sudo apt-get install python-software-properties
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | sudo tee -a /etc/apt/sources.list.d/10gen.list
sudo apt-get update
sudo apt-get install -y git mongodb-10gen curl
cd /usr/local
wget http://nodejs.org/dist/v0.8.23/node-v0.8.23-linux-x86.tar.gz
sudo tar -xvzf node-v0.8.23-linux-x86.tar.gz --strip=1
@gabrielhpugliese
gabrielhpugliese / entities.py
Last active December 16, 2015 19:18
Initialization of tests for Flask+PyMongo
class Entities(object):
def __init__(self, mongo=None):
self.mongo = mongo or PyMongo(app)
def do_something(self):
with app.test_request_context():
user = {'_id': _id, 'states': []}
return self.mongo.db.entities.insert(user)
Package.describe({
summary: "Chat with Github Flavored Markdown and social login"
});
Package.on_use(function (api, where) {
// Client
api.use([
'startup',
'session',
'templating',
http {
// there is other config here
server {
listen 443;
access_log /var/log/nginx/meteorapp.access.log;
error_log /var/log/nginx/meteorapp.error.log;
@gabrielhpugliese
gabrielhpugliese / snmp-nagios.sh
Created June 14, 2013 19:13
Fast installation of SNMP for Mongu.ru
#!/bin/bash
apt-get install -y snmpd
theusername=`head -c 1200 /dev/urandom | md5sum | head -c 8`
thepassword=`head -c 1200 /dev/urandom | md5sum | head -c 32`
service snmpd stop
net-snmp-config --create-snmpv3-user -ro -a MD5 <<EOF
@gabrielhpugliese
gabrielhpugliese / meteor-windows-vagrant-tutorial.md
Last active May 22, 2026 22:28
Tutorial for running Meteor in Windows using Vagrant

Tutorial: Meteor in Windows using Vagrant

BEFORE YOU CONTINUE:

  • Now, Meteor runs in any Windows without any line of this tutorial. Just download the Meteor binary! Yay!!
  • mrt is no longer used with Meteor 1.0

These days some people were discussing at meteor-talk group about running Meteor at Windows and I’ve recommended them using Vagrant. It’s a very developer-friendly piece of software that creates a virtual machine (VM) which let you run any operating system wanted and connect to it without big efforts of configuration (just make the initial installation and you have it working).

Many packages (I've tested) for running Meteor+Vagrant fails because Meteor writes its mongodb file and also other files inside local build folder into a shared folder between the Windows host and the Linux guest, and it simply does not work. So I've put my brain to work and found a solution: do symlinks inside the VM (but do not use ln. Use mount so git can follow it). It’s covered on

@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')
@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 / 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 / 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"))})