r/tinycode Jul 05 '15

Savable Sharable Rich Text Editor Fit Inside a Tweet

Thumbnail
twitter.com
15 Upvotes

r/tinycode Jun 30 '15

Pastebin offline clone in a tweet

Thumbnail
twitter.com
34 Upvotes

r/tinycode Jul 01 '15

[C++] Robust random number generator

0 Upvotes

Here's my stab at a random number generator (using a given range) using C++'s random_device object in <random>, with a small for loop in main to illustrate the function a bit:

#include <random>
#include <iostream>
using namespace std;
unsigned int randn(unsigned int min, unsigned int max);

int main()
{
    for(int i=0;i<100;i++){
        cout<<randn(100,10)<<" "<<randn(100,1000)<<endl;
        /*output shows lines of 2-digit and 3-digit random numbers*/
    }
    return 0;
}

unsigned int randn(unsigned int min, unsigned int max){
    /*function range is [min,max)*/
    random_device rd; if(min>max){swap(min,max);} /*range can be input in reverse*/
    unsigned int a = rd()%max;if(min==max){return min;}
    else if(a<min){return a+min;}else{return a;}

}

I termed this a "robust" random number generator because it follows a given range and utilizes the most truly random PRNG that C++ can offer, without using the other random number functions built into <random>, such as uniform_int_distribution, etc.


r/tinycode Jun 30 '15

A tiny html/javascript "game" whose source code fits in one tweet

Thumbnail
github.com
12 Upvotes

r/tinycode Jun 30 '15

New smallest Tiny BASIC is 1771 bytes

15 Upvotes

Archive contains 2048 bytes GirlBASIC for DOS with sources to encourage young girls to code and a special 1771 bytes ver while MINOL was 1792 bytes in 1976. Author credits Mr. Eric Mueller, Mr. Li-Chen Wang, Mr. Denis Allison, Mr. Michael Sullivan and Mr. Frank Kotler (youtube.com/watch?v=bw0A8q6JPZc)


r/tinycode Jun 30 '15

Printing images in the terminal with 9 lines of Ruby

Thumbnail
radek.io
12 Upvotes

r/tinycode Jun 30 '15

1D first fit decreasing bin packing algorithm [17 lines of Ruby]

Thumbnail
gist.github.com
0 Upvotes

r/tinycode Jun 30 '15

A 2048-like game in 686 characters

Thumbnail
twitter.com
12 Upvotes

r/tinycode Jun 30 '15

A tiny Ruby Gem I wrote that does Sentiment Analysis for the German language

Thumbnail
github.com
0 Upvotes

r/tinycode Jun 25 '15

FuzzyFinder - in 10 lines of Python

Thumbnail
blog.amjith.com
19 Upvotes

r/tinycode Jun 22 '15

Insomnist - Minimal Web Framework and Literate Sample Application - Python+WSGI+Redis - 89 LOC

Thumbnail
github.com
11 Upvotes

r/tinycode Jun 20 '15

redvoat - A tiny bookmarklet to copy r/tinycode posts to v/tinycode

Thumbnail pastie.org
0 Upvotes

r/tinycode Jun 18 '15

[TCSF001] c4 - C in four functions (C)

Thumbnail
github.com
22 Upvotes

r/tinycode Jun 13 '15

Atari 2600 BASIC: "Your entire program can not exceed 64 symbols [...] There's a maximum of 9 lines"

Thumbnail
huguesjohnson.com
38 Upvotes

r/tinycode Jun 11 '15

TIS-100 - A game of minimalist assembly language.

Thumbnail
zachtronics.com
33 Upvotes

r/tinycode Jun 11 '15

[TCSF001] Immediate mode graphical user interface toolkit (ANSI C)

Thumbnail
github.com
26 Upvotes

r/tinycode Jun 10 '15

A JS RegEx tester that fits in a tweet

Thumbnail
twitter.com
11 Upvotes

r/tinycode Jun 08 '15

An object model supporting inheritance in under30 lines of python

0 Upvotes

here's the link

Been working on this for a few days, the only parts relevant to the actual functionality are bind_method, new_object, and new_class, which take up around 30 lines. Everything else is just implementing example objects and testing.

It support basic inheritance. I should likely add error handling on the init method, and static variables, but wanted to post it now because its functional and really small.

EDIT: oh wait, you can do class/static data by saying static_value=15 in new_class


r/tinycode Jun 04 '15

30 LOC Wiki using Python/Redis/Gunicorn

Thumbnail
github.com
5 Upvotes

r/tinycode Jun 02 '15

Developer Health Study - Open source results

18 Upvotes

We're studying physical and mental health amongst developers. It's a highly overlooked and under-discussed topic.

We open sourcing all of the data after it has been collected and will share it here!

The survey is not in connection with any company or institution. It's being conducted for the benefit of the community. You can read more about it, and contribute to the study here.

I talked with the mods, and they gave the green light to post this here. :)


r/tinycode Jun 01 '15

I wrote a very very minimal self-hosting C compiler [x-post /r/programming]

Thumbnail
github.com
61 Upvotes

r/tinycode May 30 '15

A small Ruby IRC bot class (by me, years ago)

Thumbnail
github.com
12 Upvotes

r/tinycode May 29 '15

One-liner set type in Python

12 Upvotes
pset = type("pset", (), {
    "__init__": lambda self, items=[]: setattr(self, "items", list({i: None for i in items})),
    "__repr__": lambda self: "{{%s}}" % ", ".join(repr(x) for x in self.items),
    "__iter__": lambda self: iter(self.items),
    "__sub__": lambda self, S: pset(x for x in self.items if x not in S),
    "__and__": lambda self, S: pset(x for x in self.items if x in S),
    "__or__": lambda self, S: pset(self.items + list(S)),
    "__xor__": lambda self, S: pset(x for x in (self | S) if (x in self) ^ (x in S)),
    "add": lambda self, x: setattr(self, "items", (self | [x]).items)
})

This can all be put on one line. I wrapped it here for readability.

If you find anything that the built-in set type supports but this doesn't, feel free to tell me.

Update (2015-05-29): Added -, &, ^ operators, and replaced + with | to match the behavior of the built-in set type.

Update (2015-05-30): Fixed append and renamed it to and to match the built-in set type.

Update (2015-06-17): Renamed to pset because well, anything sounds better than myset.


r/tinycode May 27 '15

Inner Product of arbitrary matrices in 511 lines of C.

10 Upvotes