Better late than never
Truncate file into Mb’s
$ sudo truncate -s 10M filename.log
Truncate file into Gb’s
$ sudo truncate -s 1G filename.log
Security Researcher, DevOps, SRE
Better late than never
Truncate file into Mb’s
$ sudo truncate -s 10M filename.log
Truncate file into Gb’s
$ sudo truncate -s 1G filename.log
It’s always a pleasure to have html tags tidy and attached to one another. especially if these html tags are yours in your website. To have this we can do with a simple php function. Place the code below at the top of header php page or index page.
<?php function sanitize_output($buffer) { $search = array( '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s', '/<!--(.|\s)*?-->/' ); $replace = array( '>', '<', '\', '' ); $buffer = preg_replace($search, $replace, $buffer); return $buffer; } ob_start("sanitize_output"); ?>
$ mkdir ~/mymodules $ cd ~/mymodules ~/mymodules~$ puppet module generate pulpn-test --skip-interview
$ puppet module install puppetlabs-stdlib
$ puppet module build ~/mymodules/test
So, I needed to download songs from youtube but not as a video but only audio. Then I went to this website to convert these video as usual. The website that I used to convert video from youtube was popped out ads that I didn’t like. I started to thinking why the hell that I need those websites anyway? just use the terminal instead.
$ youtube-dl --extract-audio --audio-format mp3 <youtube-url>
uWSGI is driving me crazy when install it, every single time. I’m using Centos 6.9 to setup my python app.
This one is for setup uWSGI and make sure you already installed Python2.7 on your machine:
$ wget https://bootstrap.pypa.io/get-pip.py $ which python2.7 $ sudo /usr/local/bin/python2.7 get-pip.py $ which pip2.7 $ sudo /usr/local/bin/pip2.7 install uWSGI $ which uwsgi $ uwsgi --version
Test your app with uWSGI manually:
$ sudo /usr/local/bin/uwsgi --ini /dir/to/app/uwsgi.ini
Setup vassels from uwsgi ini file
$ sudo mkdir -p /etc/uwsgi/vassels $ sudo ln -s /dir/to/app/uwsgi.ini /etc/uwsgi/vassels/appname.ini
$ sudo vim /etc/init.d/emperor
#!/bin/sh # chkconfig: 2345 99 10 # Description: Starts and stops the emperor-uwsgi # See how we were called. RUNEMPEROR="/usr/local/bin/uwsgi --emperor=/etc/uwsgi/vassels" PIDFILE=/var/run/emperor-uwsgi.pid LOGFILE=/var/log/uwsgi/emperor.log start() { if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then echo 'Service emperor-uwsgi already running' >&2 return 1 fi echo 'Starting Emperor...' >&2 local CMD="$RUNEMPEROR &> \"$LOGFILE\" & echo $!" su -c "$CMD" > "$PIDFILE" echo 'Service started' >&2 } stop() { if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then echo 'Service emperor-uwsgi not running' >&2 return 1 fi echo 'Stopping emperor-uwsgi' >&2 kill -7 $(cat "$PIDFILE") && rm -f "$PIDFILE" echo 'Service stopped' >&2 } status() { if [ ! -f "$PIDFILE" ]; then echo "Emperor is not running." >&2 return 1 else echo "Emperor (pid `cat ${PIDFILE}`) is running..." ps -ef |grep `cat $PIDFILE`| grep -v grep fi } case "$1" in start) start ;; stop) stop ;; status) status ;; restart) stop start ;; *) echo "Usage: emperor {start|stop|restart}" exit 1 esac
$ sudo chmod +x /etc/init.d/emperor $ sudo /etc/init.d/emperor start $ sudo chkconfig emperor on
Check your app if it’s already running:
$ sudo ps -ef | grep uwsgi