Skip to content

Instantly share code, notes, and snippets.

View maxshaw's full-sized avatar

Max Shaw maxshaw

View GitHub Profile
@CatTail
CatTail / proto.js
Last active February 1, 2024 15:59
Javascript prototype in a nutshell
var assert = require('assert')
var util = require('util')
function test (inherits) {
function Fruit () {
}
Fruit.prototype.round = false
Fruit.prototype.sweet = true
Fruit.prototype.eat = function () {}
@blmacbeth
blmacbeth / ProgressView.py
Created September 19, 2015 20:08
ProgressView.py
# coding: utf-8
from objc_util import *
## this is bad python styling, but I justify it by saying the
## function is an alias for the UIColor class
def UIColor(red=1.0, green=1.0, blue=1.0, alpha=1.0):
UIColor = ObjCClass('UIColor')
r = CGFloat(red)
g = CGFloat(green)
@omz
omz / touchid.py
Last active November 15, 2023 23:35 — forked from alessaba/TouchID.py
TouchID.py
# coding: utf-8
from objc_util import *
import threading
NSBundle = ObjCClass('NSBundle')
LocalAuthentication = NSBundle.bundleWithPath_('/System/Library/Frameworks/LocalAuthentication.framework')
LocalAuthentication.load()
LAContext = ObjCClass('LAContext')
# authenticate() will raise one of these exceptions when authentication
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
public class Config {
@Bean
@omz
omz / PythonistaBackup.py
Last active January 6, 2024 05:44
PythonistaBackup.py
# coding: utf-8
'''Creates a zip archive of your Pythonista files and serves them via HTTP in your local network.'''
import sys
if sys.version_info[0] >= 3:
from http.server import SimpleHTTPRequestHandler, HTTPServer
else:
from SimpleHTTPServer import SimpleHTTPRequestHandler
from BaseHTTPServer import HTTPServer
@jsbain
jsbain / TabbedView.py
Last active January 26, 2018 13:37
TabbedView.py
import ui
class TabbedView(ui.View):
def __init__(self,tablist=[], frame=(0,0)+ui.get_screen_size()):
'''takes an iterable of Views, using the view name as the tab selector.
empty views sre just given generic names'''
self.tabcounter=0 #unique counter, for name disambiguation
self.buttonheight=30 #height of buttonbar
#setup button bar
self.tabbuttons=ui.SegmentedControl(frame=(0,0,self.width, self.buttonheight))
self.tabbuttons.action=self.tab_action
@omz
omz / FontInstaller.py
Last active August 8, 2023 14:43
FontInstaller
# FontInstaller (by @olemoritz)
# This script installs a custom TTF font on iOS (system-wide).
# It can be used in one of two ways:
# 1. Simply run it in Pythonista, you'll be prompted for the URL of the font
# you'd like to install (if there's a URL in the clipboard, it'll be used by default)
# 2. Use it as an 'Open in...' handler, i.e. select this file in Pythonista's 'Open in...
# menu' setting. This way, you can simply download a ttf file in Safari and open it in
@pudquick
pudquick / shellista.py
Last active November 12, 2022 16:56
Advanced shell for Pythonista
import os, cmd, sys, re, glob, os.path, shutil, zipfile, tarfile, gzip
# Credits
#
# The python code here was written by pudquick@github
#
# License
#
# This code is released under a standard MIT license.
#
@pudquick
pudquick / pipista.py
Created November 20, 2012 07:23
pipista - pip module (for installing other modules) for Pythonista
import os, os.path, sys, urllib2, requests
class PyPiError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
def _chunk_report(bytes_so_far, chunk_size, total_size):
if (total_size != None):