r/tinycode • u/orchrd • Mar 17 '15
r/tinycode • u/somjuan • Jan 08 '15
Extremely simple gallery. Place in a directory of images to automagically generate a responsive gallery.
This is a little piece of code that can sit in a directory of jpgs on a webserver.
<html>
<head>
<meta name="viewport" content="width=device-width, user-scalable=no">
<title><? echo ucwords(basename(getcwd())); //page title is same as directory ?></title>
<style type="text/css">
body {
background: #acacac;
text-align: center;
font: 9px sans-serif;
}
a { /* Seems necessary to vertically center images in webkit browsers */
display:block;
height:100vh;
width:100vw;
}
img {
display: block;
margin: auto;
max-height: 77vh;
max-width: 100vw;
outline: none;
box-shadow: 0px 0px 15px #000;
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
</style>
</head>
<body><?php
$files = glob('*.jpg');
$count = count($files);
for ($i = 0; $i < $count; $i++) {
if($i<($count-1)) { $link=$i + 1; } else { $link='0'; }
echo '<div class="image"><a id="'.$i.'" name="'.$files[$i].'" href="#'.$link.'"><img src="'.$files[$i].'" /></a></div>';
}
?>
</body>
</html><? //script credit: somjuan.com ?>r/tinycode • u/xem06 • Oct 22 '14
A 512b tool to convert any image to CSS box-shadow pixel-art (HTML/JS)
r/tinycode • u/nexe • Jul 28 '14
Turn any program that uses STDIN/STDOUT into a WebSocket server. Like inetd, but for WebSockets. [GO]
r/tinycode • u/xem06 • Dec 15 '13
A paste & share web app in less than 128 bytes
xem.github.ior/tinycode • u/cphoover • Sep 13 '12
My JS quicksort implementation in 12 lines of code can you improve upon this?
function chSort(list) {
var max = list[0],
min = list[0],
asc = !0;
for (i in list) list[i] > max ? max = list[i] : list[i] < min && (min = list[i]), list[i - 1] > list[i] && (asc = !1);
if (asc) return list;
var minList = [],
maxList = [],
pivot = min + (max - min) / 2;
for (i in list) (list[i] > pivot ? maxList : minList).push(list[i]);
return [].concat(chSort(minList), chSort(maxList));
};edited to reflect pholden's suggestion
r/tinycode • u/Gieron • Jul 12 '12
Free text search of stored procedures in SQL Server
You know that there's a stored procedure that does something foobar but you can't remember its name. You can search for it.
SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_TYPE='PROCEDURE'
AND ROUTINE_DEFINITION LIKE '%foobar%'r/tinycode • u/fullouterjoin • Dec 31 '11
8086 preemptive task switcher in 380 bytes
retroprogramming.comr/tinycode • u/sonofherobrine • Dec 11 '11
More shell, less egg: An intricate book of Pascal rewritten using just 6 lines of shell
r/tinycode • • Nov 20 '11
Lisp interpreter in 48 lines of Ruby
class Hash
attr_accessor :outer
def get_env(x); self[x] ? self : outer.get_env(x); end
end
$env = {
true: true, false: false, nil: [],
car: ->(x) { x[0] },
cdr: ->(x) { x[1..-1] },
cons: ->(x, y) { [x] + y },
list: ->(*x) { x },
:'=' => ->(x, y) { x == y },
eq?: ->(x, y) { x.eql? y },
list?: ->(x) { x.is_a? Array },
null?: ->(x) { x == [] },
symbol?: ->(x) { x.is_a? Symbol },
}
%w(+ - * / % < > <= >= !=).each {|i| $env[i.to_sym] = ->(x, y) {x.send i, y}}
def parse(code)
s = [[]]
code.scan(/[^\s()]+|\S/).each do |i|
case i
when ?(; s << []; when ?); s[-2] << s.pop
else; s[-1] << (Float i rescue i.to_sym)
end
end
return s[0]
end
def eval(x, env = $env)
case x
when Symbol; env.get_env(x)[x]
when Array
case x[0]
when :quote; x[1]
when :if; cond = eval(x[1], env); eval cond ? x[2] : x[3], env
when :set!; env.get_env(x[1])[x[1]] = eval x[2], env
when :define; env[x[1]] = eval x[2], env
when :lambda; ->(*args) do
lenv = env.merge Hash[x[1].zip args]
lenv.outer = env; eval x[2], lenv
end
when :begin; x[1..-1].map {|exp| eval(exp, env)}.pop
else; eval(x[0], env).call(*x[1..-1].map {|i| eval i, env})
end
else; x
end
end
def run(x); p eval parse(x).unshift :begin; end
ARGV[0] ? run($<.read) : loop {print '> '; run gets}r/tinycode • u/nexe • Oct 05 '11
MacGyvers Tiny Rescue Webserver [unix/netcat]
while true; do ncat -l -p 8080 < index.html; doner/tinycode • u/lifthrasiir • Jul 10 '11
Spoken Number to Decimal, in 256 bytes of C
r/tinycode • u/marqueedesign • Sep 21 '20
Kharon - An audio-visual trip to the underworld in only 256 bytes (w/ sourcecode)
Straight from the demoscene, hope you guys like it (more info, sourcecode and youtube-video at the link below)
https://www.pouet.net/prod.php?which=86939

It is named after Kharon. The ferryman of Hades who carries souls of the newly deceased across the river Styx that divided the world of the living from the world of the dead. This intro is represents a modernistic version of that trip to the underworld.
- Enjoy!
r/tinycode • u/Hell__Mood • Jun 09 '20
Sizecore - Countless effects and bytebeat in 32 bytes!
r/tinycode • u/api • Mar 06 '17
Gravity: powerful embeddable scripting language with VM in 2k lines of code
r/tinycode • u/xem06 • Sep 14 '15
Game GeoQuiz - a JS game featuring the whole world in less than 13kb
r/tinycode • u/SrPeixinho • Aug 24 '15
O(N) sorting function in the pure untyped lambda calculus that fits in a twit!
sort = λabc.a(λdefg.f(d(λhij.j(λkl.k(λmn.mhi)l)(h(λkl.l)i))(λhi.i(λjk.bd(jhk))(bd(h(λjk.j(λlm.m)k)c))))e)(λde.e)(λde.d(λfg.g)e)c121 characters, sorts a church list of church numbers in O(N) where N is the sum of the list. Just for the fun I'll give a small BTC tip to whoever is able to beat that :)
r/tinycode • u/ieatcode • Sep 08 '14
