Code Vault

From Sfvlug

(Difference between revisions)
Line 1: Line 1:
-
==Note:==
+
Here is a list of bash script or other short and simple code that has been donated by our members.
-
What is the best way to contribute code? Should it just be placed here or should a seperate page be created?
+
-
Good question, I had intended to leave a lot of that type of decision up to whoever posted something but since this is going to be a community page it might be better to keep it less cluttered so I will suggest making a brief statement here about the code and a link to the page where the actual code lives. The discussion tab [[Talk:Code Vault]] can be used for comments rather than making further clutter here. If you haven't gotten the copyright holder's permission to use the code the link should be to the original source.
+
==Index==
 +
NOTE: Please come in here and separate your code by username. I did this quick, shoot me if I made mistakes.
-
Here are some examples to give everyone a better idea, we can clean this area up later once we get more contributions:
 
-
(Let's say I'm not about the license and don't know if it is OK to reproduce.)
+
==[[user:G4rlic|G4rlic]]==
 +
===[[Mail Scrub]]===
 +
===[[Python File Slicing]]===
-
'''How to contribute code and the organization of this section will be a topic of discussion at the Saturday December 16, 2006 meeting. See [[Meetings]] for more information on the meeting.'''
+
==[[user:JeffCarlson|JeffCarlson]]==
 +
===[[Email Dictionary Attack]]===
-
== [http://www.cs.ucr.edu/~nsoracco/py/mailScrub.html Email List Filter] ==
+
==[[user: Charles Wyble| Charles Wyble]]==
-
This is a python script designed to filter out bad emails from a mailing list.  The script is written as an excuse to learn python.  It's designed to have both offline filtering (via regular expressions) and online filtering that uses MX lookups and SMTP server testing.  Lots of example code in here can be lifted for other apps.
+
===[[Access to HTML]]===
-
 
+
-
== Access Database to HTML ==
+
-
I have written a bash script that converts Access databases to HTML.
+
-
[http://thewybles.com/~charles/me/code/mdb2html.sh.txt Source Code]  
+
-
 
+
-
I know of at least two people in the LUG who were interested in this functionality. Code is GPL.
+
-
 
+
-
== Process Substitution (or, how to do more with less effort) ==
+
-
[[Process Substitution]] is a good way to do things in a single line of script or at the command line, that would otherwise take extra work like writing to temp files.
+
-
 
+
-
== Python File Slicing ==
+
-
[[pyFileSlice]] is a simple utility that will chop out a section of a file that has common starting and ending tags.  Pulling out the page referrers section in an [http://awstats.sf.net Awstats] data file for further analysis prompted this little bit of research.  After trying 3 methods (one involving regex pattern checking over each element in a list, one involving startswith(), and one that uses startswith() and doesn't read the file all at once) the one presented here works the fastest with the least amount of memory used.  [http://www.cs.ucr.edu/~nsoracco/py/fileSlice.html Source Code]
+
-
 
+
-
note: 20061211: alternate method posted for looping through the file.
+
-
 
+
-
== Generate a report on an Email Dictionary Attack ==
+
-
This is just some Bourne shell script I whipped up while trying to learn more about a dictionary attack hitting my mail server.  Messages not delivered to a real user are dropped into /var/spool/mail/bounce in maildir format.  Change the numbers following seq to the start and finish messages desired to check.  I'm just posting this here primarily as a scrapbook, and for educational purposes.
+
-
 
+
-
for A in `seq 137146 200000` ; do
+
-
[ -f ../mail/bounce/$A ] || continue
+
-
formail -x To < ../mail/bounce/$A | awk '{print $NF}' | tr -d \\< | tr -d \\> | tr A-Z a-z
+
-
done | egrep '@example.com$' | sort | uniq -c | less
+
-
 
+
-
Contributed by JeffCarlson.
+
-
 
+
-
==Shell script to enter low power mode on boot==
+
-
A simple little snippet to add to rc.local (or your distribution's equivalent of post-SYSV start up script) that will help conserve power when booting up in battery mode.
+
-
 
+
-
# Haxx to lower power usage when booting up on battery.
+
-
BATSTATE=`cat /proc/acpi/battery/BAT0/state | grep charging | awk -F: '{print $2}'`
+
-
if [ "$BATSTATE" == "discharging" ]; then
+
-
+
-
        # If we get here, we're on battery.
+
-
        # Throttle the CPU
+
-
        echo 4 > /proc/acpi/processor/CPU/throttling
+
-
+
-
        # Go into laptop mode..
+
-
        echo 1 > /proc/sys/vm/laptop_mode
+
-
+
-
        # Remove wireless (and any other unnecessary) driver
+
-
        for i in ipw2100; do
+
-
                rmmod ${i}
+
-
        done
+
-
fi
+
-
 
+
-
Return to [[Main Page]]
+

Revision as of 06:02, 29 January 2007

Here is a list of bash script or other short and simple code that has been donated by our members.

Contents

Index

NOTE: Please come in here and separate your code by username. I did this quick, shoot me if I made mistakes.


G4rlic

Mail Scrub

Python File Slicing

JeffCarlson

Email Dictionary Attack

Charles Wyble

Access to HTML

Personal tools