A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

Re: aa - Stikked
From aa, 9 Years ago, written in Python.
This paste is a reply to aa from aa - go back
Embed
Viewing differences between aa and Re: aa
import os
import glob
import time
 
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
 
base_dir 
pygame, random, sys, math

# You have to call this to make it work.
pygame.init()

# Set up some variables containing the screeen size
sizeX=600
sizeY=600

# Set the starting colour
colour 
'/sys/bus/w1/devices/'
device_folder 
pygame.Color('#009900')

# Create the pygame window
window 
glob.glob(base_dir + '28*')[0]
device_file 
pygame.display.set_mode([sizeX,sizeY])

# Create the clock object
clock 
device_folder + '/w1_slave'
 
def read_temp_raw():
    f = open(device_file, 'r')
    lines = f.readlines()
    f.close()
    return lines
 
def read_temp():
    lines = read_temp_raw()
    while lines[0].strip()[-3:] != 'YES':
        
pygame.time.sleep(0.2)
        lines = read_temp_raw()
    equals_pos = lines[1].find('t=')
    if equals_pos != -1:
        temp_string = lines[1][equals_pos+2:]
        temp_c = float(temp_string) / 1000.0
        temp_f = temp_c * 9.
Clock()

# Put a name on the window.
pygame.display.set_caption("Spirograph")

# Initialise more variables
# k and l are numbers between 
/ 5.0 + 32.0
        return temp_c, temp_f
        
and 1.
# k is the ratio of the distance of the small circle from the big circle
l=random.random()

# l is the ratio of the small circles radius (to the hole with the pen in)
# to the distance from the centre of the large circle.
k=random.random()

# Counter - real number - not integer.
i=0.0

# Scaling factor (Radius of big circle)
R=300

x=0
y=0

# This will loop forever.
while True:
        print(read_temp())        
        time.sleep(5)
    t = math.radians(i)

    newx = R * ((1-k) * math.cos(t) + l*k*math.cos((1-k) * t / k ))
    newy = R * ((1-k) * math.sin(t) - l*k*math.sin((1-k) * t / k ))

    if (x==0 and y==0):
       pass
    else:
       pygame.draw.line(window,colour,(x+R,y+R),(newx+R,newy+R),2)
    x=newx
    y=newy

    i=i+5

    clock.tick(40)
    pygame.display.flip()
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                sys.exit()
sys.exit()