pouët.net

Random line of code thread

category: code [glöplog]
Code:@panic ; oh god oh fuck ld hl,DS_TempSP ld a,[hl] inc l ld h,[hl] ld l,a ld sp,hl jp DevSound_StopMusic

actually 9 lines but whatever
added on the 2021-04-21 00:28:34 by DevEd DevEd
One-liner which plays DRM protected content from Audible using ffplay, ffprobe & rainbowcrack:
Code:ffplay -activation_bytes $(./rcrack . -h $(ffprobe $1 2>&1 | grep 'file checksum == ' | awk -F ' == ' '{print $2}') | grep 'hex:' | awk -F ':' '{print $2}') $1
added on the 2021-04-21 23:47:42 by pintcat pintcat
Oh and it's inAudible-NG's build of rainbowcrack I was referring to. It contains pre-generated rainbow tables to retrieve your Audible activation code.
added on the 2021-04-22 00:42:06 by pintcat pintcat
LODA assembly language where bitwise xor/and/or is tricky, but gcd is a builtin instruction. Here is the factorial function.
Code:; A000142: Factorial numbers: n! = 1*2*3*4*...*n. ; 1,1,2,6,24,120,720,5040,40320,362880,3628800 mov $1,1 lpb $0 mul $1,$0 sub $0,1 lpe
added on the 2021-04-22 13:18:48 by neoneye neoneye
Code:lea $180+PatchCodeSize_NTSC(a0),a2
added on the 2021-05-11 09:52:16 by StingRay StingRay
Code:#include <Windows.h> #include <set> int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { std::set<int> rates; DEVMODE mode, current; EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &current); int i = 0; while (EnumDisplaySettings(NULL, i++, &mode)) { if (mode.dmPelsWidth == current.dmPelsWidth && mode.dmPelsHeight == current.dmPelsHeight && mode.dmBitsPerPel == current.dmBitsPerPel) { rates.insert(mode.dmDisplayFrequency); } } char key = '1'; for (int rate : rates) { RegisterHotKey(NULL, rate, MOD_CONTROL | MOD_ALT | MOD_WIN, key++); } MSG msg; while (GetMessage(&msg, NULL, 0, 0) > 0) { if (msg.message == WM_HOTKEY) { int rate = static_cast<int>(msg.wParam); if (rates.count(rate)) { EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &current); current.dmDisplayFrequency = rate; ChangeDisplaySettings(&current, CDS_UPDATEREGISTRY); } } } return 0; }
added on the 2021-05-13 12:35:17 by Blueberry Blueberry
Code://https://stackoverflow.com/questions/277772/avoid-trailing-zeroes-in-printf //adapted from paxdiablo (removed truncating) char StringForDouble[50]; char *PointerInString; void PrintDouble(double number) { sprintf(StringForDouble,"%.10f",number); // convert number to string PointerInString=strchr(&StringForDouble[0],'.'); // find decimal point, if any if(PointerInString!=NULL) { PointerInString=strchr(&PointerInString[0],'\0'); // find end of string PointerInString--; while(PointerInString[0]=='0') { // remove trailing zeros PointerInString[0]='\0'; PointerInString--; } if (PointerInString[0]=='.') { PointerInString[0]='\0'; } // if all decimals were zeros, remove "." } fprintf(filep,"%s",&StringForDouble[0]); }
added on the 2021-05-26 19:42:33 by baah baah
Code:int pos=(int(sin(y/80.0-n*10)*100+sin(-y/50.0+n-frameCount/23.0)*100+200)+frameCount*8)%256;
added on the 2021-05-27 07:21:07 by Marq Marq
When looking back at it this morning. Is it any better?
Code://https://stackoverflow.com/questions/277772/avoid-trailing-zeroes-in-printf //adapted from paxdiablo (removed truncating) char StringForDouble[50]; char *PointerInString; void PrintDouble (double number) { sprintf(StringForDouble,"%.10f",number); // convert number to string PointerInString=strchr(&StringForDouble[0],'.'); // find decimal point, if any if(PointerInString!=NULL) { PointerInString=strchr(&PointerInString[0],'\0'); // find end of string do{ PointerInString--; } while(PointerInString[0]=='0'); // remove trailing zeros if (PointerInString[0]=='.') { // if all decimals were zeros, remove "." PointerInString[0]='\0'; } else { PointerInString[1]='\0'; //otherwise put EOS after the first non zero char } } printf("%s",&StringForDouble[0]); }
added on the 2021-05-27 09:43:01 by baah baah
col -= foo(vec2(s*0.000000000000000000000674022 * uv.yx));
added on the 2021-05-27 19:50:50 by BSC BSC
Code:char I[1<<28];size_t K=0,H;long J,_,E;double O,L; size_t R(){return I[K++];} long ri(){for(L=_=1,J=0;H=R()-43,H<3&&(_=1-H)||H-5<10&&(J=J*10+H-5,1);L*=10);return J;} double rf(){O=ri();E=_;H<4?O+=ri()/L:0;return(H-26<33?pow(10,ri()*_):1)*O*E;} int main() { fread(I,1,sizeof I,stdin); // use ri()*_ to read longs or rf() to read doubles }
Code:cmp.w C64TimerAValue(a6),d0
added on the 2021-05-29 12:24:16 by StingRay StingRay
U-boot time!

Code:# Now it's time for some trickery: are we running on a Zybo or a Zybo-Z7? # # The Z7 has 1 GiB of RAM, compared to 512 MiB on the old Zybo. I.e. the latter only # has 0x2000_0000 DRAM bytes, while the Zynq SoC maps the entire # 0x0000_0000..0x3fff_ffff address range to DRAM. Thus, the old Zybo simply # mirrors 0x2000_0000..0x3fff_ffff to 0x0000_0000..0x1fff_ffff . # # Why is this interesting to us? Well, we can write one pattern to 0x2400_0000, # another to 0x0400_0000, and see if 0x2400_0000 suddenly contains the second # pattern written to the low address. If so, we are running an old Zybo. # Fill memory areas mw ${testaddr_lma_hi} 0x69420 8 mw ${testaddr_lma} 0x1337 8 if cmp ${testaddr_lma} ${testaddr_lma_hi} 8; then echo "Running on Zybo 1st ed" # [snip] (load zybo dtb) else echo "Running on Zybo-Z7" # [snip] (load zybo-z7 dtb) fi
added on the 2021-07-06 14:03:08 by porocyon porocyon
Quote:
move.l #($4eae<<16)|(-636&$ffff),d0
added on the 2021-07-14 12:10:55 by StingRay StingRay
Code:armi.a1=atan2((-l2*sin(armi.a2)*x+(l1+l2*cos(armi.a2))*y),(l2*sin(armi.a2)*y+(l1+l2*cos(armi.a2))*x));
added on the 2021-07-14 13:16:21 by Marq Marq
today i implemented a switch in a switch... you don't do that very often, so i felt very xzibit
Code:two_pints = 2 * math.pi * n * t
added on the 2021-07-14 13:59:42 by jobe jobe
Quote:
Code:two_pints = 2 * math.pi * n * t
:D
added on the 2021-07-14 14:16:11 by ferris ferris
taunting us with that one
added on the 2021-07-14 14:16:34 by ferris ferris
Code:cmp.b #(($c00000-$80000)>>16),d1
added on the 2021-09-16 22:18:34 by StingRay StingRay
Code:static sF32 loc_sum_partials(const sF32 *_tbl, sU16 *_phases, const sU16 *_speeds, const sF32 *_amps) { sF32 r = 0.0f; for(sUI i = 0u; i < 256u/*sample->num_partials*/; i++) { r += _tbl[_phases[i]] * _amps[i]; _phases[i] += _speeds[i]; } return r; }

(you need an FFT for this. sounds *lush*)
added on the 2021-10-05 19:09:52 by bsp bsp
Code:// TODO: urgent, must fix before 1st release!
added on the 2021-10-05 19:51:39 by neoneye neoneye
How many years after the first release was the line unearthed?
It's fiction. I can't recall if I have seen it or not.
added on the 2021-10-05 19:56:12 by neoneye neoneye
Code: ld hl,DFP_UpdateFlags push bc ld a,0 inc c scf : rla and a dec c jr nz,:- or [hl] ld [hl],a pop bc
added on the 2021-11-15 18:49:42 by DevEd DevEd

login