Skip to content

Instantly share code, notes, and snippets.

View ivanhuay's full-sized avatar

ivan huayraña ivanhuay

View GitHub Profile
@ivanhuay
ivanhuay / country ips
Created July 5, 2017 12:44
scrypt for search country of ips files
#!/bin/bash
FILE=$1
if [ -f $FILE ];
then
while read line
do
resp=`curl -s "http://freegeoip.net/json/$line"|grep -Eo "\"country_name\":\"[a-zA-Z\ ]{4,50}\""`
echo "$line $resp"
@ivanhuay
ivanhuay / changeBackground.sh
Last active January 19, 2017 20:01
change background to scare a friend
#!/bin/bash
USERBACKGROUND=$( gsettings get org.gnome.desktop.background picture-uri )
IMAGES=("wallhaven-466058.png" "wallhaven-284216.jpg" "wallhaven-452660.jpg" "wallhaven-452652.jpg" "wallhaven-418590.jpg" "wallhaven-360663.jpg")
STARTTIME=5
function getImages {
for i in ${IMAGES[@]}; do
echo "dowloading https://wallpapers.wallhaven.cc/wallpapers/full/${i} ..."
@ivanhuay
ivanhuay / randomVolume.sh
Last active January 18, 2017 16:41
Bash script to change volumen random
#!/bin/bash
COUNTER=0
STARTWAIT=20
echo "waiting $STARTWAIT seconds!"
sleep $STARTWAIT
echo "Random volumen >:D"
while true; do
echo "number: $COUNTER"
if [ $(( COUNTER % 2 )) -eq 0 ]; then
RANDOMPERCENT=$( node -e "console.log(Math.round(Math.random()*50)+10)" )
@ivanhuay
ivanhuay / install-node.sh
Created January 5, 2017 01:22
install node latest - ubuntu 16.04
#!/bin/bash
sudo apt-get update
sudo apt-get install nodejs -y
sudo apt-get install npm -y
sudo npm install -g n
sudo n latest
sudo npm install -g npm
echo "(^_^)\n done!!"
@ivanhuay
ivanhuay / install-mongodb.sh
Created January 5, 2017 01:17
install mongodb 3 - ubuntu 16.04
#!/bin/bash
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
sudo apt-get update
sudo apt-get install -y mongodb-org
@ivanhuay
ivanhuay / nw_dependencies
Created November 3, 2016 18:36
Installer node webkit dependencies
#!/bin/bash
sudo apt-get install libxss1:i386
sudo apt-get -y install libx11-6:i386 libglib2.0-0:i386 libgtk2.0-0:i386 libatk1.0-0:i386 libgdk-pixbuf2.0-0:i386 libcairo2:i386 libfreetype6:i386 libfontconfig1:i386 libxcomposite1:i386 libasound2:i386 libxdamage1:i386 libxext6:i386 libxfixes3:i386 libnss3:i386 libnspr4:i386 libgconf-2-4:i386 libexpat1:i386 libdbus-1-3:i386
sudo apt-get install libudev1:i386
sudo ln -sf /lib/x86_64-linux-gnu/libudev.so.1 /lib/x86_64-linux-gnu/libudev.so.0
@ivanhuay
ivanhuay / docker_restore_mongo_volume.sh
Created August 9, 2016 14:29
Simple scripr for restore mongo volumen from .tar file
#!/bin/bash
DOCKER_MONGO_CONTAINER=$1
INPUT_FILE=$2
if [ $# -eq 2 ];then
if echo $INPUT_FILE |grep '.tar' ;then
docker run --rm --volumes-from $DOCKER_MONGO_CONTAINER -v $(pwd):/backup ubuntu bash -c "cd /data && tar xvf /backup/$INPUT_FILE --strip 1"
if [ $? -eq 0 ]; then
echo "volume success loaded to $DOCKER_MONGO_CONTAINER";
echo "Restarting container."
@ivanhuay
ivanhuay / docker_dump_mongo_volume.sh
Created August 9, 2016 14:10
Simple script for backup the volume if mongodb container
#!/bin/bash
DOCKER_MONGO_IMAGE=$1
OUT_FILE=$2
if [ $# -eq 2 ];then
if echo $OUT_FILE |grep '.tar' ;then
docker run --rm --volumes-from $DOCKER_MONGO_IMAGE -v $(pwd):/backup ubuntu tar cvf /backup/$OUT_FILE /data/db
else
echo "Invalid out_file: \"$OUT_FILE\". The out file require .tar extension!"
fi
@ivanhuay
ivanhuay / curl-fl.sh
Created July 6, 2016 13:36
bash script for execute curl to each file line
#!/bin/bash
FILE=$1
if [ -f $FILE ];
then
while read line
do
resp=`curl -s $line`
echo "$line $resp"
#!/bin/bash
ERROR_FILE="$HOME/shell/error.log"
COMMAND="$1"
PARAMS="${@:2}"
FULL_COMMAND="$COMMAND $PARAMS"