Skip to content

Instantly share code, notes, and snippets.

View homecoder's full-sized avatar

Michael Ruggiero homecoder

  • Toronto, Canada
View GitHub Profile
@homecoder
homecoder / switch.py
Created February 23, 2018 05:30
Python 'switch' statement.
# -*- coding: utf-8 -*-
"""
Copyright 2018 Michael Ruggiero - This code is released under the MIT License.
Personal Request: If you find this useful, can you reach out to me on GitHub (create an issue, just email me michael AT ruggiero.co) I'd really love to see/hear how it was used.
Of course, it's MIT so you don't have to; just leave the copyright in-tact as per the license.
LICENSE:
Copyright 2018 Michael Ruggiero
@zrzka
zrzka / security.py
Last active June 2, 2021 13:34
iOS Keychain for Pythonista (WIP)
#!python3
from ctypes import c_int, c_void_p, POINTER, byref, c_ulong
from objc_util import (
load_framework, c, ns, ObjCInstance, nsdata_to_bytes, NSString, NSData, NSNumber,
ObjCClass, NSArray, NSDictionary
)
from enum import Enum, IntFlag
from typing import Union
import datetime
@zrzka
zrzka / autolayout.py
Last active January 4, 2018 00:06
Pythonista & auto layout
#!python3
import ui
from objc_util import ObjCInstance, ObjCClass, on_main_thread
from enum import Enum
from functools import partial
from collections import defaultdict
_LayoutConstraint = ObjCClass('NSLayoutConstraint')
@omz
omz / CodeEditor Demo.py
Created July 28, 2015 22:18
CodeEditor Demo.py
# coding: utf-8
'''
NOTE: This requires the latest beta of Pythonista 1.6 (build 160022)
Demo of using Pythonista's own internals to implement an editor view with syntax highlighting (basically the exact same view Pythonista uses itself)
IMPORTANT: This is just for fun -- I was curious if it would work at all, but I don't recommend that you rely on this for anything important. The way Pythonista's internals work can change at any time, and this code is *very* likely to break in the future.
'''
import ui
@omz
omz / PythonistaFTP.py
Last active May 17, 2023 12:43
PythonistaFTP.py
'''FTP server for Pythonista (iOS)
You can use this to exchange files with a Mac/PC or a file management app on the same device (e.g. Transmit).
If you use a Mac, you can connect from the Finder, using the "Go -> Connect to Server..." menu item.
'''
import os
from socket import gethostname
@jsbain
jsbain / gistcheck.py
Last active November 24, 2022 00:18 — forked from davenicholls/gistcheck.py
updated comment: prevent opening of pyui in editor
# Source: https://gist.github.com/5212628
#
# All-purpose gist tool for Pythonista.
#
# When run directly, this script sets up four other scripts that call various
# functions within this file. Each of these sub-scripts are meant for use as
# action menu items. They are:
#
# Set Gist ID.py - Set the gist id that the current file should be
# associated with.
@d-smith
d-smith / KeyUtils.java
Last active October 24, 2019 11:03
Read and write passwords to a Java keystore file
package keystuff;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.security.KeyStore;
public class KeyUtils {
public static FileInputStream getFileInputStreamFromArg(String filePath) throws FileNotFoundException {
@dankrause
dankrause / pngmeta.py
Created December 21, 2012 18:34
A command-line tool that manipulates png meta-data in a very Unix-like way. Requires the Python Imaging Library (PIL).
#!/usr/bin/env python
import json, optparse, sys
try:
import PIL.Image, PIL.PngImagePlugin
except:
print >> sys.stderr, "Unable to import Python Imaging Library. Please ensure that it is installed."
sys.exit(1)