Skip to content

Instantly share code, notes, and snippets.

Al Sweigart asweigart

Block or report user

Report or block asweigart

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:2341ac7b8612584958cff8d6380ce114
import sys
class Calculation:
def __init__(self, numbersFromTheUser): # THIS METHOD IS RUN WHEN WE CALL Calculation()
self.theNumbers = numbersFromTheUser
# WE SAVE numbersFromTheUser IN self.theNumbers
# THE OTHER METHODS IN Calculation WILL USE self.theNumbers
#Define a function that determines number of arguments
def number(self):
View gist:b1402b78166ba6638983dc18e0685ba8
pixels = []
i = 0
while i < WIDTH * HEIGHT:
i += 1
View gist:df34bf308bc2aa6887e13960a05a87f3
pixels = []
i = 0
while i < WIDTH * HEIGHT:
i += 1
View gist:35565d34eb9a5e9d333ac393155691a7'g(%25s%29%20start'%20%25%20(N%29%29%0A%09if%20N%20%3D%3D%201%3A%0A%09%09%23logging.debug('g(1%29%20returns%201'%29%0A%09%09return%201%20%23%20this%20is%20just%20the%20chain%20%7B1%7D%0A%0A%09totalNumberOfChains%20%3D%200%0A%09midpointOfN%20%3D%20N%20//%202%0A%09for%20i%20in%20range(midpointOfN,%200,%20-1%29%3A%0A%09%09if%20N%20%25%20i%20!%3D%200%3A%0A%09%09%09%23logging.debug('i%20of%20%25s%20skipped'%20%25%20(i%29%29%0A%09%09%09continue%0A%0A%09%09%23logging.debug('calling%20g(i%29%20where%20i%20is%20%25s'%20%25%20(i%29%29%0A%09%09totalNumberOfChains%20%2B%3D%20g(i%29%0A%0A%09%23logging.debug('g(%25s%29%20returns%20%25s'%20%25%20(N,%20totalNumberOfChains%29%29%0A%09return%20totalNumberOfChains%0A%0Aprint(g(12%29%29&cumulative=false&curInstr=10&heapPrimitives
View gist:85a47cffb4dd0f17d461
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
View gist:4dd0c869cc7053a60dce
Class Notes Duex
Talk about automation, factories and robots. Mention factories with the lights turned off.
Go over the basic functions of PyAutoGUI. Consult the handout.
I've now taught you enough to write programs that can automatically sign up for email accounts and start sending out spam. (No, that's what Captchas are for.)
Point out the documentation online.
View gist:54a4bfad586906059e0b
import time
import struct
import Quartz.CoreGraphics as CG
class ScreenPixel(object):
"""Captures the screen using CoreGraphics, and provides access to
the pixel values.
View gist:6912168
Hello, world! and make it easy to share large amounts of text with people over the web.
You can’t perform that action at this time.