Jump to content
IGNORED

Post your favorite code snippet


acidphakist

Recommended Posts

#!/usr/bin/python

 

import wx

import os

 

 

class CustomApp(wx.App):

def __init__(self):

wx.App.__init__(self)

self.value = None

 

def SetValue(self, value):

self.value = value

 

def GetValue(self):

return(self.value)

 

class SearchObject:

def __init__(self):

self.tags = {}

self.fileHandle = ''

 

def SetTags(self,tagDict):

self.tags = tagDict

 

def SetFileHandle(self,fileHandle):

self.fileHandle = fileHandle

 

class PrintWindow(wx.Frame):

def __init__(self,filterFixObjects,filterFixLines):

self.filterFixObjects = filterFixObjects

self.filterFixLines = filterFixLines

wx.Frame.__init__(self,None,wx.ID_ANY, 'Order Search Results')

for line in self.filterFixLines:

print line

 

class MainWindow(wx.Frame):

def __init__(self,app):

self.app = app

wx.Frame.__init__(self,None,wx.ID_ANY, 'Order Search')

self.panel = wx.Panel(self, wx.ID_ANY)

title = wx.StaticText(self.panel,wx.ID_ANY)

 

self.dirname = ''

self.searchobject = SearchObject()

 

filemenu= wx.Menu()

menuOpen = filemenu.Append(wx.ID_OPEN, "&Open","Open a file to edit")

self.Bind(wx.EVT_MENU, self.OnOpen, menuOpen)

menuBar = wx.MenuBar()

menuBar.Append(filemenu,"&Pick your fix logfile")

self.SetMenuBar(menuBar)

 

topSizer = wx.BoxSizer(wx.VERTICAL)

bagSizer = wx.GridBagSizer(hgap=5, vgap=5)

Link to comment
Share on other sites

Sorry...it's python (obviously) and it's currently my favorite because I'm learning GUI development using wxPython.

 

I won't bother to bore you with what it does seeing as this part is rather vanilla window setup.

Link to comment
Share on other sites

Sorry...it's python (obviously) and it's currently my favorite because I'm learning GUI development using wxPython.

 

I won't bother to bore you with what it does seeing as this part is rather vanilla window setup.

 

Well, I don't think programming is boring - I'm not a Python coder myself, but I did read through it a bit after you posted it and gathered it was creating some sort of window... Python is one of those languages that always surprises how versatile it is. A free IDE I use, Editra, is written in Python...

Link to comment
Share on other sites

ssh -D 9999 -f -C -q -N you@yourserver.com

echo I put on my socks.

 

sets up a socks proxy over ssh which you can connect to on your localhost at port 9999. much simpler than setting up a vpn when you just want to do some encrypted surfing over public wifi, although you have to be careful to make sure your browser also tunnels the dns requests.

Link to comment
Share on other sites

Guest hahathhat

i also love this one:

 

(name this file fork.sh)

 

#!/bin/sh

 

./fork.sh

./fork.sh

 

i've drunkenly used it on people's iMacs. so nice of them to switch to unix. but it seems to have stopped tanking the system over the last few years... they walled it off a bit better... foo.

Link to comment
Share on other sites

Guest Babar

what does it do ?

 

 

 

Nothing better than inform7. It's so transparent (and it's used to build textual games for those who don't know).

Holly Hop Drive is a woman in the fun room.

holly hop drive is wearing a cardigan and trousers and a poppy.

 

Understand "rape [someone]" as raping.

Understand "fuck [someone]" as raping.

 

raping is an action applying to one thing.

 

Instead of examining holly:

....say "She is wearing [a list of things worn by the noun]."

 

Instead of taking something which is worn by the holly:

....say "Holly violently shoves your away, Hey the [noun] is mine! Fucker!"

 

Instead of kissing holly:

....say "She punches you square on the Jaw, then spits at your feet. Feisty!"

 

Instead of searching holly:

....say "She screams Get your hand out of my pockets!!, and pushes you back."

 

Instead of raping holly:

....say "She wrestles you to the ground, and overpowers you, which is freaking embarrassing. What's worse, is that she's wearing a strap-on, and has her way with you.". ;

....end the game saying "You were raped by a chick. You may as well klerck right now."

 

 

