Skip to content

Instantly share code, notes, and snippets.

View sdushantha's full-sized avatar

Siddharth Dushantha sdushantha

View GitHub Profile
@igniteflow
igniteflow / rename.py
Created September 19, 2011 16:41
Python script to rename files in directory, transforming spaces to hyphens and the chars to lowercase
import os
"""
Renames the filenames within the same directory to be Unix friendly
(1) Changes spaces to hyphens
(2) Makes lowercase (not a Unix requirement, just looks better ;)
Usage:
python rename.py
"""
@jasonrdsouza
jasonrdsouza / key_detect.py
Created February 24, 2012 15:54
Python function to get keypresses from the terminal
def getchar():
#Returns a single character from standard input
import tty, termios, sys
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(sys.stdin.fileno())
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
@adamjohnson
adamjohnson / publickey-git-error.markdown
Last active July 9, 2024 09:54
Fix "Permission denied (publickey)" error when pushing with Git

"Help, I keep getting a 'Permission Denied (publickey)' error when I push!"

This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

  1. Open git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. Pro Tip: You can use any *nix based command prompt (but not the default Windows Command Prompt!)
  2. Type cd ~/.ssh. This will take you to the root directory for Git (Likely C:\Users\[YOUR-USER-NAME]\.ssh\ on Windows)
  3. Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type ls to see a directory listing. If those two files don't show up, proceed to the next step. NOTE: Your SSH keys must be named id_rsa and id_rsa.pub in order for Git, GitHub, and BitBucket to recognize them by default.
  4. To create the SSH keys, type ssh-keygen -t rsa -C "your_email@example.com". Th
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
#!/bin/bash
# unzip the .ipa file
unzip -q "$1"
# Default information
displayName=`/usr/libexec/PlistBuddy -c "Print CFBundleDisplayName" Payload/*/Info.plist`
bundleIdentifer=`/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" Payload/*/Info.plist`
versionName=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" Payload/*/Info.plist`
@APadierna
APadierna / dilbert.py
Last active November 14, 2021 14:58
Script to download The dilbert comic strips
#!/usr/bin/env python
"""
Simple script to download the Dilbert comic strips in a defined period of time
If no arguments are passed to the script, it will download all the Dilbert comic
strips in the current folder (It may take a while).
Acknowledgments
---------------
This script is strongly based in the work from:
@iacchus
iacchus / Show_Images_in_Terminal_Emulator.md
Last active October 6, 2023 04:16
Show Images in terminal emulator
@fimkap
fimkap / gist:565d97a6a57a7b9283c8663ae8c9eab1
Created January 12, 2017 09:25
NeoVim, FZF and termpix setup
install termpix from https://github.com/fimkap/termpix (currently alpha blending done with white background)
-- init.vim (along with usual FZF setup, change path to termpix)
let g:fzf_layout = { 'down': '~60%' }
let g:fzf_files_options =
\ '--preview "(~/dev/termpix/bin/termpix --width 50 --true-color {} || cat {}) 2> /dev/null "'
@saurabhshri
saurabhshri / pip.md
Last active June 7, 2024 12:58
Install and use pip in a local directory without root/sudo access.

Install and use pip in a local directory without root/sudo access.

Why?

Many users when are given server access, do not have root (or sudo) privileges and can not simply do sudo apt-get install python-pip . Here's an easy way you can install and use pip without root (or sudo) access in a local directory. Note : This works without easy_install too.

How?

@igniteflow
igniteflow / python-command-line.md
Last active May 13, 2018 11:48
Creating a command-line app with Python
  1. Create a setup.py:
  #!/usr/bin/env python

  from distutils.core import setup

  setup(
      name='My Thing',
 version='1.0',