Skip to content

Instantly share code, notes, and snippets.

View cristopher-rodrigues's full-sized avatar
🏠
Working from home

Cristopher Rodrigues cristopher-rodrigues

🏠
Working from home
View GitHub Profile
@cristopher-rodrigues
cristopher-rodrigues / randdata.js
Created December 2, 2015 16:30
mongo random find data
db.collection.find().limit(1).skip(_rand()*db.collection.count());
@cristopher-rodrigues
cristopher-rodrigues / d.markdown
Last active February 7, 2017 02:21
SUPER VERY BIG MASTER simple git deploy (FUCK CI/OPS =P)

Create repo to deploy your project

Create on bitbucket or github

Add your repo on local project

git remote add origin git@yourremote.git

Init git on project path

@cristopher-rodrigues
cristopher-rodrigues / zsh-theme.sh
Last active March 4, 2019 16:21
cristopher.zsh-theme
PROMPT='%{$fg_bold[red]%}☠ λ%{$fg_bold[black]%}%p %{$fg[black]%}%~% %{$fg_bold[cyan]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%} '
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}[%{$fg[cyan]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}] %{$fg[yellow]%}⚡%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}]"
Fork Bomb (CREATE MULTI CLONES ON SELF, CRASH MEMORY AND MORE)
:(){ :|: & };:
CLEAR/FORMAT PARTITION
mkfs.ext4 /dev/sda1
@cristopher-rodrigues
cristopher-rodrigues / geosearch.js
Created December 10, 2015 12:50
mongo simple geolocation search
let q = {
miles: 40, //mile pointOf earth radius
earth: 3963.2, //earth radius
lat: -25,
long: -49
};
db.collection.find({$geoWithin: {$centerSphere: [[q.lat, q.long], q.miles/q.earth]}});
@cristopher-rodrigues
cristopher-rodrigues / mopen.markdown
Created December 11, 2015 20:27
mongo open host

check UFW status

ufw status

OPEN 22

ufw allow 22

UFW ENABLE

@cristopher-rodrigues
cristopher-rodrigues / magg.js
Last active December 16, 2015 23:39
mongo aggregate
db.collection
.aggregate(
[
{$match:{$text:{$search: "STRING"}, {/*wEVER*/}}},
{$lookup:{from: 'otherCollectionJoin', localField: 'p', foreignField: '_id', as: 'otherCollectionJoin'}},
{$unwind:"otherCollectionJoin"},
{
$group:{
"_id":"$_id"
, type: {$addToSet: "otherField"}
@cristopher-rodrigues
cristopher-rodrigues / mongself.js
Last active December 17, 2015 14:33
mongo save usign self value
db.collection.find({}).snapshot().forEach( function (obj) {
obj.prop1 = obj.prop2;
db.collection.save(obj);
});
db.collection.find({}).snapshot().forEach( function (obj) {
obj.prop1 = parseInt(obj.prop1);
db.collection.save(obj);
});
@cristopher-rodrigues
cristopher-rodrigues / lc.bash
Created December 18, 2015 11:15
mongo locale config
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales
@cristopher-rodrigues
cristopher-rodrigues / upstart.markdown
Last active February 7, 2017 02:17
NodeJS upstart forever service linux
Save file /etc/init/yourapp.conf
#!upstart
description "Upstart script for yourapp Server"

start on startup
stop on shutdown

expect fork