Programming @4-ch

Programming @4-ch

Be it HTML, C++, Java or whatever language you prefer, programming is what we do best around this board.
Markup languages are also fine around here, as with all the "not so real" languages of Shell script, CSS, and other various third party scripting languages.
  • We are sick of language discrimination, more so the PHP/Java bashers. There will be little tolerance of blatant and repetitive insults. You are still welcome to bring forward a sensible, insult-free argument regarding a certain topic at the appropriate time and place for it.
  • Please use WakabaMark or the appropriate HTML tags (with HTML enabled, of course) to format your code.
Rules · 規則
Board look: Blue Moon Buun Futaba Headline Mercury Pseud0ch Toothpaste
1: gaynal sex (1) 2: [perl] Kareha resources (8) 3: >EXPERT HTML PROGRAMMER (4) 4: What is your definition of "freedom" ? (11) 5: HELP (3) 6: Scala thread (4) 7: Live coding tool (5) 8: [Code Help]General code help?[PHP] (12) 9: Is this board alive? (3) 10: Is Perl a dead language? (29) 11: How to make my own imageboard (6) 12: Interpreted vs. compiled labguages (30) 13: world4ch's /prog/ Emergency Shelter #4 (9) 14: This is the official /prog/riders thread (11) 15: Is Ruby as inefficient as they say (6) 16: Coding Challenge #2! (114) 17: Operating Systems vs Artificial Intelligence (3) 18: 6.034 (6) 19: my own "yet another imageboard-script" (106) 20: Best language for starting out in functional programming? (20) 21: [SICP] LEARNING TIME [PY] (4) 22: HAX MY ANUS (2) 23: OOP vs functional (11) 24: Active (6) 25: Introduction to complexity and the idea od quantum computers (3) 26: Opinions of Codecademy? (8) 27: Programming languages with fast matrix operations (15) 28: [JS] Help me find out the correct speed to sync up with the song 太陽いわく燃えよカオス (5) 29: "4tran"? (52) 30: Spoilers in Wakaba (16) 31: Which one? (4) 32: Backup tweets (4) 33: I reproduced an error I found in safari. (3) 34: Google app engine (2) 35: lol (2) 36: Shitpostan (2) 37: What is the diff between RSS and Atom feeds? Is one better? (2) 38: GameBoy Color emulator in JavaScript (11) 39: Excessive file access in a perl script? (10) 40: Common useful applictions of Perl? (10)

gaynal sex (1)

1 Name: #!/usr/bin/anonymous : 2014-08-21 00:04 ID:77in1rtB

gaynal sex

Name: Link:
Leave these fields empty (spam trap):
More options...

[perl] Kareha resources (8)

1 Name: #!/usr/bin/anonymous : 2014-05-02 18:55 ID:IpwbeqOT

We like Kareha here. What have you noticed in kareha? Have you made any hacks or otherwise made use of it?

I saw that Storlek used Kareha as a base for his blog in the past. This seems sane to me, and not all too hard to do. When you think about it, Kareha is (in essence) a community blog.

Entering "fusianasan" in the name field or "2ch-sep93" in's date field do two quite obvious things.

pseud0ch.css, interestingly enough, does not support italics by default.

2 Name: meltingwax!bUNUJnjNcg : 2014-05-03 05:41 ID:XTaTycJ8

Over at I use a hacked verson of Kareha that removes dates and makes the rules section user-editable [1]. It also scrambles the thread identifiers (which are normally the thread creation time) so the age of threads cannot be inferred.

It also has a couple custom CSS stylesheets, mainly 7chan, Overchan, and MWN. Feel free to take the first two for your site, if interested.


3 Name: #!/usr/bin/anonymous : 2014-05-18 21:40 ID:Heaven

is the code for that rule changer thing available anywhere?

also, it seems i've found a bug:

