13 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for BustACode

I have been learning NumPy arrays/matrices in Python. As I worked, I found that I desired a more readable form of 3d matrices. So I figured that writing one would be a good goal and learning exercise. The goal was to create a function that would print 3d NumPy matrices …

0
3K
Member Avatar for ddanbe

For a small class it doesn’t matter that much, but for a bigger class I find it handy to have an oversight of all the methods at hand. That’s what I did here. One requirement is that the class file has already been compiled error free. Don’t know if my …

Member Avatar for JOSheaIV
0
419
Member Avatar for Gribouillis

This snippet defines a function `printat()` which adds line and file information to the normal `print()` function output. The intended use is a quick and dirty debugging information for everyday's use. A more complete solution is to use a logging/debugging/tracing framework.

Member Avatar for Gribouillis
5
871
Member Avatar for zegarnek

Hi, I am just playing with C code in the console under Linux. In the old times a fair bit of code was written for a console; programs were operating in text mode, creating menues was quite a fun. I coded very simple c routine to print a strings of …

Member Avatar for N1GHTS
1
3K
Member Avatar for Gribouillis

This snippet prints a python list of strings in multicolumn format (similarly to linux `ls` command). It uses module prettytable, available in [pypi](https://pypi.python.org/pypi/PrettyTable).

Member Avatar for Gribouillis
3
1K
Member Avatar for Assembly Guy

**NOTE** This code won't work at the application level. It directly addresses memory at 0xB8000 which will result in a segfault at the application level. This code must be part of an OS or an application in a not-so-secure operating system like DOS, where applications can directly address any part …

Member Avatar for Assembly Guy
0
450
Member Avatar for tinstaafl

Here's a simple wrapper for printing text. Built as a class library, this can be used in any .net application. This has automatic word wrapping. I figured that using the new constructor to accept different parameters would easily allow for printing different documents with different settings. I included Name, Font, …

1
577
Member Avatar for Reverend Jim

One of the things I have been steadfastly avoiding is writing code to print stuff. Most of what I want to print is from withing apps like Outlook or Word that already provide that functionality. But I finally ended up having to bite the bullet. What I ended up with …

Member Avatar for tinstaafl
2
3K
Member Avatar for metalix

View the full tutorial at [URL="http://www.effectivewebdesign.co.nz/tutorial.php"]http://www.effectivewebdesign.co.nz/tutorial.php[/URL] I have tested this many times and it works fine. Please don't complain unless you really can't get it working, Just PM me and I'll fill in the blanks Happy Coding :)

Member Avatar for Rogueit
0
843
Member Avatar for TrustyTony

Here is my newest version of the pretty printer I posted earlier. Not doing all that fancy stuff of printing looped recursive structures, but if you put one deeper structure inside flat one, works better for me than pprint module. I do not use often object oriented structures though. Dedicated …

0
658
Member Avatar for gpjacks

This is a program which declares two vectors of 6 elements each of type double. One vector is named weight and the other is named rate. The program uses a loop to prompt the user for a weight in ounces and a postage rate for that weight and then stores …

0
239
Member Avatar for TrustyTony
Member Avatar for Gribouillis
1
722
Member Avatar for TrustyTony

Here is my newest baby, the pretty.py module, born today, which I start to use instead of pprint module. Reason to make this (in addition to that it is possible to do) is that I had this problem, sorry long, LONG example: UPDATE: take out the [CODE]or j[/CODE] that was …

Member Avatar for TrustyTony
0
1K

The End.