Jump to content

Code Warrior

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

About Code Warrior

  • Birthday 09/25/1965

Profile Information

  • Gender
    Male

Code Warrior's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Note: IBM sold it keyboard division to Lexmark which split off to a company named Unicomp. Still in business. Still making a quieter version of the Model M in USB or PS2 version. I may have to snag one to see for myself. TTFN, CW
  2. I'd seen this keyboard before, and never seriously considered it. But on the website, they compare it to the "legendary IBM model M" - a legendary keyboard? I did a bit of research on the model M, and found an actual cult following. (Not something common with keyboards.) There's even a website dedicated to the sale of these keyboards. And as luck would have it, I had a model M in a pile of broken computer stuff at home (I think I need to throw some stuff out), and after trying it for a few seconds, I was sold. Smooth keypresses and the curvature of the board make for an awesome experience - I highly recommend it to everybody. Unfortunately, the model M has been discontinued, and a model M in good shape can easily fetch 50 USD on ebay. (These keyboards are from the late 1980's and early 1990s. That's saying something.) I hear that universities throw these babies out left and right, so I'm going to head down to the university and see if I can't find one (or a dozen) in the garbage pile of the computer science building. If not, I think I'll spend the $50 on eBay. I'll have to chime up on this one. The model M *is* the keyboard to own if you could ever own only one keyboard. It's heft is enough to be lethal if used as weapon, this click is loud enough to wait gofers in the next cubicle, it's lacking those pesky windows buttons tuckd between the ctrl and alt buttons, has a ps/2 connector, etc. etc. I've own several of these over these over the years and absolutely love them. Wish I could get my hands on another. It truely is a man's keyboard. My second pick would be the MCK142. Don't be fooled by it being advertised as a CAD/CAM keyboard, I've used it from programming to MMORPGing! It's easy to program (tap a few keys, type, tap a key). The model I had the same click as the IBM Model M, weighed about half as much as one, and used a couple AAA batteries to keep the programmable keys in memory. YMMV, CW
  3. That was part of my optimization. ... // skip ahead to next ^ $j = strpos($strin, '^', $i); if ($j === FALSE) { // no more. out the rest. $out .= substr($strin, $i); $i = strlen($strin); } else { $out .= substr($strin, $i, $j - $i); $i = $j - 1; } ... Cheers, CW
  4. Thanks everyone, I got it slimmed down quite abit running alot faster now.
  5. Exactly. I used to run a 4 node BBS back in the early 90's and wrote alot of door programs and utilities. I'll try to get this mess tweaked using regex as much as possible but parsing with it can be tricky as what is being interpreted depends greatly upon what appeared before it. I also have a working ANSI screen to HTML function that needs the same treatment so I have my work cut out for me. I wish I had the luxury of writting the whole thing in C but alot of hosts frown upon rogue binaries. Cheerio, CW
  6. Hello, first time poster. I'm an old time programmer deciding to get back into the swing of things by writting my own bbs in php backended with mysql on apache. I'm not entirely pleased with the way standard BB codes work and was working out my own technique for doing this on my board. It looks good sofar on the browsers I have here but maybe I could get some bashing around by you all to optimize / clean it up a bit. <?php function str_textcodes($strin) { // dos colors to html colors $d2h_colors = array( '#000','#a00','#0a0','#a50','#00a','#a0a','#0aa','#aaa', '#555','#f55','#5f5','#ff5','#55f','#f5f','#5ff','#fff' ); // font sizes 0-6 $fontsizes = array( 'xx-small','x-small','small','medium','large','x-large','xx-large' ); // attribute flags... $at_italics = FALSE; // italics $at_bold = FALSE; // bold $at_underline = FALSE; // underline $at_through = FALSE; // strike through $at_overline = FALSE; // over line $at_blink = FALSE; // blink $at_supers = FALSE; // superscript $at_subs = FALSE; // subscript $at_font = 0; $at_fontchange = FALSE; $at_fcolor = "black"; $at_bcolor = "white"; $at_fcolorchange = FALSE; $at_bcolorchange = FALSE; $at_fontsize = 3; // default size $at_fontsizechange = FALSE; $at_paragraph = FALSE; $at_change = FALSE; $at_changecnt = 0; $out = ""; for ($i = 0; $i < strlen($strin); $i++) { if ($strin[$i] == '^') { // gather up codes until non-code encountered. $i++; switch ($strin[$i]) { case '0': $at_italics = $at_bold = $at_underline = $at_through = $at_overline = $at_blink = $at_propfont = $at_monofont = $at_supers = $at_subs = FALSE; $at_fcolor = "black"; $at_bcolor = "white"; $at_fontsize = 3; $at_fontchange = FALSE; $at_fcolorchange = FALSE; $at_bcolorchange = FALSE; $at_change = FALSE; for (; $at_changecnt > 0; $at_changecnt--) $out .= "</span>"; break; case 'i': $at_italics = TRUE; $at_change = TRUE; break; case 'e': $at_bold = TRUE; $at_change = TRUE; break; case 'u': $at_underline = TRUE; $at_change = TRUE; break; case 't': $at_through = TRUE; $at_change = TRUE; break; case 'o': $at_overline = TRUE; $at_change = TRUE; break; case 'x': $at_blink = TRUE; $at_change = TRUE; break; case 'f': $at_fontchange = TRUE; $at_change = TRUE; $i++; switch ($strin[$i]) { case 'p': $at_font = 1; break; case 'm': $at_font = 2; break; case 'c': $at_font = 3; break; case 'f': $at_font = 4; break; case 's': $at_font = 5; break; default: break; } break; case '~': $at_supers = TRUE; $at_change = TRUE; break; case '_': $at_subs = TRUE; $at_change = TRUE; break; case 'r': $x = $at_fcolor; $at_fcolor = $at_bcolor; $at_bcolor = $x; $at_change = TRUE; $at_fcolorchange = TRUE; $at_bcolorchange = TRUE; break; case 'c': $i++; $at_fcolor = $d2h_colors[hexdec($strin[$i])]; $at_fcolorchange = TRUE; $at_change = TRUE; break; case 'b': $i++; $at_bcolor = $d2h_colors[hexdec($strin[$i])]; $at_bcolorchange = TRUE; $at_change = TRUE; break; case 'C': $i++; $at_fcolor = '#'.strtoupper(substr($strin, $i, 6)); $i += 5; $at_fcolorchange = TRUE; $at_change = TRUE; break; case 'B': $i++; $at_bcolor = '#'.strtoupper(substr($strin, $i, 6)); $i += 5; $at_bcolorchange = TRUE; $at_change = TRUE; break; case 's': $i++; $s = $strin[$i]; if (($s >= '0') && ($s <= '6')) $at_fontsize = intval($s); else $at_fontsize = 3; $at_fontsizechange = TRUE; $at_change = TRUE; break; case 'p': if ($at_paragraph) $out .= '</P>'; $at_paragraph = TRUE; $out .= '<P>'; break; case 'P': if ($at_paragraph) $out .= '</P>'; $at_paragraph = TRUE; $i++; switch ($strin[$i]) { case 'l': $out .= "<P style='text-align: left;'>"; break; case 'r': $out .= "<P style='text-align: right;'>"; break; case 'j': $out .= "<P style='text-align: justify;'>"; break; case 'c': $out .= "<P style='text-align: center;'>"; break; case 'L': $out .= "<P style='text-align: left; text-indent: 32px;'>"; break; case 'R': $out .= "<P style='text-align: right; text-indent: 32px;'>"; break; case 'J': $out .= "<P style='text-align: justify; text-indent: 32px;'>"; break; case 'C': $out .= "<P style='text-align: center; text-indent: 32px;'>"; break; case 'i': $out .= "<P style='text-align: left; padding-left: 32px;'>"; break; default: $out .= "<P>"; $i--; break; } break; case 'n': $out .= "<br>"; break; case 'g': if ($at_change) { $r = "<span style='"; if ($at_italics) $r .= "font-style: italic; "; if ($at_bold) $r .= "font-weight: bold; "; if ($at_supers || $at_subs) { if ($at_supers) $r .= "vertical-align: top; font-size: 50%; "; else $r .= "vertical-align: bottom; font-size: 50%; "; } if ($at_underline || $at_through || $at_overline || $at_blink) { $r .= "text-decoration: "; if ($at_underline) $r .= "underline "; if ($at_through) $r .= "line-through "; if ($at_overline) $r .= "overline "; if ($at_blink) $r .= "blink "; $r .= "; "; } if ($at_fontchange) { switch ($at_font) { case 1: $r .= "font-family: serif; white-space: normal; "; break; case 2: $r .= "font-family: monospace; white-space: normal; "; break; case 3: $r .= "font-family: monospace; white-space: pre; "; break; case 4: $r .= "font-family: fantasy; white-space: normal; "; break; case 5: $r .= "font-family: cursive; white-space: normal; "; break; default: break; } } if ($at_fontsizechange) $r .= "font-size: ".$fontsizes[$at_fontsize]."; "; if ($at_fcolorchange && ($at_fcolor !== "")) $r .= "color: ".$at_fcolor."; "; if ($at_bcolorchange && ($at_bcolor !== "")) $r .= "background-color: ".$at_bcolor."; "; $r .= "'>"; $out .= $r; $at_change = FALSE; $at_fcolorchange = FALSE; $at_bcolorchange = FALSE; $at_fontsizechange = FALSE; $at_fontchange = FALSE; $at_changecnt++; } $i++; switch ($strin[$i]) { case '0': $out .= '&#x2591;'; break; case '1': $out .= '&#x2592;'; break; case '2': $out .= '&#x2593;'; break; case '3': $out .= '&#x2588;'; break; case 't': $out .= '&#x2580;'; break; case 'b': $out .= '&#x2584;'; break; case 'l': $out .= '&#x258c;'; break; case 'r': $out .= '&#x2590;'; break; case 'q': $out .= '&#x250c;'; break; case 'w': $out .= '&#x252c;'; break; case 'e': $out .= '&#x2510;'; break; case 'a': $out .= '&#x251c;'; break; case 's': $out .= '&#x253c;'; break; case 'd': $out .= '&#x2524;'; break; case 'z': $out .= '&#x2514;'; break; case 'x': $out .= '&#x2534;'; break; case 'c': $out .= '&#x2518;'; break; case 'v': $out .= '&#x2502;'; break; case 'h': $out .= '&#x2500;'; break; default: $out .= ' '; $i--; break; } break; case '^': $out .= '^'; break; default: break; } } else { if ($at_change) { $r = "<span style='"; if ($at_italics) $r .= "font-style: italic; "; if ($at_bold) $r .= "font-weight: bold; "; if ($at_supers || $at_subs) { if ($at_supers) $r .= "vertical-align: top; font-size: 50%; "; else $r .= "vertical-align: bottom; font-size: 50%; "; } if ($at_underline || $at_through || $at_overline || $at_blink) { $r .= "text-decoration: "; if ($at_underline) $r .= "underline "; if ($at_through) $r .= "line-through "; if ($at_overline) $r .= "overline "; if ($at_blink) $r .= "blink "; $r .= "; "; } if ($at_fontchange) { switch ($at_font) { case 1: $r .= "font-family: serif; white-space: normal; "; break; case 2: $r .= "font-family: monospace; white-space: normal; "; break; case 3: $r .= "font-family: monospace; white-space: pre; "; break; case 4: $r .= "font-family: fantasy; white-space: normal; "; break; case 5: $r .= "font-family: cursive; white-space: normal; "; break; default: break; } } if ($at_fontsizechange) $r .= "font-size: ".$fontsizes[$at_fontsize]."; "; if ($at_fcolorchange && ($at_fcolor !== "")) $r .= "color: ".$at_fcolor."; "; if ($at_bcolorchange && ($at_bcolor !== "")) $r .= "background-color: ".$at_bcolor."; "; $r .= "'>"; $out .= $r; $at_change = FALSE; $at_fcolorchange = FALSE; $at_bcolorchange = FALSE; $at_fontsizechange = FALSE; $at_fontchange = FALSE; $at_changecnt++; } /* output it. */ $out .= $strin[$i]; } } for (; $at_changecnt > 0; $at_changecnt--) $out .= "</span>"; if ($at_paragraph) $out .= '</P>'; return $out; } $str = <<<EOS ^e^c1^s5TEXT CODES:^0 can be used in text messages, articles, and bulletins posted by users on the BBS. ^p^i^uRESET^0^n ^fm^^0^0 = Reset all attribute changes; clean slate; everything reset to defaults... ^p^i^uATTRIBUTES^0^n ^fm^^e^0 = ^eBold^0^n ^fm^^i^0 = ^iItalics^0^n ^fm^^u^0 = ^uUnderline^0^n ^fm^^t^0 = ^tStrike through^0^n ^fm^^o^0 = ^oOver-line^0^n ^fm^^x^0 = ^xBlink^0 (not supported on all browsers) ^p^i^uSCIENTIFIC^0^n ^fm^^~^0 = ^~Superscript^0 (These two are mutually exclusive)^n ^fm^^_^0 = ^_Subscript^0 ^p^i^uTYPE-FACES^0^n ^fm^^f^in^0 = Type-face font (dependent on browser) where ^i^fmn^0 = ^n ^Pi^fmp^0 ^fpproportional^0^n ^fmm^0 ^fmmonospaced^0^n ^fcc^0 ^fccode^0^n ^fcf^0 ^fffantasy^0^n ^fcs^0 ^fsscript^0^n ^p^i^uTYPE-FACE SIZING^0^n ^fm^^s#^0 = Change font size. (0=^s0smallest^0, 3=^s3normal^0 6=^s6largest^0) ^p^i^uCOLORING^0^n ^fm^^r^0 = ^rreverse^0. (swap foreground and background colors)^n ^fm^^C^i######^0 = change foreground color with hex (rrggbb) color.^n ^fm^^B^i######^0 = change background color with hex (rrggbb) color.^n ^fm^^c#^0 = change foreground color with quick color. (below)^n ^fm^^b^i#^0 = change background color with quick color. (below)^n ^Pi^fm0^0 ^c0Black^0^n ^fm1^0 ^c1Red^0^n ^fm2^0 ^c2Green^0^n ^fm3^0 ^c3Brown^0^n ^fm4^0 ^c4Blue^0^n ^fm5^0 ^c5Magenta^0^n ^fm6^0 ^c6Cyan^0^n ^fm7^0 ^b0^c7Light Gray^0^n ^fm8^0 ^c8Dark Gray^0^n ^fm9^0 ^b0^c9Bright Red^0^n ^fmA^0 ^b0^caBright Green^0^n ^fmB^0 ^b0^cbYellow^0^n ^fmC^0 ^b0^ccBright Blue^0^n ^fmD^0 ^b0^cdBright Magenta^0^n ^fmE^0 ^b0^ceBright Cyan^0^n ^fmF^0 ^b0^cfWhite^0 ^p^i^uFORMATTING^0^n ^fm^^n^0 = new line^n ^fm^^p^0 = new paragraph^n ^fm^^P^ix^0 = new paragraph with justification/indentation. ^Pi^fml^0 left^n ^fmr^0 right^n ^fmc^0 center^n ^fmj^0 justify^n ^fmL^0 left w/indent^n ^fmR^0 right w/indent^n ^fmC^0 center w/indent^n ^fmJ^0 justify w/indent^n ^fmi^0 indent entire paragraph ^p^i^uSPECIAL CHARACTERS^0^n ^fm^^^^^0 = ^^^n ^fm^^g^in^0 = graphic character. (not supported on all browsers) Where ^fm^in^0 =^n ^Pi^fm0^0 ^g0^n ^fm1^0 ^g1^n ^fm2^0 ^g2^n ^fm3^0 ^g3^n ^fmt^0 ^gt^n ^fmb^0 ^gb^n ^fml^0 ^gl^n ^fmr^0 ^gr^n ^fmq^0 ^gq^n ^fmw^0 ^gw^n ^fme^0 ^ge^n ^fma^0 ^ga^n ^fms^0 ^gs^n ^fmd^0 ^gd^n ^fmz^0 ^gz^n ^fmx^0 ^gx^n ^fmc^0 ^gc^n ^fmv^0 ^gv^n ^fmh^0 ^gh^n ^p ^fp^i^eThe above was generated with...^0^n EOS; echo str_textcodes($str).'<br><br>'; echo '<pre><code>'.$str.'</code></pre>'; ?> CW
×
×
  • 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.