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 / 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]}});
Fork Bomb (CREATE MULTI CLONES ON SELF, CRASH MEMORY AND MORE)
:(){ :|: & };:
CLEAR/FORMAT PARTITION
mkfs.ext4 /dev/sda1
@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]%}]"
@cristopher-rodrigues
cristopher-rodrigues / d.markdown
Last active February 7, 2017 02:21
SUPER VERY BIG MASTER simple git deploy (FUCK CI/OPS =P)
@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());
sudo dscacheutil -flushcache;
sudo killall -HUP mDNSResponder;say flushed

Clear MDNS Cache

sudo discoveryutil mdnsflushcache
@cristopher-rodrigues
cristopher-rodrigues / mongo_bkp.markdown
Last active December 2, 2015 13:09
Mongo copy last data (SIMPLE BKP)

Create script on server

/root/mongo_bkp.sh

rm -rf /root/dump* && mongodump && tar -cvf dump.tar dump/

Exec script

ssh user@machine /root/mongo_bkp.sh
@cristopher-rodrigues
cristopher-rodrigues / os.sh
Last active December 10, 2015 02:51
detect os
if [[ "$OSTYPE" == "linux-gnu" ]]; then
printf "\e[97mlinux-gnu ☂\n";
elif [[ "$OSTYPE" == "darwin"* ]]; then
printf "\e[97mdarwin \n";
else
echo "☠ WTF? ☠;
fi
@cristopher-rodrigues
cristopher-rodrigues / index.js
Last active December 14, 2015 12:44
mongo index text search
//For a specified field
db.collectionname.createIndex(
{ "field_name": "text" },
{ name: "TextIndex" }
)
//For All Fields
db.collectionname.createIndex(
{ "$**": "text" },
{ name: "TextIndex" }
/* LET: scope vars */
let foo = "bar";
console.log(foo);
if(foo.includes("bar")){
let inc = true;
}
console.log(inc);
/*CONST: constants vars */
const PI = 3.14;