Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
JavaScript-Packer / base64-encoder-utf.js
Created July 31, 2015 05:18
Base64 encoder with UTF-8 encoding - Base64 Button function for http://www.whak.ca/packer/LZW(HAK).htm
function b2a(r) {
function utf(r) {
var t, e, o;
for (r = r.replace(/\r\n/g, "\n"), t = "", e = 0; e < r.length; e++) o = r.charCodeAt(e),
128 > o ? t += String.fromCharCode(o) :o > 127 && 2048 > o ? (t += String.fromCharCode(192 | o >> 6),
t += String.fromCharCode(128 | 63 & o)) :(t += String.fromCharCode(224 | o >> 12),
t += String.fromCharCode(128 | 63 & o >> 6), t += String.fromCharCode(128 | 63 & o));
return t;
}
var t, a, h, e, o, c, n = "", C = 0, i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
@JavaScript-Packer
JavaScript-Packer / smiley-shaped.js
Last active August 29, 2015 14:26
http://www.whak.ca/packer/smilies.htm Working on a script generator that will turn JavaScript source codes into silly shapes, here is a sample
var WHAK=
'var C="charCodeAt",G=eval,'+
'I="indexOf",Q="charAt",U=32768,M=G('+
'"Math.pow");_$={_:"WHAK+com/PaCker=BDEFGIJL'+
'MNOQRSTUVXYZbdfghijlnpqstuvwxyz0123456789",_f:Str'+
'ing.fromCharCode,$:function(r){if(null==r)return"";v'+
'ar a,e,t,o,h,c,f="",n=0,i=0,d=_$._f;for(r=r.replace(/[^A-'+
'Za-z0-9+/=]/g,"");i<r.length;)e=_$._[I](r[Q](i++)),t=_$._[I]('+
'r[Q](i++)),h=_$._[I](r[Q](i++)),c=_$._[I](r[Q](i++)),e=e<<2|t>>4,'+
't=(15&t)<<4|h>>2,o=(3&h)<<6|c,0==n%2?(a=e<<8,64!=h&&(f+=d(a|t)),64!'+
@JavaScript-Packer
JavaScript-Packer / html.entity.safe.escape.js
Last active December 23, 2018 11:24
Turned/reversed the unpacker for WHAK compression algorithm and made it into a HTML entities encoder - http://www.whak.ca/packer/JavaScript.htm
var W,H,A,K;
H ="&amp; &lt; &gt; &#34; &#10; &#39;"[$="split"](" ");
A ="&<>\"\n'";W='<script>alert("www.WHAK.com");<\/script>';
K =0;for(K in A)W=W[$](A[K]).join(H[K]);alert(W);
@JavaScript-Packer
JavaScript-Packer / word-stats.js.html
Created July 26, 2015 16:13
Paste some text and get statistics on the words found in text. Demo on http://jsfiddle.net/dktvn13L/
<div id="wct_embed_counts">
<textarea id="wct_embed_input_text" rows="12">www.WHAK.com</textarea>
<div id="wct_embed_result">www.WHAK.com</div>
<div id="wct_powered_by">www.WHAK.com</div>
<script type="text/javascript">function wct_getWordStats(e) {
var r, a, _, c, d, s, u, t = [], n = e.trim();
t.num_character = e.trim().length;
r = n.split(/\s+/).join("");
t.num_character_wo_spaces = r.length, t.num_paragraph = 0, n.length > 0 && (t.num_paragraph = n.split(/\n+/).length);
a = n.replace(/(\w)[-_'](\w)/gi, "$10$2");
@JavaScript-Packer
JavaScript-Packer / multiple-replace-demo.js
Last active January 1, 2016 03:57
Multiple replacements VIA an array for find & replace terms.
var W,H,A,K;
W = '123456'[$='split']('');
H = 'test this WHAK com www for'[$](' ');
A = '2 is a 1 (1ed 6 3 2, 1 6 3 that), 1ing 6 5.3.4';
K = 0; for(K in W)A=A[$](W[K]).join(H[K]);
document['write'](A);
// this is a test (tested for WHAK this, test for WHAK that), testing for www.WHAK.com
@JavaScript-Packer
JavaScript-Packer / html-entities-encoder.htm
Created July 26, 2015 12:28
Encode HTML entities for every character in a string - Demo on http://jsfiddle.net/mjytsf60/
<textarea id=loader rows=11 cols=77></textarea>
<script>
function encodeHTMLentities(w){return w.replace(/[^]/g,function(w){return '&#'+w.charCodeAt(0)+';'})}
loader.value=encodeHTMLentities(document.body.innerHTML)
</script>
@JavaScript-Packer
JavaScript-Packer / D3.js.embedded.69KB.demo.html
Last active August 29, 2015 14:25
D3.js is a JavaScript library for manipulating documents based on data. Demo on http://jsfiddle.net/n9rp2xqt/show/ D3 helps you bring data to life using HTML, SVG, and CSS. D3’s emphasis on web standards gives you the full capabilities of modern browsers without tying yourself to a proprietary framework, combining powerful visualization componen…
<!DOCTYPE html><meta charset="utf-8">
<body><!-- We compressed 147 KB https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js to 48 KB on
http://www.scriptcompress.com then embedded JavaScript into HTML file with working demo under 70KB -->
<script>var WHAK_com =atob('QlpoOTFBWSZTWRx4Tl4AsOhfgFAAf////7////+/////YOJd9D1r6UABW7A9nr3Gz7lD330ds\
t97PiSx3t4G75u6+rRqocUtb1iuqUdd3uym2LrKqr1pHpou7j6d5i+2qVSSRSh9kwYFKhIDzdz3vLZYAfTd6FKSq0+7rpHPW+2PTu\
G+2B9u+15Q3d1WexfV8OHvPc++0Qz7nOnTd3XHOabOji5GqoKWbQAPs9kM9s3bXo92vYN1l2c3Du7PTkPIW1ADvvvvj7fZ9AHz7LN\
ki9srlD7Hoy0bYAAoANr1uMtKPWdT2He7e3uO2syzfd7zPdV3ambYpTSWhfGAHuYe7h1CqK5NBCj3twUCgXsa0rbPd3ZQXjyu2ts8\
y1t1d12d267Wt3TdtrOq67bL3B0LYave940DbdHe527e5i9zqDbw+6wPu6S+vfM77nbTNzh1ueOJ7PLPfJCgyWvvoMPoL2F3eqUa+\
ju305fU68OcJ2W3t29u9VLx8dXsbD4sfWtrtJ7w+u+rPcKz299oPdeFzUemXvXXN7723222D66JWhq+9szc+K+XnDN7goHIBfLzVt\
nO3O9b65699t99ut5253W3dfHN4WYqNDffYCrwm623Trzt3NUdw97b3qngAKDPU03OGtmGjuOFdCSsuZ3vdFWd7nueoWus2AATVho\
@JavaScript-Packer
JavaScript-Packer / guid.js
Created July 24, 2015 10:09
Function to get a unique guid of the specified length (32 is default)
function guid(t) {
var a, r = [], e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", n = e.length;
for (t = t || 32, a = 0; t > a; a++) {
r[a] = e.charAt(Math.floor(Math.random() * n));
}
return r.join("");
}
@JavaScript-Packer
JavaScript-Packer / numbers-for-humans.js
Created July 24, 2015 10:07
Make numbers show like 1st, 2nd, 3rd or (n)th
function humanizer(e) {
if (e % 100 >= 11 && 13 >= e % 100) {
return e + "th";
}
switch (e % 10) {
case 1:
return e + "st";
case 2:
return e + "nd";
@JavaScript-Packer
JavaScript-Packer / stripper.js
Created July 24, 2015 10:04
Function removes leading and trailing whitespace from string
function strip(e) {
return e.trim ? e.trim() : e.replace(/^\s+/, "").replace(/\s+$/, "");
}