You are not logged in.

#1 2006-06-30 18:55:24

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

random python

I'm truely bored here today... I made this to play with:

import sys, time

class Spinner:
   def __init__(self):
      self.chars = ['/','-','\','|']
      self.bkspace = "%s%s" % (chr(127),chr(127))
      self.current = 0

   def step(self,delay=0):
      print "%s%s" % (self.bkspace,self.chars[self.current]),
      sys.stdout.flush()
      self.current = (self.current + 1) % len(self.chars)
      if delay > 0: time.sleep(delay)

if __name__ == '__main__':
   spin = Spinner()
   try:
      while True: spin.step(0.1)
   except: print ''

Enjoy.

Offline

#2 2006-06-30 19:12:08

kth5
Member
Registered: 2004-04-29
Posts: 657
Website

Re: random python

Same here, totally pissed by the world cup freaks all over the place. smile
So I hacked a bit:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys, os, math, random, stat
sys.path.append('/usr/lib/python2.4/site-packages/libavg')
import avg

Player = avg.Player()

def rotate():
    node = Player.getElementByID("archlogo")
        node.angle += 0.2

Log = avg.Logger.get()
Log.setCategories(Log.APP |
        Log.WARNING |
#        Log.PROFILE |
#        Log.PROFILE_LATEFRAMES |
        Log.CONFIG
        )

Player.loadFile("arch.avg")
Player.setInterval(10, rotate)
Player.play()

full source here and libs here


I recognize that while theory and practice are, in theory, the same, they are, in practice, different. -Mark Mitchell

Offline

#3 2006-06-30 19:14:57

Gullible Jones
Member
Registered: 2004-12-29
Posts: 4,863

Re: random python

Yeah... That's pretty random. lol

Offline

#4 2006-06-30 20:50:13

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: random python

me too, me too!

#!/usr/bin/env python

import sys, time

f = open('/var/log/pacman.log', 'r')
string = f.readlines()
f.close()

doc_len = len(string)
ct = 0
pct = 0
for s in string:
        ct += 1
        current_stat = ((ct + 0.00) / (doc_len + 0.00)) * 100.00
        if current_stat > pct:
                pct += 1
                current_len = len(str(pct)) + 8
        sys.stdout.write('      ' + str(pct) + ' %' + 'b' * current_len)
        sys.stdout.flush()
        # do some stuff here, we'll sleep instead.
        time.sleep(0.1)
print ''

Offline

#5 2006-06-30 21:13:19

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: random python

oh oh! crash vim!

python<<PYEOF
import vim, time, thread
def wtf_kaboom(b):
   while True:
      b.append("hello")
      time.sleep(5)

def go_kaboom():
   thread.start_new_thread(wtf_kaboom,(vim.current.buffer,))
PYEOF

Copy that into vim (you'll need gvim to enable python). And the do

:so %
:python go_kaboom()

It will work fine until you switch buffers... then kaboom.

Actually it's untested on linux, but it dies hard here on Windows.

Offline

#6 2006-06-30 23:15:20

Husio
Member
From: Europe
Registered: 2005-12-04
Posts: 359
Website

Re: random python

Penguin wrote:

me too, me too!

#!/usr/bin/env python

import sys, time

f = open('/var/log/pacman.log', 'r')
string = f.readlines()
f.close()

doc_len = len(string)
ct = 0
pct = 0
for s in string:
        ct += 1
        current_stat = ((ct + 0.00) / (doc_len + 0.00)) * 100.00
        if current_stat > pct:
                pct += 1
                current_len = len(str(pct)) + 8
        sys.stdout.write('      ' + str(pct) + ' %' + 'b' * current_len)
        sys.stdout.flush()
        # do some stuff here, we'll sleep instead.
        time.sleep(0.1)
print ''

that code rox!

Offline

#7 2006-07-01 01:41:49

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: random python

print "Dusty is Brillant"

8)

Dusty[/code]

Offline

#8 2006-07-01 03:17:37

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: random python

Dusty wrote:
print "Dusty is Brillant"

8)

Dusty[/code]

AHAHAH!!!
dusty, tha wouldn't even compile in the forums...lol


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#9 2006-07-01 14:29:02

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Offline

#10 2006-07-01 15:36:21

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,914
Website

Re: random python

Now running an svn server for your /home thats cool


Mr Green

Offline

#11 2006-07-01 16:52:09

deficite
Member
From: Augusta, GA
Registered: 2005-06-02
Posts: 693

Re: random python

#include <cstdio>

int main()
{
    for (;;)
        printf("/b|b\b-b/b|b\b-b");
}

edit: WHY IS IT STRIPPING .h OFF OF STDIO!!!!!! Grr, I edited this thing like three times and it refuses to let met use .h

It must be a C++ nazi. I'm just going to have to go C++ I guess.

Offline

Board footer

Powered by FluxBB