> Traceback (most recent call last):
>  File "index.cgi", line 21, in <module>
>   main()
>  File "index.cgi", line 15, in main
>   do_get()
>  File "/home/meltingwax/", line 60, in do_get
>   """ % raw
> UnicodeEncodeError: 'ascii' codec can't encode character u'\ufffe' in position 869: ordinal not in range(128)

4 Name: #!/usr/bin/anonymous : 2014-05-18 22:00 ID:Heaven

i should probably explain how to reproduce that bug...

  1. go to in your browser.
  2. change the page encoding to utf-8 in your browser
  3. paste a unicode character with a value higher than 127 into the textarea
  4. submit the form
  5. go to again.

5 Name: meltingwax!bUNUJnjNcg : 2014-05-28 02:30 ID:XTaTycJ8

Thanks for reporting that bug. Even when you don't change the page encoding, it doesn't support unicode.

If you want the code to the rules, it's at this link:

To install:

  1. Untar that so you have a folder called $KAREHA_ROOT/rules/.
  2. Then, in $KAREHA_ROOT/include/rules.html, put this where you want the rules to appear:
<div id="rules-to-be-loaded" />
<script type="text/javascript">
$.getJSON('/rules/store.json', function(data) {
Post too long. Click to view the whole post or the thread page.

6 Name: #!/usr/bin/anonymous : 2014-08-15 07:10 ID:NKiVyO92

Kareha with PSGI/Plack support:

Surprised it took this long for someone to do this. Its at least 10x faster than vanilla Kareha when run with starman behind nginx.

7 Name: #!/usr/bin/anonymous : 2014-08-18 23:19 ID:Heaven

So instead of ~2 seconds of cpu time per year, your board uses ~0.2 seconds of cpu time per year?

8 Name: #!/usr/bin/anonymous : 2014-08-20 23:13 ID:mrBSe2Wz

Its bi-annual on some sites. It might even be monthly here.

Name: Link:
Leave these fields empty (spam trap):
More options...


1 Name: >EXPERT HTML PROGRAMMER : 2014-04-21 17:52 ID:lot+OX0a


2 Name: : 2014-05-02 14:42 ID:6E69x8qt

4 Name: #!/usr/bin/anonymous : 2014-08-10 09:32 ID:Fu87NZgk

<?test ><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
<html><?test ><!-- ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="">
<?test --><?test ?>
<?test >
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- ?>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<?test --> <?test ?>
<title>HTML or XML?</title>
Post too long. Click to view the whole post or the thread page.
Name: Link:
Leave these fields empty (spam trap):
More options...

What is your definition of "freedom" ? (11)

1 Name: #!/usr/bin/anonymous : 2014-04-22 10:49 ID:kQlYfQNM


2 Name: #!/usr/bin/anonymous : 2014-04-22 16:03 ID:dHH6Tobi

>Ability to see code.
>Ability to modify code.
>Ability to distribute modifications (fork).

3 Name: #!/usr/bin/anonymous : 2014-04-24 08:09 ID:M8os6tex

Freedom is the freedom to express 2 + 2 = 4. That granted, all else follows!

4 Name: #!/usr/bin/anonymous : 2014-04-25 01:07 ID:muqlh1bG

When I was young, I heard a song and thought to myself that the lyrics were

>Freedom's just another word for nothing left to do

Later, when I was slightly less young, I realized the lyrics actually were

>Freedom's just another word for nothing left to lose

Those definitions aren't especially useful to me, however, since I'm not a blues singer.

5 Name: #!/usr/bin/anonymous : 2014-05-30 09:49 ID:lW3PjXp1

I don't have one

6 Name: #!/usr/bin/anonymous : 2014-06-13 20:54 ID:4tpzojyy

"Freedom" only really has meaning in context. Freedom to do something, freedom not to have something done to you. On it's own it's an empty ideal.

Seeing as this is a programming board, I assume you mean "freedom" in a free software context, in which case my vote for free license goes to the MIT license. Simple and to the point, and not "copyleft" (which IMO is just trading one master for an arguably more benevolent one.)

7 Name: #!/usr/bin/anonymous : 2014-06-20 13:34 ID:Heaven

Your opinion is not appreciated. GPLv3 is the only license. We don't need shitty companies. We need transparency. Freedom as in free. The end.

8 Name: #!/usr/bin/anonymous : 2014-06-20 22:18 ID:4tpzojyy

Hello Stallman.

9 Name: #!/usr/bin/anonymous : 2014-07-02 09:23 ID:5H6su3Ag

But what if I want the freedom to have my work ripped off and exploited for commercial gain by leading companies such as Apple?

10 Name: #!/usr/bin/anonymous : 2014-07-11 13:34 ID:xtFFI2kx

That happens already on their side since they just ignore licences anyway, but if you really want such freedom, just upload your code on the interbutts without a licence.

11 Name: #!/usr/bin/anonymous : 2014-08-07 23:41 ID:muqlh1bG

In some countries, that's rather difficult. Luckily, the WTFPL covers such cases.

Name: Link:
Leave these fields empty (spam trap):
More options...

HELP (3)

1 Name: #!/usr/bin/anonymous : 2014-07-14 19:28 ID:f5AD22xa

Keep open with new servers, send money to my paypal at

Help us fuck Hollywood and the MPAA in the ass!

2 Name: #!/usr/bin/anonymous : 2014-07-24 09:17 ID:Heaven

Begging for donations on 4-ch of all of the places? Pathetic.

3 Name: gorrillaconvention : 2014-08-03 20:59 ID:Heaven

i dont care who says theyre hot or they arent id still put it in all their holes

Name: Link:
Leave these fields empty (spam trap):
More options...

Scala thread (4)

1 Name: #!/usr/bin/anonymous : 2012-02-08 21:38 ID:/YIKnO1d

Hello, Anon. Scala programmer is here. Ask questions.

2 Name: #!/usr/bin/anonymous : 2012-02-10 16:35 ID:Heaven

What's the difference between "null", "Null", "None", and "Nil"?
And why is there any?

3 Name: #!/usr/bin/anonymous : 2014-05-06 01:15 ID:rN/fvWh0

I heard that Scala gives weird backtraces due to the fact that the JVM was built for Java, not a functional language. Any comment on this?

4 Name: #!/usr/bin/anonymous : 2014-06-22 12:04 ID:B2Tt70/Q

Scala gives weird backtraces because like all ML derivatives, the compiler takes extreme liberties with regard to how its output ends up looking. Much like a segfaulting Haskell program is nigh-impossible to debug with a e.g. gdb, which is oriented towards procedurally-structured compiler outputs.

Name: Link:
Leave these fields empty (spam trap):
More options...

Live coding tool (5)

1 Name: #!/usr/bin/anonymous : 2014-04-28 06:26 ID:fjtdgAlQ

Who else likes live coding?

Here is a screenshot of the live coding environment I wrote based on Lua:

In the past, I've embedded Forth (with FICL Forth), Scheme (s7 scheme) and Lisp (using ECL). If you want a Lisp machine, why not make a live coding environment by embedding a Lisp of your choice?

2 Name: #!/usr/bin/anonymous : 2014-04-28 16:58 ID:Fthhyn5j

thats pretty cool

3 Name: #!/usr/bin/anonymous : 2014-04-29 15:34 ID:skLXpcBj

How do you save you're work?

4 Name: #!/usr/bin/anonymous : 2014-04-29 16:11 ID:WTvM5cqX

The buffers are named. Ctrl-S saves the buffer.
Use the setBufferName function to set the name.

The buffers are intended to be used as live REPLs as well as source files. In that way, its similar to a C64.

I haven't directly made it possible to save the state of the world, just the buffers. If you want to save some state, you need to print what you want to save into the buffer.
For example:
print2(inspect(_G)) traverses all variables and tables and inserts their values into the buffer.

I should probably make a video.

5 Name: #!/usr/bin/anonymous : 2014-04-30 22:53 ID:z4vD3Jlv


Name: Link:
Leave these fields empty (spam trap):
More options...

[Code Help]General code help?[PHP] (12)

1 Name: #!/usr/bin/anonymous : 2014-04-16 17:06 ID:tTTThWto

I was running a textboard that has custom software. It has gone down due to reasons beyond my control (got a new router, AT&T won't let me port forward like I was able to do before). Anyways, in the event I can open ports again, I would like to add something to the script. How could I add an Eternal September post date like on DQN? Would I have to play with date()?

3 Name: #!/usr/bin/anonymous : 2014-04-17 06:10 ID:Heaven

php is shit

4 Name: #!/usr/bin/anonymous : 2014-04-19 21:22 ID:Heaven

Ok, thank you >>2
I know, >>3, I can't be botherd to learn anything else.

5 Name: #!/usr/bin/anonymous : 2014-04-19 22:52 ID:Heaven

Everything else is shit. But not quite as shit as php. php is a magnificent example of a shitty programming language. However, despite being a total pile of shit you may still achieve satori while using it. As a architectural genius may realize er abilities when stacking blocks of cow dung. After years of toiling with shit, ey will find bricks and concrete, and ey will wounder why the building blocks don't naturally stick together and emit the familiar odor.

6 Name: #!/usr/bin/anonymous : 2014-04-19 23:48 ID:Heaven

Thank you for that depressing view on languages.

7 Name: #!/usr/bin/anonymous : 2014-04-20 06:44 ID:Heaven

Don't take it too seriously. Everything is shit in the sense that everything is inadequate at expression in one way or another. But what formal language could possibly compare to the extent of a person's imagination? Nothing.

8 Name: #!/usr/bin/anonymous : 2014-04-21 18:59 ID:07R5RuIa

wouldn't you do?
`$date = Date('2003-09-d')
so that todays date (21st) would say 2003-09-21

9 Name: #!/usr/bin/anonymous : 2014-04-21 19:00 ID:07R5RuIa

*without the backtick. thought that would turn the line into monotype like on ascii boards

10 Name: #!/usr/bin/anonymous : 2014-04-25 19:32 ID:x9BsBbjb

Ok, so based on what >>2-san gave me, this is what I came up with:

$days=21*12*30;//21 because it's been 21 years since 1993
$date = date("1993-09-$days);
echo $date;
Would this be correct? Because every time I check I'm off by 18 days.

11 Name: #!/usr/bin/anonymous : 2014-04-26 12:57 ID:VhMy9ojj

Days accumulate. I.e. we're on day 7543 today (september 1993).
You need to match the opening backtick with a closing backtick. On your post form, click More options..., there is an option box for Formatting:. The default is WakabaMark, see docs here
$days is a constant and not a variable! I.e. it does not depend on the actual date. How can it possibly update?
You'd first need to retrieve the current date, for example 26/4/2014.
Then you calculate

#        20 years         3 months     current month
$days = (2013-1993)*365 + 3*30 + 26;

But this is a rough calculation that is not correct. The first problem is that not all months have 30 days, and the second is that not all years have 365 days.

Post too long. Click to view the whole post or the thread page.

12 Name: #!/usr/bin/anonymous : 2014-04-26 22:37 ID:gCTBJ7nM

Thank you! To be honest, I didn't know much about mktime(). But now the function makes sense. Your code works perfectly, thank you. I'm just working on removing everything after the decimal.

Name: Link:
Leave these fields empty (spam trap):
More options...

Is this board alive? (3)

1 Name: #!/usr/bin/anonymous : 2014-04-26 08:40 ID:n6Yf9IpJ

Is it sentient?

2 Name: #!/usr/bin/anonymous : 2014-04-26 15:22 ID:zriFw6ue

Yes [spoiler]no[/spoiler] [spoiler]maybe [/spoiler][spoiler]so[/spoiler]

3 Name: #!/usr/bin/anonymous : 2014-05-04 04:43 ID:Heaven


Name: Link:
Leave these fields empty (spam trap):
More options...

Is Perl a dead language? (29)

1 Name: #!/usr/bin/anonymous : 2009-07-28 17:56 ID:fC7WlNmb

I have been reading on reddit and digg people are claiming Perl is a dead language. I am a heavy Perl coder and I do not see any of this. What do you think?

20 Name: KnowItAll : 2009-12-13 00:11 ID:CrZLGBMm

Perl is a great scripting language for quick little jobs. All the knobs out there that got such a chubby over this and decided to try and write actual applications in the language and take it on as a way of life R stupid.

21 Name: #!/usr/bin/anonymous : 2009-12-16 00:55 ID:Heaven

Perl is like a tool box. Every family should have one in their home. Owning a tool box doesn't automatically make you a mechanic, but it is liberating to know you can fix things that are quick and easy around the house. And the more you learn to use them, the more you are able to fix.

22 Name: Chris : 2012-01-14 05:32 ID:Sn/rrBhI

Perl was sick, but not dead, in 2009.

However - around mid 2011 - yes - it finally died. Nobody is updating or maintainng any of the major (and already-antique) perl resources anymore.

23 Name: #!/usr/bin/anonymous : 2012-01-17 00:02 ID:Heaven


┃┃ _.-. The neutrality of this post is disputed. │
┃┃ /\|/\ Please see the discussion on the talk page. │
┃┃ --|¯¯ Please do not remove this message until the dispute is resolved. │
┃┃ ,_,_ This post does not cite any references or sources. │
┃┃ \ \?\ Please help improve this post by adding citations to reliable │
┃┃ '='=` sources. Unverifiable material may be challenged and removed. │

24 Name: #!/usr/bin/anonymous : 2012-04-25 18:15 ID:dQVhDbTe

you should try perl6/rakudo, seriously

25 Name: #!/usr/bin/anonymous : 2012-06-12 19:09 ID:Heaven

Perl is dead.
Perl6 will not revive Perl.
Perl6 is not a Perl update.
Perl6 is an entirely new language that just happens to be an updated Perl.
New languages are never late, just not yet released.
What I'm trying to say is, Perl is not dead.

Do you understand what I'm saying.

26 Name: #!/usr/bin/anonymous : 2014-04-23 18:31 ID:Qho8HWiq

Perl is the only "big" scripting language in OpenBSD base system. A lot of people still use it for things from quick scripts to full applications. Just a few years ago I was working for a company that managed all DB inventory through Perl and DBI (PostgreSQL and Oracle). I maintained that codebase (something like 20,000 lines of Perl, not counting CPAN modules) and added features as needed, and never ran into the "write once" problem that people often allude to, despite only having met with the original author of that code once. If you simply adopt good practices and write solid code, Perl is a fine choice for many projects. The problem is people who don't know any better run their mouths and others start to believe those lies. But this will come to bite them in the ass, because their favorite language (Python or whatever) will also be subjected to that in time. Anyway, Perl isn't dead any more dead than C. That one also gets a bad rap because of its string handling and buffer overflows, but it's still widely used. Tools that work and are useful will remain...

27 Name: #!/usr/bin/anonymous : 2014-04-26 14:14 ID:u+TFQ6mk

Like >>26 said, OpenBSD uses a lot Perl for everything.
And Perl, is not a dead language, just look the cpan, every day there is a new module.

28 Name: #!/usr/bin/anonymous : 2014-05-04 04:44 ID:Heaven

this thread is almost five years old

29 Name: #!/usr/bin/anonymous : 2014-05-18 22:32 ID:Heaven

and people still insist that perl was dead five years ago, despite the fact that the latest stable release was only 4 months ago and the latest preview release was last month.

Name: Link:
Leave these fields empty (spam trap):
More options...

New thread

Name: Link:
Leave these fields empty (spam trap):
More options...