also, i have a little problem : sometimes my neighbour, who uses our wifi network, downloads stuffs via bittorrent. As a result i get a ~1sec ping which is very annoying (most probably because he uploads more than what is allowed by our ISP (~128kb/s). Consequently, i launch a man in the middle kind of attack, so that i can monitor his traffic. As i'm using a mac, I use ipfw (and thus dummynet) in order to 'reshape' his traffic.

Usually, i just create a pipe meant for packets i receive from him before redirecting them. I configure my pipe to have a 20kb/s bandwidth, and it usually works (my ping becomes normal again, around 60-80ms).

Now what i'd like to do is something more supple : allowing him to do whatever the fuck he wants, but just give a stronger priority to my own packets. I tried:

-creating a pipe with no bandwith limit, meant for "any to any" packets.

-adding a queue to this pipe for packets coming from my neighbour's ip (with a weight of 1)

-adding a queue to this pipe for other packets (including mine) (with a weight of 99).

But… it doesn't work that well. My ping is still fucking high. Should i add a delay or a 'packet-dropping' factor ?

Anyone ?

Link to comment
Share on other sites

what does it do ?

 

 

 

Nothing better than inform7. It's so transparent (and it's used to build textual games for those who don't know).

Holly Hop Drive is a woman in the fun room.

holly hop drive is wearing a cardigan and trousers and a poppy.

 

Understand "rape [someone]" as raping.

Understand "fuck [someone]" as raping.

 

raping is an action applying to one thing.

 

Instead of examining holly:

....say "She is wearing [a list of things worn by the noun]."

 

Instead of taking something which is worn by the holly:

....say "Holly violently shoves your away, Hey the [noun] is mine! Fucker!"

 

Instead of kissing holly:

....say "She punches you square on the Jaw, then spits at your feet. Feisty!"

 

Instead of searching holly:

....say "She screams Get your hand out of my pockets!!, and pushes you back."

 

Instead of raping holly:

....say "She wrestles you to the ground, and overpowers you, which is freaking embarrassing. What's worse, is that she's wearing a strap-on, and has her way with you.". ;

....end the game saying "You were raped by a chick. You may as well klerck right now."

 

 

also, i have a little problem : sometimes my neighbour, who uses our wifi network, downloads stuffs via bittorrent. As a result i get a ~1sec ping which is very annoying (most probably because he uploads more than what is allowed by our ISP (~128kb/s). Consequently, i launch a man in the middle kind of attack, so that i can monitor his traffic. As i'm using a mac, I use ipfw (and thus dummynet) in order to 'reshape' his traffic.

Usually, i just create a pipe meant for packets i receive from him before redirecting them. I configure my pipe to have a 20kb/s bandwidth, and it usually works (my ping becomes normal again, around 60-80ms).

Now what i'd like to do is something more supple : allowing him to do whatever the fuck he wants, but just give a stronger priority to my own packets. I tried:

-creating a pipe with no bandwith limit, meant for "any to any" packets.

-adding a queue to this pipe for packets coming from my neighbour's ip (with a weight of 1)

-adding a queue to this pipe for other packets (including mine) (with a weight of 99).

But… it doesn't work that well. My ping is still fucking high. Should i add a delay or a 'packet-dropping' factor ?

Anyone ?

 

 

I don't know of any *nix software that allows for this kind of shaping. You'd likely require a dedicated router that can handle these types of policies.

 

Also, where are these queues being implemented? The very fact you are using them could explain the latency incurred,

Link to comment
Share on other sites

Guest Babar

As far as I understand, a queue is used to subdivide a pipe. For example, you set up a pipe for any packets with a maximal bandwidth of 1Mb/s.

Then you add a queue for john's packets with a a weight of 10

and a queue for you own packets with a weight of 90.

If you're both sending at 1Mb/s, you'll be ensured that john's packets are not being sended at more than 100kb/s.

But i'm using these feature in a blind way. I don't know what happens to packets that are "paused/frozen" by the pipe/queue mechanism. Are they delayed ? Or dropped ?

Also : I measured my ping before to start adding pipes and queues, so i'm fairly certain it is not caused by my own shady activities. According to a technician that works at my ISP, my router's cache gets clogged up, because it refuses to send at more than 128kb/s.

Link to comment
Share on other sites

what does it do ?

 

It builds a list containing the Fibonacci sequence. The amazing thing is that it is a recursive definition, yet it all works out because of the lazy evaluation Haskell has.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.