Skip to content

Instantly share code, notes, and snippets.

@minitech
minitech / range.js
Created January 31, 2013 17:21
Ranges for JavaScript!
for(var i=0;i<1e3;i++)Object.defineProperty(Number.prototype,'_'+i,{get:function(i){return function(){for(var r=[],j=~~this;j<=i;j++)r.push(j);return r;};}(i)});
1.._20.forEach(function(i) {
console.log(i);
});
@minitech
minitech / gist:5085265
Created March 4, 2013 20:19
Election standings!
$('.vote-count-post').map(function() { return {votes: $(this).text(), name: $(this).closest('tr').find('.user-details > a').text()}; }).get().sort(function(a, b) { return b.votes - a.votes; }).forEach(function(item) { console.log(item); });
@minitech
minitech / gist:5149282
Created March 13, 2013 03:58
I want a language where it’s possible to do this.
container.append $ '<button>', $ '<button>'
text: 'Save' text: 'Cancel'
@minitech
minitech / unsyntax.js
Created April 30, 2013 18:44
JavaSckript Moste Evile. Run with node --harmony-proxies, then just run.
with(evil()) {
get /user
(response) (
response.write("Hello, world!")
)
post /user
(response) (
response.write("Unauthorized!")
)
// Put anything here to make the final assertion true.
function isSafe(input) {
return /^\d+([.e]\d+)?$/.test(input);
}
isSafe(input) && typeof eval(input) !== 'number'
// Put anything here to make the final assertion true.
!function() {
return typeof this === 'object';
}.call(obj);
// Put anything here to make the final assertion true.
var isSafe = function(input) {
return /^\d+([.e]\d+)?$/.test(input);
};
var input = '1e' + magnitude;
isSafe(input) && typeof eval(input) !== 'number';
@minitech
minitech / quiz-3.js
Last active December 17, 2015 19:59
// Put anything here to make the final assertion true.
;var isSafe = function(input) {
return /^\d+([.e]\d+)?$/.test(input);
};
if(typeof magnitude === 'string') {
var input = '1e' + magnitude;
isSafe(input) && typeof eval(input) !== 'number';
(function a() {
/* (function(package) {
* (function(a) {
* "use strict";
* var a\u005f = package;
* with(a_)
* this && a();
* })(a);
* })();
*/
<!DOCTYPE html>
<html>
<head>
<title>Simple tabbed menu</title>
<link rel="stylesheet" type="text/css" href="tabs.css">
</head>
<body>
<h1>Simple tabbed menu</h1>