Skip to content

Instantly share code, notes, and snippets.

View tdamdouni's full-sized avatar

Taha Dhiaeddine Amdouni tdamdouni

View GitHub Profile
@controversial
controversial / ProgressBadge.py
Last active July 19, 2022 19:31
ProgressBadge.py
from objc_util import *
import time
import notification
APP=UIApplication.sharedApplication()
DISPLAYMODE=0
def setBadge(text):
APP.setApplicationBadgeString_(text)
@omz
omz / Add Web Tab.py
Last active April 15, 2025 01:31 — forked from steventroughtonsmith/Add Web Tab.py
Insert a custom browser tab into Pythonista
# coding: utf-8
from objc_util import *
import console
import urllib
import dialogs
WKWebView = ObjCClass('WKWebView')
UIViewController = ObjCClass('UIViewController')
UIBarButtonItem = ObjCClass('UIBarButtonItem')
NSURLRequest = ObjCClass('NSURLRequest')
@steventroughtonsmith
steventroughtonsmith / Add Web Tab.py
Created January 13, 2016 22:55
Insert a custom browser tab into Pythonista
# coding: utf-8
from Foundation import *
from QuartzCore import *
from UIKit import *
import console
WKWebView = ObjCClass('WKWebView')
@on_main_thread
@philgruneich
philgruneich / OCRtoInteract.py
Last active March 17, 2020 00:28
Requires Pythonista for iOS and Interact for iOS. Sends image and returns OCR'd text. Opens text in Interact unless used from action extension, then adds to clipboard.
# coding: utf-8
import requests
import photos
from PIL import Image, ImageEnhance
import StringIO
import appex
import console
import json
import keychain
# EDIT: this has now been upgraded to a full-fledged repo and is accepting PRs. This gist is no longer updating.
# go here: https://github.com/paultopia/spideyscrape
# This is a very basic scraper-spider for those html books where there's a table of contents page that links to a
# bunch of sub-pages with actual content (like the documentation for a bunch of libraries).
#
# Dependencies: Beautiful soup 4 on Python 2.7.
#
# It assumes all content is vanilla html or at least can be accessed through vanilla html.
#
# OBSOLETE.
# GO HERE INSTEAD: https://github.com/paultopia/spideyscrape
# very basic scraper-spider for those html books where there's a table of contents page that links to a
# bunch of sub-pages with actual content. (Like the documentation for a bunch of libraries.)
# WARNING: has no validation, assumes pages contain relative links and are all on the same site.
# (this is an easy tweak but I don't have time today)
# also assumes all content is vanilla html or at least can be accessed through vanilla html.
#
# pass ToC page through raw_input. This script scrapes every unique page linked from ToC and
@gbaman
gbaman / HowToOTG.md
Last active March 26, 2025 10:11
Simple guide for setting up OTG modes on the Raspberry Pi Zero

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int

@Phuket2
Phuket2 / tmpPfL16j.py
Created December 20, 2015 07:47
tmpPfL16j.py
f_str = [
{
"selected" : False,
"frame" : "{{0, 0}, {320, 480}}",
"class" : "View",
"nodes" : [
{
"selected" : False,
"frame" : "{{0, 233}, {320, 32}}",
"class" : "Label",
@alessaba
alessaba / JailbreakTest.py
Last active December 24, 2015 12:11
JailbreakTest.py
# coding: utf-8
import os
def is_device_jailbroken():
try:
os.listdir('/private')
except OSError:
return False
return True
@Phuket2
Phuket2 / SlidePanelClass.py
Created December 19, 2015 16:21
SlidePanelClass.py
# coding: utf-8
'''
code copied from dialogs.py Pythonista 1.6 beta, @omz (Ole Zorn)
specially the parts of the code that present a datepicker
in a dialog with animation and a shield of the dialogs contents
a few mods made
'''
_country_list = ['Afghanistan', 'Albania', 'Algeria', 'American Samoa', 'Andorra', 'Angola', 'Anguilla', 'Antarctica', 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Aruba', 'Australia', 'Austria', 'Azerbaijan', 'Bahamas', 'Bahrain', 'Bangladesh', 'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bermuda', 'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana', 'Brazil', 'Brunei Darussalam', 'Bulgaria', 'Burkina Faso', 'Burundi', 'Cambodia', 'Cameroon', 'Canada', 'Cape Verde', 'Cayman Islands', 'Central African Republic', 'Chad', 'Chile', 'China', 'Christmas Island', 'Cocos (Keeling) Islands', 'Colombia', 'Comoros', 'Democratic Republic of the Congo (Kinshasa)', 'Congo, Republic of (Brazzaville)', 'Cook Islands', 'Costa Rica', 'Ivory Coast', 'Croatia', 'Cuba', '