Highlighting text in Ruby ### Start code def highlight(text,search_string) keywords = search_string.squeeze.strip.split(” “).compact.uniq matcher = Regexp.new( ‘(‘ + keywords.join(“|”) + ‘)’ ) highlighted = text.gsub(matcher) { |match| “<b>#{match}</b>” } return highlighted end text = “This is an example of the text.” search = “example text” puts highlight(text,search) # => This is an <b>example</b> of the… Read More


Remove all node_module folders recursively find . -name “node_modules” -exec rm -rf ‘{}’ + That will delete the folder and files even if there is a space in the name. That saved me about 10GB over several hundred node projects which I had not touched in a while. If I need the node modules back,… Read More


Upstart script for DeepDetect Create upstart config /etc/init/deepdetect.conf description “DeepDetect” start on filesystem or runlevel [2345] stop on run level [!2345] respawn respawn limit 3 12 script exec /usr/bin/deepdetect.sh end script pre-start script echo “command_deepdetect_starting START : $(date)” >> /var/log/deepdetect.log end script pre-stop script rm /var/run/command_deepdetect_starting.pid echo “command_deepdetect_starting STOP : $(date)” >> /var/log/deepdetect.log end script… Read More


Install Squid proxy server on Ubuntu 14.04 Installing Squid Squid is available in the Ubuntu repositories. To ensure your system is up to date and then to install Squid, run the following commands: sudo apt-get update sudo apt-get upgrade sudo apt-get install squid Copy the original configuration file to keep as a backup: sudo cp… Read More


DeepDetect Client Rails Example Requirements Ubuntu 14.04 or Ubuntu 16.04 Rails 5+ Ruby 2.2+ Redis Install DeepDetect Install dependencies: sudo apt-get install build-essential libgoogle-glog-dev libgflags-dev libeigen3-dev libopencv-dev libcppnetlib-dev libboost-dev libboost-iostreams-dev libcurlpp-dev libcurl4-openssl-dev protobuf-compiler libopenblas-dev libhdf5-dev libprotobuf-dev libleveldb-dev libsnappy-dev liblmdb-dev libutfcpp-dev cmake libgoogle-perftools-dev unzip Clone & build deepdetect: cd && mkdir Projects && git clone git@github.com:beniz/deepdetect.git… Read More


Delete all unused repositories and forgotten forks in 6 (semi)-automatic steps! Github forces me to type name of repo for every fork and repository I want to delete. That’s smart and all, but what if one wants to mass-delete a bunch of old, unused, forgotten, dirty little repositories that make his repository list look like… Read More


To check limit open files ulimit -n To increase limit open files to 500000 on ubuntu, use command: sudo sh -c “ulimit -n 500000 && exec su $LOGNAME” Explain issues ulimit is a shell built-in command like cd you can’t use like: sudo cd /test/ similarly you can’t use sudo ulimit -c This is not… Read More


Rsync with a non-standard ssh port While doing some work on the JQuery Plugins site today, I needed to use rsync over ssh. The ssh daemon on the remote server runs on a non-standard port, and all the port related options to rsync only change settings if you’re running the rsync-daemon. After some searching, the… Read More