wolfhammer
• Member for 8 years, 7 months
• Last seen more than a month ago

108k views

JavaScript var can = document.createElement('canvas'); can.width=1024; can.height=1024; can.style.position='fixed'; can.style.left='0px'; can.style.top='0px'; can.onclick=function(){ document.body....

4k views

JavaScript Canvas Update Excellent suggestions in the comments. It's now faster and doesn't slow down the ui! function previewFile() { var srcImage = document.getElementById('srcImage'); ...

9k views

HTML5, 37 bytes <svg><path d="M4,0 7,8 0,3 8,3 1,8"/>

1k views

JavaScript 752,701 function Z(I,a,b){ var C=document.createElement('canvas') var W=C.width=I.width,H=C.height=I.height,X=C.getContext('2d') X.drawImage(I,0,0) a*=2,b*=2,W/=a,H/=b ...

9k views

JavaScript 271 251 c=document.body.appendChild(document.createElement('canvas')) x=c.getContext('2d') c.width=400 r=c.height=200 for(i=0;i<8;x.beginPath(),x.arc(r,r,r-i*10,0,7),x.fillStyle=...

28k views

JavaScript (+bonus) - pixel divide swap repeater The function takes an image element and Divides the pixels by 8. Does a reversible swap of pixel groups. Recurses swapping if the pixel ...

3k views

JavaScript ES6 432 405 398 385 o="Dec Hex " o=${o}${o} ${o+o+o+o}${o} ${o}\n for(i=0;i<16;i++){for(j=0;j<8;j++){k=i+j*16 o+=k>9&&k<16?' ':k<96||k>99?' ':' ' o+=k+" ... View answer 87 answers 103 votes 21k views 3 votes JavaScript 206 175 c=c.getContext('2d') d=c.createImageData(w=78,h=52),a=Int32Array(d.data.buffer) for(i=w*h;i--;)a[i]=-[6007552,1,13286929][i%w/26|0] c.putImageData(d,0,0) <canvas id=c>... View answer 21 answers 55 votes 5k views 3 votes JavaScript foreach var arr = ["Seattle", "WA", "New York", "NY", "Chicago", "IL"]; function foreach(fn, arr) { var s = fn.toString(); var args = s.substring(s.indexOf('(')+1,s.indexOf(')')).... View answer 29 answers 28 votes 11k views 3 votes JavaScript - Optimized Node cluster with Branches, Leaves, and string barrels. // fullMon - Converts month key names to full names using a highly optimized tree for fast traversal. function fullMon(... View answer 5 answers -1 votes 542 views 2 votes JavaScript 0.185 Seconds function fact(x) { x+="" var rL=1,rI=0,i=0 if(x.length <2)return [x] for(i;i<x.length;i++)rL*=(i+1); var r = new Array(rL); function loop(p, s) { ... View answer 13 answers -6 votes 2k views 2 votes JavaScript 89 for(i=prompt,x=i(),n='';p=i();n+=p.replace(/./g,m=>x[m.charCodeAt(0)-97])+"\n"); alert(n) View answer 13 answers 18 votes 2k views 2 votes JavaScript 112 alert(prompt().replace(/.*?\d+/g,function(m){for(i=n=m.length-1,o="";i--;){j=m[n];while(j--)o=m[i]+o}return o})) View answer 31 answers 46 votes 11k views 2 votes Tcl 298 package require base64 set d [base64::decode AVUABVVUCr7ALv78Lr+/K/6oA//wCmoAKmmoqlWq+ddv/VV/9VVfBUFQKgCoqgCq] binary scan$d B* z set i 0 foreach {a b} [split $z ""] { if {$i % 12 == 0} {...

8k views

JavaScript 111 This does the number conversion without parseInt or eval. Reading the string backwards and counting bits it set's bit x if it's a one. When a space is found a the number is converted ...

7k views

JavaScript function rgbToHex(rgb) { var r = rgb[0].toString(16); var g = rgb[1].toString(16); var b = rgb[2].toString(16); return '#' + r + g + b; } alert(rgbToHex([176,0,11]));

3k views

JavaScript // setup alphabet and secret rotated alphabet // var alpha=' abcdefghijklmnopqrstuvwxyz' var rotor=' cdefghijklmnopqrstuvwxyzab' alpha+=alpha.toUpperCase() rotor+=rotor.toUpperCase() ...

3k views

4k views

JavaScript 248 var v= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' function d(k,c){var a,b,o,x a=k.charAt(0) x=v.indexOf(a) b=v.substr(x)+v.substring(0,x) o= v.charAt(b.indexOf(c....

6k views

Tcl 69,69 first attempt 132 keys+vals proc j {x n} { regsub -all {(".*?"):(".*?")} $x "$lappend o \\n$" x subst$x set o $o } proc keys x {j$x 1} proc vals x {j $x 2} second try 69 keys, 69 ... View answer 64 answers 40 votes 4k views 1 votes Tcl, 110 bytes set a 0 set b [incr x] time {set c [expr$a+$b] set a$b set x [expr $x*[set b$c]]} [expr {*}$argv-1] puts$x Try it online! Was able to take off 9 bytes thanks to sergiol!

3k views

JavaScript 143 136 134 123 function p(s,a="",c="",i,z=[]){a+=c,i=s.length !i?z.push(a):0 for(;i--;s.splice(i,0,c))p(s,a,c=s.splice(i,1),0,z);return z} var perms = p([1,2,3]); document....

662 views

JavaScript 4737 4378 alert(is(prompt("enter word"))) function is(w){if(w=="I")return true;w=w.toLowerCase();var key='/345I_abcdefghijklmnopqrstuvwxyz',x = "...

9k views

javascript/html/css 343 202 182 s=document.getElementById('c').style i=0 setInterval(function(){s.left=52+50*Math.cos(i+=.005)+'px' s.top=52+50*Math.sin(i)+'px'},50) b{color:#800080;position:...

3k views

JavaScript 342 334 308 function R(n){var v=document,o=[],x=1,c=v.body.appendChild(v.createElement('canvas')).getContext('2d') while(n)v=n%10,y=x+2,o=[[],[x],[x,x],[x,x,x],[x,y],[y],[y,x],[y,x,x],...

1k views

JavaScript 174 136 function R(s,x){return s.replace(new RegExp(".{"+x+"}","g"),"\$&\n").replace(/[^\n]*/g,function(m){ while(m.length<x)m=" "+m;return m;})}

6k views

JavaScript var c=document.getElementById('c'),x=c.getContext('2d'),i=0 c.width=c.height=140 x.scale(5,5) x.fillStyle="#999" x.fillRect(3,26,14,2) x.fillRect(1,18,2,10) x.fillRect(17,18,2,10)...

10k views

JavaScript 74 72 65 60 //for(i=0,a="0123456789ABCDEF";i++<49;)console.log(a[i>>4]+a[i%16]) for(i=0;i++<48;)console.log((i>>4)+"0123456789ABCDEF"[i%16])

2k views