Skip to content

Instantly share code, notes, and snippets.

@saltlakeryan
saltlakeryan / timestamp.py
Created September 30, 2015 16:53
Print out a string of characters that represents the current time
import time
timestr = time.strftime("%Y%m%d-%H%M%S")
print timestr
@saltlakeryan
saltlakeryan / find_tifs.py
Last active September 30, 2015 17:16
Walk through all subdirectories and print the filenames that are tif files
import os
for root, dirs, files in os.walk("."):
for file in files:
if file.endswith(".tif") or file.endswith(".TIF"):
print(os.path.join(root, file))
import img2pdf
pdf_bytes = img2pdf.convert(['test.jpg'])
file = open("name.pdf","wb")
file.write(pdf_bytes)
import Tkinter
from tkFileDialog import askopenfilename, askdirectory
class simpleapp_tk(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.parent = parent
self.initialize()
def initialize(self):
subst h: c:\Users\bla\blabla
https://www.python.org/ftp/python/2.7.10/python-2.7.10.amd64.msi
msiexec /a python-2.7.10.amd64.msi /qb TARGETDIR=H:\python27
H:
cd python27
@saltlakeryan
saltlakeryan / example_formidable_query.php
Created September 15, 2015 21:02
pull csv from formidable forms with php
<?php
function get_form_entries($baseurl, $username, $password, $uid, $formid) {
$headerfile = tempnam("/tmp", "formidable-header");
$cookiefile = tempnam("/tmp", "formidable-cookie");
$csvfile = tempnam("/tmp", "formidable-csv");
$login_cmd = "curl -s -D $headerfile -c $cookiefile 'http://$baseurl/wp-login.php' --data 'log=$username&pwd=$password&testcookie=1' -H 'Cookie: wp-settings-time-$uid=2829600000; wordpress_test_cookie=WP+Cookie+check' 2> /dev/null";
$pull_csv_cmd = "curl -s -D $headerfile -b $cookiefile -o $csvfile -c $cookiefile 'http://$baseurl/wp-admin/admin-ajax.php?frm_action=0&action=frm_entries_csv&form=$formid'";
exec($login_cmd, $output, $status);
if ($status != 0) {
throw new Exception("Can't login");
@saltlakeryan
saltlakeryan / autorun
Last active February 27, 2024 23:22
autorun file for system rescue cd
#!/bin/bash
set -e
set -o pipefail
function main() {
setup_env
print_welcome
mount_dir
back_up | tee -a $BACKUPDIR/backup.log
DisplayInfo()
Related URLs:
• Postman—http://getpostman.com
• Hurl.it—http://hurl.it
• Runscope—http://runscope.com
• HTTPie—http://httpie.org
• Charles Proxy—http://charlesproxy.com
• mitmproxy—http://mitmproxy.org
• API Tools—http://apitools.com
• Requestb.in—http://requestb.in
#Examples: pyhook_demo.py
import pythoncom, pyHook
def OnKeyboardEvent(event):
print 'MessageName:',event.MessageName
print 'Message:',event.Message
print 'Time:',event.Time
print 'Window:',event.Window
print 'WindowName:',event.WindowName
print 'Ascii:', event.Ascii, chr(event.Ascii)
@saltlakeryan
saltlakeryan / fullscreenwindow.py
Created May 5, 2015 17:31
Example of creating a full screen window in python for win32 (using wxwidgets):
import wx
class OverlayFrame( wx.Frame ) :
def __init__( self ) :
wx.Frame.__init__( self, None, title="Transparent Window",
style=wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP )
self.ShowFullScreen( True )