Skip to content

Instantly share code, notes, and snippets.

View kevgathuku's full-sized avatar

Kevin Gathuku kevgathuku

View GitHub Profile
@kevgathuku
kevgathuku / alphabet. py
Created December 18, 2013 15:53
Generate alphabet
import string
print string.ascii_lowercase
print string.ascii_uppercase
@kevgathuku
kevgathuku / chown_lampp_htdocs.sh
Created April 22, 2014 10:36
Changes the ownership of the lampp htdocs to you
#!/bin/bash
#sudo chown username:groupname /opt/lampp/htdocs
sudo chown kevin:kevin /opt/lampp/htdocs
@kevgathuku
kevgathuku / synaptic
Created May 12, 2014 13:55
Start synaptic without entering root password
# Add file to /etc/sudoers.d/ folder
username ALL=(root) NOPASSWD:/usr/sbin/synaptic
@kevgathuku
kevgathuku / automount.sh
Last active August 29, 2015 14:01
Automount NTFS partition on startup
# Get the UUID
sudo blkid
# Create a mount point
sudo mkdir /media/kevin/newvolume
# Open /etc/fstab using gksu
gksu gedit /etc/fstab
#Line to add in /etc/fstab
@kevgathuku
kevgathuku / remove_remote
Created May 16, 2014 16:02
Remove remote origin
git remote rm origin
@kevgathuku
kevgathuku / links_external.js
Created May 23, 2014 23:42
Opens all external links on a website in a new tab
@kevgathuku
kevgathuku / move_docs.py
Created May 27, 2014 22:44
Move all PDF files from download folder
#!/usr/bin/python
import os
import glob, shutil
dst = "/media/kevin/volume/Tutorials/"
src = "/home/kevin/Downloads"
for file in glob.glob("/home/kevin/Downloads/*.pdf"):
shutil.move(file, dst)
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
pyg = 'ay'
while True:
original = raw_input('Enter a word: \t')
if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]
@kevgathuku
kevgathuku / ternary.js
Created October 12, 2014 16:37
Example of the ternary operator example in JS
//JS Ternary operator example
var protocol = document.location.protocol;
var prot = (protocol == 'http:' || protocol == 'https:') ? 'remote' : 'local'
console.log('You are viewing a ' + prot + ' file via the '+ protocol + ' protocol');
@kevgathuku
kevgathuku / breakLoop.js
Created October 12, 2014 21:06
Breaking out of a continuous loop in JS
var contain=new Array;
for (var current = 2; ; current++) {
if (current % 7 == 0)
contain[contain.length] = current;
//Common gotcha. use two equals signs for comparison
if (contain.length == 5)
break;
}