Random line of code thread
category: code [glöplog]
Code:
moveq #14,D0
clrsp: clr.l -(SP)
dbra D0,clrsp
movem.l (SP)+,D0-A6
Shorter anyone ?
Code:
#define BYTESPERPIXEL(fits8bits) (3 << (!fits8bits))
…
int main(int argc, char **argv) {
in = alloca(width * height * BYTESPERPIXEL(256 > max));
out = alloca(width * height * BYTESPERPIXEL(256 > max));
fread(in, BYTESPERPIXEL(256 > max), width * height, stdin);
ptr = out;
for(y = 0; y < height; y++) {
for(x = 0; x < width; x++) {
for(i = 0; i < BYTESPERPIXEL(256 > max); i++) {
*ptr++ = *in++ & visibility_mask(x, y, argc, argv);
}
}
}
printf(”P6n%d %dn%dn”, width, height, max);
fwrite(out, BYTESPERPIXEL(max < 256), width * height, stdout);
Taken from The Underhanded C Contest - a contest for evil code that appears to be harmless.
ah, wasn't this the one that encodes the original bw bits in the number of '0' chars ? :)
Code:
$this->target_type = (($record['target_type']=="Advertisment")?"Advertisement":$record["target_type"]);
BYTE idx;
if (!FreeImage_GetPixelIndex(dib, sx + x, sy + y, &idx))
die("failed to read pixel at %d, %d", sx + x, sy + y);
buf[y][0] |= (idx & 1) << (7 - x);
buf[y][1] |= ((idx >> 1) & 1) << (7 - x);
if (!FreeImage_GetPixelIndex(dib, sx + x, sy + y, &idx))
die("failed to read pixel at %d, %d", sx + x, sy + y);
buf[y][0] |= (idx & 1) << (7 - x);
buf[y][1] |= ((idx >> 1) & 1) << (7 - x);
hermes: get the Stoustrup and read about virtual inheritance, that's probably what you wanted to do there.
btst.b #6,$bfe001
[quote]btst.b
FAIL!
FAIL!
And [/quote] FAIL \o/
Quote:
.if Wav_Slot != -1
invoke Is_Wav_Playing, Wav_Slot
.if eax == TRUE
fld Panning2
fsin
fadd CFLT(1.0)
fmul CFLT(0.5)
fstp Cur_Panning
invoke Set_Wav_Panning, Wav_Slot, Cur_Panning
fld CFLT(1.0)
fmul FrameRate
fadd Panning2
fstp Panning2
.else
mov Wav_Slot, -1
.endif
.endif
invoke DInput_Get_Key, DIK_ESCAPE
test eax, eax
jz Esc_Pressed
invoke Terminate_Application
Esc_Pressed: ret
Update endp
ramennumeralweb.html:
<!--
RamenNumeralWeb.html
David Jones
Jan 21 2010
Purpose: convert between different bases
-->
<html>
<head>
<title>Ramen Numerals Web Edition</title>
</head>
<body>
<body onload="document.ramennumerals.txtInput.focus()">
<form name="ramennumerals" id="ramennumerals" action="ramennumeralsweb.asp" method="post" style="margin: 0; text-align: center;">
<table border="1">
<th colspan="2">Ramen Numerals Web Edition By David Jones</th>
<tr>
<td><label for="InputChrSet">Input Character Set</label></td>
<td><input type="text" name="InputChrSet" size="22" title="Enter Characters Here" value="0123456789"/></td>
</tr>
<tr>
<td><label for="txtInput">Input</label></td>
<td><input type="text" name="txtInput" size="22" title="Enter Characters Here" value="0"/></td>
</tr>
<tr>
<td><label for="outputChrSet">Output Character Set</label></td>
<td><input type="text" name="outputChrSet" size="22" title="Enter Characters Here" value="0123456789ABCDEF"/></td>
</tr>
<tr>
<td colspan="2"><center><u>Convert Between Number Bases</u></center></td>
</tr>
<tr>
<td colspan="2"><center>Input Character Set: 0123456789 (Decimal)</center></td>
</tr>
<tr>
<td colspan="2"><center>Input Is The Number In The Input Characterset To Convert</center></td>
</tr>
<tr>
<td colspan="2"><center>Output Character Set: 0123456789ABCDEF (HexaDecimal)</center></td>
</tr>
<tr>
<td colspan="2"><center>Output Will Be In The Specified Output Format</center></td>
</tr>
</table>
<input type="submit" value="Submit"/>
<input type="reset" value="Reset" onclick="document.ramennumerals.txtInput.focus()"/>
</form>
</body>
</html>
ramennumeralsweb.asp:
<%@ Language="VBScript" %>
<% Option Explicit %>
<!--
David Jones
Spring 2010
-->
<%
Dim inputChrSet
Dim txtInput
Dim outputChrSet
Dim PreOutput
Dim output
Dim format1
Dim format2
inputChrSet = Request.Form("InputChrSet")
txtInput = Request.Form("txtInput")
outputChrSet = Request.Form("outputChrSet")
preOutput = ConvAny2Dec2(txtInput, inputChrSet, True)
output = ConvDec2Any(preOutput, outputChrSet)
If inputChrSet = "0123456789" Then
format1 = "Decimal"
ElseIf inputChrSet = "0123456789ABCDEF" Then
format1 = "Hexadecimal"
ElseIf inputChrSet = "01" Then
format1 = "Binary"
ElseIf inputChrSet = "01234567" Then
format1 = "Octal"
Else
format1 = "Custom"
End If
If outputChrSet = "0123456789" Then
format2 = "Decimal"
ElseIf outputChrSet = "0123456789ABCDEF" Then
format2 = "Hexadecimal"
ElseIf outputChrSet = "01" Then
format2 = "Binary"
ElseIf outputChrSet = "01234567" Then
format2 = "Octal"
Else
format2 = "Custom"
End If
Response.Write "<html>"
Response.Write "<head>"
Response.Write "<title>Ramen Numerals Web Edition</title>"
Response.Write "</head>"
Response.Write "<body>"
Response.Write "<center>"
Response.Write "<table border=" & Chr(34) & "1" & Chr(34) & ">"
Response.Write "<th colspan=" & Chr(34) & "2" & Chr(34) & ">" & "Results" & "</th>"
Response.Write "<tr>"
Response.Write "<td>Input Character Set</td>"
Response.Write "<td>" & format1 & "</td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td>Output Character Set</td>"
Response.Write "<td>" & format2 & "</td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td>Input Number</td>"
Response.Write "<td>" & txtInput & "</td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td>Output Number</td>"
Response.Write "<td>" & output & "</td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td colspan=" & Chr(34) & "2" & Chr(34) & ">" & txtInput & " in " & format1 & " is " & output & " in " & format2 & "</td>"
Response.Write "</tr>"
Response.Write "</table>"
Response.Write "</center>"
Response.Write "</body>"
Response.Write "</html>"
Function ConvDec2Any(thenum, thechars)
On Error Resume Next
Err.Clear
Dim remainder
Dim holdbuffer
Dim buffer
Do
thenum = thenum / Len(thechars)
If InStr(thenum, ".") = 0 Then
remainder = 0
Else
remainder = Right(thenum, Len(thenum) - InStr(thenum, ".") + 1) * Len(thechars)
thenum = Left(thenum, InStr(thenum, "."))
End If
holdbuffer = buffer
buffer = Mid(thechars, remainder + 1, 1) & holdbuffer
Loop While thenum > 0
thenum = thenum / Len(thechars)
If InStr(thenum, ".") = 0 Then
remainder = 0
Else
remainder = Right(thenum, Len(thenum) - InStr(thenum, ".") + 1) * Len(thechars)
thenum = Left(thenum, InStr(thenum, "."))
End If
if Err.Number <> 0 then
ConvDec2Any = "Error!"
Exit Function
end if
ConvDec2Any = buffer
End Function
Function ConvAny2Dec2(thenum,thechars,CaseSensitive)
On Error Resume Next
Err.Clear
Dim b
Dim I
Dim HeXeN
Dim hexen2
If thenum = vbNullString Then
ConvAny2Dec2 = "Error!"
Exit Function
End If
For I = 1 To Len(thenum) + 1
If CaseSensitive = True Then
HeXeN = InStr(thechars, Mid(thenum, I, 1)) - 1
Else
HeXeN = InStr(UCase(thechars), Mid(UCase(thenum), I, 1)) - 1
End If
If HeXeN < 0 Then
If thenum > 0 Then
ConvAny2Dec2 = "Error!"
Exit Function
End If
End If
b = Len(thenum) - I
hexen2 = hexen2 + Len(thechars) ^ CLng(b) * CLng(HeXeN)
Next
if Err.Number <> 0 then
ConvAny2Dec2 = "Error!"
Exit Function
end if
ConvAny2Dec2 = hexen2
End Function
%>
<!--
RamenNumeralWeb.html
David Jones
Jan 21 2010
Purpose: convert between different bases
-->
<html>
<head>
<title>Ramen Numerals Web Edition</title>
</head>
<body>
<body onload="document.ramennumerals.txtInput.focus()">
<form name="ramennumerals" id="ramennumerals" action="ramennumeralsweb.asp" method="post" style="margin: 0; text-align: center;">
<table border="1">
<th colspan="2">Ramen Numerals Web Edition By David Jones</th>
<tr>
<td><label for="InputChrSet">Input Character Set</label></td>
<td><input type="text" name="InputChrSet" size="22" title="Enter Characters Here" value="0123456789"/></td>
</tr>
<tr>
<td><label for="txtInput">Input</label></td>
<td><input type="text" name="txtInput" size="22" title="Enter Characters Here" value="0"/></td>
</tr>
<tr>
<td><label for="outputChrSet">Output Character Set</label></td>
<td><input type="text" name="outputChrSet" size="22" title="Enter Characters Here" value="0123456789ABCDEF"/></td>
</tr>
<tr>
<td colspan="2"><center><u>Convert Between Number Bases</u></center></td>
</tr>
<tr>
<td colspan="2"><center>Input Character Set: 0123456789 (Decimal)</center></td>
</tr>
<tr>
<td colspan="2"><center>Input Is The Number In The Input Characterset To Convert</center></td>
</tr>
<tr>
<td colspan="2"><center>Output Character Set: 0123456789ABCDEF (HexaDecimal)</center></td>
</tr>
<tr>
<td colspan="2"><center>Output Will Be In The Specified Output Format</center></td>
</tr>
</table>
<input type="submit" value="Submit"/>
<input type="reset" value="Reset" onclick="document.ramennumerals.txtInput.focus()"/>
</form>
</body>
</html>
ramennumeralsweb.asp:
<%@ Language="VBScript" %>
<% Option Explicit %>
<!--
David Jones
Spring 2010
-->
<%
Dim inputChrSet
Dim txtInput
Dim outputChrSet
Dim PreOutput
Dim output
Dim format1
Dim format2
inputChrSet = Request.Form("InputChrSet")
txtInput = Request.Form("txtInput")
outputChrSet = Request.Form("outputChrSet")
preOutput = ConvAny2Dec2(txtInput, inputChrSet, True)
output = ConvDec2Any(preOutput, outputChrSet)
If inputChrSet = "0123456789" Then
format1 = "Decimal"
ElseIf inputChrSet = "0123456789ABCDEF" Then
format1 = "Hexadecimal"
ElseIf inputChrSet = "01" Then
format1 = "Binary"
ElseIf inputChrSet = "01234567" Then
format1 = "Octal"
Else
format1 = "Custom"
End If
If outputChrSet = "0123456789" Then
format2 = "Decimal"
ElseIf outputChrSet = "0123456789ABCDEF" Then
format2 = "Hexadecimal"
ElseIf outputChrSet = "01" Then
format2 = "Binary"
ElseIf outputChrSet = "01234567" Then
format2 = "Octal"
Else
format2 = "Custom"
End If
Response.Write "<html>"
Response.Write "<head>"
Response.Write "<title>Ramen Numerals Web Edition</title>"
Response.Write "</head>"
Response.Write "<body>"
Response.Write "<center>"
Response.Write "<table border=" & Chr(34) & "1" & Chr(34) & ">"
Response.Write "<th colspan=" & Chr(34) & "2" & Chr(34) & ">" & "Results" & "</th>"
Response.Write "<tr>"
Response.Write "<td>Input Character Set</td>"
Response.Write "<td>" & format1 & "</td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td>Output Character Set</td>"
Response.Write "<td>" & format2 & "</td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td>Input Number</td>"
Response.Write "<td>" & txtInput & "</td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td>Output Number</td>"
Response.Write "<td>" & output & "</td>"
Response.Write "</tr>"
Response.Write "<tr>"
Response.Write "<td colspan=" & Chr(34) & "2" & Chr(34) & ">" & txtInput & " in " & format1 & " is " & output & " in " & format2 & "</td>"
Response.Write "</tr>"
Response.Write "</table>"
Response.Write "</center>"
Response.Write "</body>"
Response.Write "</html>"
Function ConvDec2Any(thenum, thechars)
On Error Resume Next
Err.Clear
Dim remainder
Dim holdbuffer
Dim buffer
Do
thenum = thenum / Len(thechars)
If InStr(thenum, ".") = 0 Then
remainder = 0
Else
remainder = Right(thenum, Len(thenum) - InStr(thenum, ".") + 1) * Len(thechars)
thenum = Left(thenum, InStr(thenum, "."))
End If
holdbuffer = buffer
buffer = Mid(thechars, remainder + 1, 1) & holdbuffer
Loop While thenum > 0
thenum = thenum / Len(thechars)
If InStr(thenum, ".") = 0 Then
remainder = 0
Else
remainder = Right(thenum, Len(thenum) - InStr(thenum, ".") + 1) * Len(thechars)
thenum = Left(thenum, InStr(thenum, "."))
End If
if Err.Number <> 0 then
ConvDec2Any = "Error!"
Exit Function
end if
ConvDec2Any = buffer
End Function
Function ConvAny2Dec2(thenum,thechars,CaseSensitive)
On Error Resume Next
Err.Clear
Dim b
Dim I
Dim HeXeN
Dim hexen2
If thenum = vbNullString Then
ConvAny2Dec2 = "Error!"
Exit Function
End If
For I = 1 To Len(thenum) + 1
If CaseSensitive = True Then
HeXeN = InStr(thechars, Mid(thenum, I, 1)) - 1
Else
HeXeN = InStr(UCase(thechars), Mid(UCase(thenum), I, 1)) - 1
End If
If HeXeN < 0 Then
If thenum > 0 Then
ConvAny2Dec2 = "Error!"
Exit Function
End If
End If
b = Len(thenum) - I
hexen2 = hexen2 + Len(thechars) ^ CLng(b) * CLng(HeXeN)
Next
if Err.Number <> 0 then
ConvAny2Dec2 = "Error!"
Exit Function
end if
ConvAny2Dec2 = hexen2
End Function
%>
Code:
template <typename Constant, Constant constant>
struct IntegralConstant {
typedef Constant Value;
typedef IntegralConstant<Constant, constant> Type;
static Constant const value = constant;
};
typedef IntegralConstant<bool, false> False;
typedef IntegralConstant<bool, true> True;
template <typename First, typename Second>
struct Equal : public False {
};
template <typename Type>
struct Equal<Type, Type> : public True {
};
template <typename First, typename Second>
struct And : public Equal<typename Equal<First, Second>::Type, True>::Type {
};
Hacked it right now out of boredom, untested but should work. Though, it's 5:37 AM :).
signal data_clk_slow, data_clk_sync, data_clk_fast : std_logic := '0';
attribute maxdelay of data_clk_slow : signal is c_maxdelay;
attribute maxdelay of data_clk_slow : signal is c_maxdelay;
wow, another VHDL coder :)
use IEEE.std_logic_arith.all;
Code:
move.b psg_select.w,$ffff8800.w
sta outa+$01
stx outx+$01
sty outy+$01
; code some mega fx here
lda $dd0d
outa lda #$00
outx ldx #$00
outy ldy #$00
rti
stx outx+$01
sty outy+$01
; code some mega fx here
lda $dd0d
outa lda #$00
outx ldx #$00
outy ldy #$00
rti
if;
import (python.tutorial.for.programming.beginner.that.makes.sense)
then; (gratify.demoscene)
else; (PANTS.OFF)
import (python.tutorial.for.programming.beginner.that.makes.sense)
then; (gratify.demoscene)
else; (PANTS.OFF)
afdsofpidhf BIG KAHUNA BURGER flasfhasuifhirhg958248tj
if (lazy) then crazy;
if (crazy) then sleepy;
if (sleepy) then printf("I am le tired\n");
if (tired) then call goto_bed_and_fire_ze_misiles(illegal telepathy);
if (crazy) then sleepy;
if (sleepy) then printf("I am le tired\n");
if (tired) then call goto_bed_and_fire_ze_misiles(illegal telepathy);
Quote:
Code:
moveq #14,D0
clrsp: clr.l -(SP)
dbra D0,clrsp
movem.l (SP)+,D0-A6
Shorter anyone ?
Code:
lea zeroedMemory,a0
movem.l (a0),d0-a6
:)
Add to that the 28 zero bytes and you're left with a much bigger version :)
60 bytes you mean (15*4). ;)