Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home forever and ever

Max Claus Nunes maxcnunes

🏠
Working from home forever and ever
View GitHub Profile
@maxcnunes
maxcnunes / inspect-nginx.sh
Created Feb 2, 2014
Nginx not running with no error message
View inspect-nginx.sh
# 1. discover what is wrong
sudo nginx -t
# 2. fix everything
# 3. restart the service
sudo service nginx restart
View class_and_array.js
function Produto(nome, qtd){
var self = this;
self.Nome = nome || '';
self.Qtd = qtd || 0;
return self;
}
var arroz = new Produto("Arroz", 10);
View error.sh
vagrant@srv:/srv/my-project$ npm install
npm http GET https://registry.npmjs.org/factory-mysql-fixtures
npm http 304 https://registry.npmjs.org/factory-mysql-fixtures
npm ERR! notarget No compatible version found: factory-mysql-fixtures@'maxcnunes/factory-mysql-fixtures'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["0.0.2"]
npm ERR! notarget
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
View Dockerfile
FROM ubuntu
MAINTAINER Max Claus Nunes
RUN apt-get install -y python-software-properties python
RUN add-apt-repository ppa:chris-lea/node.js
RUN echo "deb http://us.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y nodejs
#RUN apt-get install -y nodejs=0.6.12~dfsg1-1ubuntu1
RUN mkdir /var/www
@maxcnunes
maxcnunes / install_nginx.sh
Last active Aug 29, 2015
install nginx stable version on ubuntu 13.10
View install_nginx.sh
# for <= ubuntu 12.04
sudo apt-get install python-software-properties
# for >= ubuntu 12.10
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
View check_file_directory_exists.sh
# inline
[ -d "my_dir" ] && echo "Yes" || echo "No"
[ -f "my_file" ] && echo "Yes" || echo "No"
# function
dir_exists() {
( test -d $1 > /dev/null 2>&1 ) && return 0 || return 1
}
file_exists() {
View loop-insert-mongo.js
#!/usr/bin/env node
var MongoClient = require('mongodb').MongoClient,
format = require('util').format,
async = require('async');
MongoClient.connect('mongodb://127.0.0.1:27017/test_mongo', function(err, db) {
if(err) throw err;
var collection = db.collection('test_insert');
View docker-helpful-commands.sh
# remove all trash images
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')
# or
docker rmi $(docker images -q -f dangling=true)
# stop all projects by name
docker stop $(docker ps | grep "container_name" | awk '{print $1}')
# get public port by private port and container name
docker port container_name_or_id 27017 | awk -F':' '{print $2}'
View mongo-import-export
mongoexport --collection collectioname --db databasename --out /tmp/output
mongoimport --collection collectioname --db databasename --file /tmp/list-to-import.json --jsonArray --stopOnError
View list-255-bash-colors.sh
for code in {0..255}; do echo -e "\e[38;05;${code}m $code: Test"; done
You can’t perform that action at this time.