Skip to content

Instantly share code, notes, and snippets.

@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;
@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 / 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 / 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 / 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 / bash-tricks
Last active August 29, 2015 14:03
Shell Tricks
I have marked with a * those which I think are absolutely essential
Items for each section are sorted by oldest to newest. Come back soon for more!
BASH
* In bash, 'ctrl-r' searches your command history as you type
- Input from the commandline as if it were a file by replacing
'command < file.in' with 'command <<< "some input text"'
- '^' is a sed-like operator to replace chars from last command
'ls docs; ^docs^web^' is equal to 'ls web'. The second argument can be empty.
* '!!:n' selects the nth argument of the last command, and '!$' the last arg
@srijanshetty
srijanshetty / cli-smtp.py
Last active August 29, 2015 14:04
SMTP client
#!/bin/python
def send_mail():
import smtplib
gmail_user=''
gmail_password=''
FROM=''
TO=['', '']
@srijanshetty
srijanshetty / lamp-setup.sh
Last active October 10, 2015 13:20
LAMP setup
# Install LAMP stack - Apache, MySQL, PHP
# as per http://fideloper.com/ubuntu-install-php54-lamp and/or http://fideloper.com/ubuntu-12-04-lamp-server-setup
sudo apt-get update # Update package repositories
sudo apt-get install -y git-core wget vim curl build-essential python-software-properties zsh # Install basics
sudo add-apt-repository -y ppa:ondrej/php5 # Add repository for php5.5 and Apache 2.4
sudo apt-get update # Update package repositories again after adding repository
sudo apt-get install -y php5 php5-mcrypt php5-gd php5-curl php5-mysql # Install PHP and common modules
sudo apt-get install -y apache2 libapache2-mod-php5 # Install Apache2
sudo apt-get install -y mysql-server # Install MySQL
@srijanshetty
srijanshetty / keybase.md
Last active September 10, 2019 06:13
Keybase Proof

Keybase proof

I hereby claim:

  • I am srijanshetty on github.
  • I am srijanshetty (https://keybase.io/srijanshetty) on keybase.
  • I have a public key ASBp2Y-KsbCsRcnWRk-J2dX68fY1hX6NXsPfnhuobDbC0go

To claim this, I am signing this object:

@srijanshetty
srijanshetty / elementary-os-luna-fix-ppa-errors.md
Last active February 23, 2016 18:14
Unable to add PPA in elementary OS

Solution

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install --reinstall base-files=6.5ubuntu6.7+elementary8~ubuntu0.2.1

Error was related to /etc/os-release and /etc/lsb-release. The files looked like this before: