Login Register






Programming Game filter_list
Author
Message
RE: Programming Game #11
Almost two days without anyone posting what my code does? Biggrin
[Image: CDUAq9d.png]

Reply

RE: Programming Game #12
(05-07-2014, 08:46 PM).Shebang Wrote:
Code:
For Each M As Match In Matches L = New ListViewItem L.Text = SymbolCleaner(M.Value.Split(New String() {"</a> by <b>"}, StringSplitOptions.None)(1).Split(New String() {"</b>"}, StringSplitOptions.None)(0)) L.SubItems.Add(SymbolCleaner(M.Value.Split(New String() {".html"">"}, StringSplitOptions.None)(1).Split(New String() {"</a>"}, StringSplitOptions.None)(0))) L.Tag = SymbolCleaner(M.Value.Split(New String() {"<a href="""}, StringSplitOptions.None)(1).Split(""""c)(0)) Invoke(New MethodInvoker(Sub() ListView1.Items.Add(L))) Next

Some random code from one of my projects.
looks like a (bad) parser. Assigns some data into some variables based on some HTML it read. Need more info to say exactly what it's parsing Tongue


PHP Code:
<?php echo "<html><head><title>thing</title><style>body{line-height:0;font-size:1px;}</style></head><body>"; $unsafe_raw_input = $_GET["imagelocation"]; $img = imagecreatefromstring(file_get_contents($unsafe_raw_input)); $width = imagesx($img); $height = imagesy($img); for($h=0;$h<$height;$h++){for($w=0;$w<=$width;$w++){$rgb = imagecolorat($img, $w, $h);$a = ($rgb >> 24) & 0xFF; $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF;$b = $rgb & 0xFF; $a = abs(($a / 127) - 1);if($w == $width){ echo '<br>'; }else{ echo '<span style="color:rgba('.$r.','.$g.','.$b.','.$a.');">#</span>';}}}?></body></html>
PGP
Sign: F202 79C9 76F7 40BB 54EC 494F 5DEF 1D70 14C1 C4CC
Encrypt: A5B3 1B21 55E1 80AF 4C6E DE83 467B 8EFC 3DEE 681C
Auth: CD55 E8A5 1A08 2933 8BA6 BC88 D81F 1943 739A 3C47

Reply

RE: Programming Game #13
please stop flooding this thread with your annoying interpreted programming languages
[Image: Z9DvuyJ.png]

Reply

RE: Programming Game #14
(05-09-2014, 02:20 PM)Reiko Wrote: looks like a (bad) parser. Assigns some data into some variables based on some HTML it read. Need more info to say exactly what it's parsing Tongue


-snip-

Since you have the essentials correct, I'll call it a good response. I initially use Regex to parse for a body of elements, and from there use string manipulation to get the data I need (I'm learning Regex right now, don't know enough for it to be entirely effective). In this case, the data comes from the AZLyrics search result page. L.Text is assigned to the artist's name, L.SubItems.Add() is setting the subitem to the song name, and L.Tag is the link to view the lyrics. Then the L (ListViewItem) object is being added to a listview.

Also, your code converts an image to ASCII Smile



(05-09-2014, 03:17 PM)xornull Wrote: please stop flooding this thread with your annoying interpreted programming languages

Please stop flooding this thread with your off-topic posts. Maybe correctly answer one of the snippets correctly so you can watch us fail at ASM :p



It's at nine lines right now, right?

Code:
uint[] octet = { 8, 8, 4, 4 }; uint final = 0; for (int i = 0; i < 4; i++) { final += octet[i] << (8 * i); } Console.WriteLine(final); Console.Read();
[Image: CDUAq9d.png]

Reply

RE: Programming Game #15
(05-09-2014, 08:30 PM).Shebang Wrote:
Code:
uint[] octet = { 8, 8, 4, 4 }; uint final = 0; for (int i = 0; i < 4; i++) { final += octet[i] << (8 * i); } Console.WriteLine(final); Console.Read();

My English really sucks, so this will be pain in the ass.
1st line declares array of your numbers, 2nd is result.

Now, in cycle, for each item in array you will add number to result.
For first passage, it adds 0 (8 << 0 = 8 * 0), for second 4096 (8 << 8 = 8 * 512), for third 1048576 (4 << 16 = 4 * 262144) and for fourth 536870912 (4 << 24 = 4 * 134217728).

All together, result should be 537923584.

I am doing this by head, so result can be incorrect, but I'm trying my best. Smile

Now, my code. It's pretty late here, so I'm just posting part of my old project.
Code:
private static Map.Tile[,] tiles = new Map.Tile[15, 40]; internal void Load(string MapName) { string[] rows = File.ReadAllLines("maps/" + MapName + "/tiles.map"); for (int i = 0; i < 15; i++) { string[] tInfo = rows[i].Split(' '); for (int j = 0; j < 40; j++) { Map.AddTile(i, j, Convert.ToInt16(tInfo[j])); } } }
We are fucked, Eddie!

Reply

RE: Programming Game #16
(05-10-2014, 01:08 AM)tortilla Wrote: My English really sucks, so this will be pain in the ass.
1st line declares array of your numbers, 2nd is result.

Now, in cycle, for each item in array you will add number to result.
For first passage, it adds 0 (8 << 0 = 8 * 0), for second 4096 (8 << 8 = 8 * 512), for third 1048576 (4 << 16 = 4 * 262144) and for fourth 536870912 (4 << 24 = 4 * 134217728).

All together, result should be 537923584.

I am doing this by head, so result can be incorrect, but I'm trying my best. Smile

Now, my code. It's pretty late here, so I'm just posting part of my old project.
Code:
private static Map.Tile[,] tiles = new Map.Tile[15, 40]; internal void Load(string MapName) { string[] rows = File.ReadAllLines("maps/" + MapName + "/tiles.map"); for (int i = 0; i < 15; i++) { string[] tInfo = rows[i].Split(' '); for (int j = 0; j < 40; j++) { Map.AddTile(i, j, Convert.ToInt16(tInfo[j])); } } }

Almost, not quite though Biggrin Remember that a bit shift left works like so:

x << y = x * 2^y

It converts an IP address (hence the array called octets) in to it's decimal form (which can be interpreted by a lot of programs surprisingly).

8 << 0 = 8 * 2^0 = 8
8 << 8 = 8 * 2^8 = 2048
4 << 16 = 4 * 2^16 = 262144
4 << 24 = 4 * 2^24 = 67108864

So the IP 4.4.8.8 converted to decimal is 67373064 Smile



As for your code, you're reading a file that contains map information for your program. You create a 2D array (15*40), and then read each row from the file in to a string array. Then each line is split by spaces, and each individual tile element is added to the array.
[Image: CDUAq9d.png]

Reply

RE: Programming Game #17
PHP Code:
#!/usr/bin/perl use warnings; use strict; my $regx = ( "0x0000000000400410 0x0000000000400416 0x000000000040041b" ); print "Enter shit you want: "; my $stream = <STDIN>; chomp($stream); if ($regx =~ /$stream/) { print "Yes that exists\n"; } else { print "That doesn't though\n"; }

ya this isn't even useful and the return addresses were just there to make me look cooler than I actually am which I don't think worked out.
Unleash the lead from my pistol into my head bumpin' crystal

Reply