Skip to content

Instantly share code, notes, and snippets.

View dineshprabu-freshdesk's full-sized avatar

Dineshprabu S dineshprabu-freshdesk

View GitHub Profile
@dineshprabu-freshdesk
dineshprabu-freshdesk / super-tip.txt
Created May 10, 2018 11:52 — forked from ericdouglas/super-tip.txt
Change 4 spaces to 2 spaces indentation and change tab to spaces - Vim tip
// 4 spaces to 2 spaces
%s;^\(\s\+\);\=repeat(' ', len(submatch(0))/2);g
// Tab to 2 spaces
:%s/\t/ /g
@dineshprabu-freshdesk
dineshprabu-freshdesk / thread-pool.rb
Created April 8, 2018 03:39 — forked from rosenfeld/thread-pool.rb
Simple thread pool implementation in Ruby
require 'thread' # for Mutex: Ruby doesn't provide out of the box thread-safe arrays
class ThreadPool
def initialize(max_threads = 10)
@pool = SizedQueue.new(max_threads)
max_threads.times{ @pool << 1 }
@mutex = Mutex.new
@running_threads = []
end