Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mkjasinski's full-sized avatar

Marcin Jasiński mkjasinski

View GitHub Profile
@mkjasinski
mkjasinski / npm-update
Created May 10, 2016 19:01
[shell] npm updater
#!/bin/sh
set -e
set -x
for package in $(sudo npm -g outdated --parseable --depth=0 | cut -d: -f4)
do
sudo npm -g install "$package"
done
@mkjasinski
mkjasinski / fetch-all-repos
Created April 19, 2016 13:40
[shell][git] fetch all repos
#!/bin/bash
#
for project in `ls -d */`; do
cd ./$project
if git s &>/dev/null; then
pwd
git s 2>/dev/null
git f 2>/dev/null
fi
cd ..
@mkjasinski
mkjasinski / change-owner
Created March 31, 2016 14:56
[PostgreSQL] change owner
#!/bin/bash
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" [db-name]` ; do
psql -c "alter table $tbl owner to \"[db-user]\"" [db-name] ;
done
for tbl in `psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" [db-name]` ; do
psql -c "alter table \"$tbl\" owner to \"[db-user]\"" [db-name] ;
done
@mkjasinski
mkjasinski / my-add-users
Created March 25, 2016 13:08
[linux] - bash script to creation users from file with logins
#!/bin/bash
for user in `cat ~/.my-users-to-add | grep -v "#"`; do
echo "Adding user [$user] ..."
if id -u "$user" >/dev/null 2>&1; then
echo "User $user exists"
else
useradd --shell /bin/bash -m $user
echo $user:$user | chpasswd
chmod ugo-rwx,ug+rwX /home/$user
chmod g+s /home/$user