Skip to content

Instantly share code, notes, and snippets.

@srijanshetty
srijanshetty / once.js
Created June 30, 2014 16:58
Only once function
var once = function(fn, context) {
return function() {
if(!fn) {
return undefined;
}
// We call the function only once
fn.apply(context || this, arguments);
// Set the function to null
@srijanshetty
srijanshetty / recover-deleted-files
Last active August 29, 2015 14:03
Recover Files only using grep
grep --binary-files=text --context=x 'stringfromyourfile' \
/dev/whateverPartition > someFile.txt
@srijanshetty
srijanshetty / events.js
Created June 24, 2014 05:18
Pub Sub system
// Taken from David Walsh's blog
var events = (function() {
var topics = {};
return {
subscribe: function(topic, listener) {
if (!topics[topic]) {
topics[topic] = {
queue: []
};
@srijanshetty
srijanshetty / master.vim
Last active January 4, 2016 14:58 — forked from gmccreight/master.vim
Learn vim
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@srijanshetty
srijanshetty / fix-ubuntu-privacy.sh
Last active December 27, 2015 20:49
Fix Ubuntu Privacy settings
#!/usr/bin/bash
gsettings set com.canonical.Unity.Lenses remote-content-search none; if [ "`/usr/bin/lsb_release -rs`" \< '13.10' ]; then sudo apt-get remove -y unity-lens-shopping; else gsettings set com.canonical.Unity.Lenses disabled-scopes "['more_suggestions-amazon.scope', 'more_suggestions-u1ms.scope', 'more_suggestions-populartracks.scope', 'music-musicstore.scope', 'more_suggestions-ebay.scope', 'more_suggestions-ubuntushop.scope', 'more_suggestions-skimlinks.scope']"; fi; echo | sudo tee -a /etc/hosts; echo 127.0.0.1 productsearch.ubuntu.com | sudo tee -a /etc/hosts;