Skip to content

Instantly share code, notes, and snippets.

@motleytech
motleytech / pysync.py
Last active December 5, 2018 22:40
Rsync like functionality via python and cp - much faster for certain purposes
# script to smartly backup files using cp rather than rsync
import sys
import os
import exceptions
from pprint import pprint as pp
def removeFile(fp):
os.remove(fp)
@motleytech
motleytech / renameFiles.py
Last active November 30, 2018 19:06
Rename files
import sys
import os
import traceback
from pprint import pprint as pp
import string
def cleanupName(s):
while ' ' in s:
s = s.replace(' ', ' ')
@motleytech
motleytech / revMouseScroll.py
Created April 6, 2018 05:46
Python script to reverse mouse scroll direction.
from _winreg import *
"""print r"*** Reading from HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\HID ***" """
aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
FLIP_FLOP_VALUE = 1
aKey = OpenKey(aReg, r"SYSTEM\CurrentControlSet\Enum\HID")
for i in range(1024):
@motleytech
motleytech / javascript_useful_methods.js
Last active July 3, 2016 02:12
Javascript useful methods
// returns a range as a list
function range(start, stop, step) {
let result = []
if (step === undefined) {
step = 1
}
if (stop === undefined) {
stop = start
start = 0
}
@motleytech
motleytech / random.js
Created June 29, 2016 23:32
Utility functions for random number generation
// Returns a random number between min (inclusive) and max (exclusive)
function rand(min, max) {
return Math.random() * (max - min) + min;
}
// Returns a random integer between min (included) and max (excluded)
// Using Math.round() will give you a non-uniform distribution!
function randInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
@motleytech
motleytech / ls_colors.md
Created June 25, 2016 05:35
ls colors and shortcuts

If you are missing colors in the terminal / console, (and the 'l' shortcut command) here is how to fix that.

Open your ~/.bashrc file in an editor

vim ~/.bashrc

and add the following at the bottom

@motleytech
motleytech / git_shortcuts.md
Created June 25, 2016 05:33
git shortcuts and aliases

Here are some useful git config options for

  1. Displaying colors in status and diff outputs.
  2. Creating aliases and shortcuts for common git commands.
  3. Setting shortcuts from the command line itself.

First, create a ~/.gitconfig file for your user account, which will store the changes we are about to make.

touch ~/.gitconfig
@motleytech
motleytech / fix_scrollbar.md
Created June 25, 2016 05:31
Fix ubuntu scrollbars
sudo apt-get remove overlay-scrollbar
sudo apt-get remove liboverlay-scrollbar-0.2-0
sudo apt-get remove liboverlay-scrollbar3-0.2-0
@motleytech
motleytech / ubuntu_share.md
Created June 25, 2016 05:29
access ubuntu samba share

Often, my work involves sharing a folder in my Ubuntu vm to access it from the host machine, and every once in a while, samba refuses to play ball (Samba is the one who is in charge of sharing folders).

Here is how to fix the problem. After enabling the share in the folder properties (keeping guest access off), we will have to give explicit permissions for a user to access the shared folder.

Suppose your username on ubuntu is testuser. Type the following commands to give access to the test user...

$ useradd -N -M -g sambashare testuser

$ smbpasswd -a testuser
@motleytech
motleytech / utils_osx_emulation.ahk
Last active June 23, 2016 21:07
os x key emulation in windows
; Show on all desktops and Always on top shortcuts for windows
WS_EX_TOOLWINDOW := 0x00000080
+MButton::WinSet, ExStyle, ^%WS_EX_TOOLWINDOW%, A
^MButton::WinSet, AlwaysOnTop, toggle, A
; osx key emulation
#Right::send {End}
#Left::send {Home}
#+Right::send {LShift down}{End}{LShift up}
#+Left::send {LShift down}{Home}{LShift up}