Skip to content

Instantly share code, notes, and snippets.

View w33tmaricich's full-sized avatar

Alexander Maricich w33tmaricich

  • LightFeather.io
  • Bowie, MD
View GitHub Profile
@w33tmaricich
w33tmaricich / files.py
Last active March 21, 2016 14:12
py: number of files in directory
import os
number = len([name for name in listdir('.') if isfile(name)])
@w33tmaricich
w33tmaricich / download.py
Last active March 21, 2016 14:12
py: download from url
def download(url):
"""
Copy a file from a given url to a local file
"""
import urllib
webfile = urllib.urlopen(url)
localfile = open(url.split('/')[-1], 'w')
localfile.write(webfile.read())
webfile.close()
localfile.close()
@w33tmaricich
w33tmaricich / sql_firelizzard.php
Last active March 21, 2016 14:12
php: ethan's sql library
<?php
class SQLConnection {
private $link, $host, $user, $pass, $dbname, $new, $flags;
function __construct($host,
$user,
$pass,
$dbname = "",
$new = false,
$flags = 0,
@w33tmaricich
w33tmaricich / keyboard_shortcuts.txt
Last active February 6, 2020 12:46
ref: emacs keyboard shortcuts
Emacs Commands List
C = Control
M = Meta = Alt|Esc
Basics
C-x C-f "find" file i.e. open/create a file in buffer
C-x C-s save the file
C-x C-w write the text to an alternate name
C-x C-v find alternate file
@w33tmaricich
w33tmaricich / osx_shortcuts.txt
Last active March 21, 2016 14:11
ref: osx keyboard shortcuts
Screen Capture to disk:
⌘ ⇧ 3 Screen to jpeg file on desktop
⌘ ⇧ 4 + Drag: Selection to jpeg file on desktop
⌘ ⇧ 4 + Spacebar: Window (click camera) to jpeg file
Screen Capture to clipboard:
⌘ ⇧ 3 + Ctrl: Screen to clipboard
⌘ ⇧ 4 + Drag + Ctrl: Selection to clipboard
⌘ ⇧ 4 + Spacebar + Ctrl Window (Camera effect)
window.onload = function () {
if (typeof history.pushState === "function") {
history.pushState("jibberish", null, null);
window.onpopstate = function () {
history.pushState('newjibberish', null, null);
// Handle the back (or forward) buttons here
// Will NOT handle refresh, use onbeforeunload for this.
};
}
else {
@w33tmaricich
w33tmaricich / redirect.html
Last active March 21, 2016 14:10
html: redirect to web page
<!-- Place in between head tag… -->
<meta http-equiv="REFRESH" content="0;url=http://www.the-domain-you-want-to-redirect-to.com">
# Directories #
/build/
/bin/
target/
# OS Files #
.DS_Store
*.class
@w33tmaricich
w33tmaricich / colors.sh
Last active March 21, 2016 14:09
sh: bash color codes and usage
bla='\033[0;30m'
red='\033[0;31m'
gre='\033[0;32m'
yel='\033[0;33m'
blu='\033[0;34m'
mag='\033[0;35m'
cya='\033[0;36m'
whi='\033[0;37m'
nc='\033[0m'
@w33tmaricich
w33tmaricich / linkpath.sh
Last active March 21, 2016 14:09
sh: retrieve file path through simlink
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"