How to activate a virtual environment via Bash
Create a file named anything.sh and make it executable Paste following code in file Run ./path-to-file.sh cd path/to/env/dir && source bin/activate
Create a file named anything.sh and make it executable Paste following code in file Run ./path-to-file.sh cd path/to/env/dir && source bin/activate
Create a file import.sh and make it executable Paste following code in file mysqluser='root' mysqlpass='password' mysqldb='database_name' tablename='mysql_table_name' DIRECTORY='input_directory' for csv in $DIRECTORY/*.csv; do echo "Loading $csv" mysql -u $mysqluser --password=$mysqlpass -D $mysqldb -e "LOAD DATA INFILE '$csv' IGNORE INTO TABLE $tablename FIELDS TERMINATED BY '\t' ENCLOSED BY '\"' LINES TERMINATED BY '\n' IGNORE 1 LINES;" done
I know this method isn’t the most secure way. But when I’m working on personal projects, it gets annoying having to enter credentials every time. Hence, I put together this little script to quickly log me in. I create file mysql.sh with following contents mysql -u username --password='password_here'
Let’s say you have a script called crawl.py and you never want two instances of it running at the same time. The following script can do the job RUNNING="$(ps aux|grep crawl|grep -v grep|wc -l)" if [ $RUNNING -eq 0 ] then python crawl.py else echo "Already running : skipping"; fi
First install zip if not already install Ubuntu apt-get install zip Centos yum install zip Then create a file.sh and paste following code OUTFILE=outputfile.zip INPUTDIR=inputdir zip -R $OUTFILE $INPUTDIR scp $OUTFILE usrename@outserver:/path/of/ $OUTFILE -i key.pem
Run an update first apt-get update Install necessary dev tools apt-get install -y zip unzip wget curl youtube-dl git subversion dconf-editor build-essential Install Sublime Text apt-get update sudo apt install -y dirmngr gnupg apt-transport-https ca-certificates software-properties-common curl -fsSL https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add - sudo add-apt-repository "deb https://download.sublimetext.com/ apt/stable/" sudo apt install -y sublime-text Install Google chrome apt-get update wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb sudo dpkg -i google-chrome-stable_current_amd64.deb Install Apache, MySQL, PHP, PHPMyAdmin Apache and MySQL apt-get update sudo apt install -y apache2 mysql-server sudo mysql_secure_installation PHP, PHPMyAdmin and some extensions ...
Following method can be used for creating a new user in Apache. This comes in real handy for my projects that user Apache authentication. I run following command when I’m asked to create a new user. htpasswd /etc/httpd/.htpasswd username_here
find directory -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c
for i in {1..number_of_loops}; do commandsSeparatedBySemicolon; done;
This article offers a sample of basic Markdown syntax that can be used in Hugo content files, also it shows whether basic HTML elements are decorated with CSS in a Hugo theme. ...