
Require-from-Twitter - uptown
https://gist.github.com/rauchg/5b032c2c2166e4e36713
======
michael_storm
This is the Internet of Things for code. This is wonderful.

This is also probably a snarky shot at npm [1], for those who lack context.

[1]
[https://news.ycombinator.com/item?id=11340510](https://news.ycombinator.com/item?id=11340510)

~~~
Rauchg
My goal was for it to be entertaining and educational[1]. I love npm (which
made this possible to begin with!)

[1] ES6 features (arg defaults, destructuring, modules, template literals,
String.prototype.repeat), babel configuration and runtime compilation, async /
await

~~~
tstrimple
I feel like require-from-twitter really helps enforce the Unix philosophy.
It's hard to write modules with multiple responsibilities in 140 characters.

~~~
kristianp
I wonder how large a system could be created using nested tweets of js. Needs
versioning though.

~~~
taneq
As large as you want:
[https://users.soe.ucsc.edu/~jpagnutt/Elevator_Pitch.pdf](https://users.soe.ucsc.edu/~jpagnutt/Elevator_Pitch.pdf)
(PDF warning)

~~~
ntumlin
This does need a warning, but PDF isn't the reason.

~~~
yxlx
What does the link do?

~~~
55555
It opens your mind until your brain falls out.

------
spriggan3

        >   "dependencies": {
        >    "babel-preset-stage-0": "6.5.0",
        >    "babel-preset-es2015": "6.6.0",
        >    "babel-runtime": "6.6.1",
        >    "babel-plugin-transform-runtime": "6.6.0",
        >    "babel-cli": "6.6.5",
        >    "babel-core": "6.7.4",
        >    "twit": "2.2.3",
        >    "entities": "1.1.1"
        >    },
    

The problem right here. Just to run a script you now need to import a whole
third party language runtime ? what other language does pull this kind of
stunt ? Javascript is madness.

~~~
dc2
Not really. Usually people include them as "devDependencies", and Babel will
transpile to ES5 before publishing.

I think Guillermo simply didn't care. Because it's not important for a joke.

\---

Uninformed presumptions are madness.

~~~
rubber_duck
Umm isn't babel-runtime an actual third party language runtime dependency
(like polyfills and shared code for stuff like async) ?

~~~
j_jochem
I wouldn't really call it a dependency since it gets inlined with the shipped
code.

------
yAnonymous
I'm currently talking to investors to start a business around this. Please
don't delete it.

~~~
cdnsteve
Maybe this will make Twitter finally profitable?

~~~
giancarlostoro
Twitter is known for deleting twitter accounts when they get reports of tweets
though.

------
martin-adams
Maybe to make this more reliable, you should retweet the module first, then
require your clone.

~~~
thoughtpalette
Thanks for providing some morning entertainment. Love this comment.

------
rburhum
Hi. I don't know how to program (otherwise I would do this myself), but can
you port this to Google+ please? My office blocks twitter. Thanks!

------
melvinmt
Why is this not a npm module yet? Name suggestion: kik2

~~~
capitalsigma
Not enough Twitter, can't you tell that's the problem here

------
cmpolis
Tangentially related(tweet sized js) and an awesome project:
[https://t.d3fc.io/](https://t.d3fc.io/) is a collection of d3 visualizations
from tweets. The code is cryptic on first inspection, but if you look at the
sandbox setup, it starts to make sense and 140 chars is a wonderful
constraint. eg:
[https://t.d3fc.io/status/694991319052103680](https://t.d3fc.io/status/694991319052103680)

------
philmander
Require from stack overflow?

require('how do I prepend spaces to a string')

~~~
JBiserkov
Autocomplete from stack overflow:
[https://news.ycombinator.com/item?id=11335766](https://news.ycombinator.com/item?id=11335766)

------
logn
A developer gets upset at unilateral actions by NPM resulting in a project
being renamed or taken down unnecessarily (potentially breaking builds). So
this dev decides to take down all their projects, as a sort of protest. This
breaks a lot of builds. The JavaScript community thinks a clever solution is
utilizing Twitter as part of the build process? Because then everything would
be dependent on Twitter not adding an "edit tweet" button...

~~~
pandler
> The JavaScript community thinks a clever solution is utilizing Twitter as
> part of the build process?

The JavaScript community thinks a hilarious, tongue-in-cheek solution is
utilizing Twitter as part of the build process.

FTFY

~~~
logn
Oops. I retract my comment and denounce myself.

------
aioprisan
Pretty comical. I bet folks would actually use this to some extent, without
realizing that Tweets can also be deleted.

~~~
melvinmt
> without realizing that Tweets can also be deleted.

Yep, _just_ like NPM modules.

~~~
softawre
> also

------
spotman
the next version should have a require from #hashtag, so that it can be fault
tolerant, and would last longer when lawyers request a takedown!

------
m_mueller
> // ES6 leftPad

and he even had space for a comment in there....

------
franciscop
For everyone who doesn't know it, there's a project called
[http://140byt.es/](http://140byt.es/) compiling many code snippets that fit
in a tweet (;

There was also a clever trick to compress/uncompress ascii text by using
base[huge number] or something like that (full unicode) so it could be
uploaded to twitter, but I don't remember the exact number

~~~
Retr0spectrum
[https://github.com/ferno/base65536](https://github.com/ferno/base65536)

~~~
franciscop
Awesome! thanks, also here's the reasoning from the Why? [1]

> I wanted people to be able to share HATETRIS replays via Twitter.

> Twitter supports tweets of up to 140 characters. "Tweet length is measured
> by the number of codepoints in the NFC normalized version of the text."

[1]
[https://github.com/ferno/base65536#why](https://github.com/ferno/base65536#why)

------
jjawssd
Next up: require from bitcoin blockchain

------
cphoover
this would actually be an interesting coding challenge and experiment to see
if something could be built worthwhile in modules limited to no larger than
140 characters.

~~~
HappyTypist
Not a good constraint. Just make each tweet module export a string, and
concatenate them and eval().

~~~
m_mueller
well, that could be easily solved by prohibiting eval?

~~~
nostrademons
Concatenate them and then run them through Babel...

------
rcthompson
Make sure you scroll down and read the mandatory disclaimer before commenting
on the merits of this approach.

------
ChikkaChiChi
Github could easily solve this problem:

If a repo meets certain criteria in licensing, create the ability to "Static
Publish" a release. This feature communicates that the version repo is the
public's and cannot be removed by the individual or team. Github also enters
the agreement that if there is ever a need to "move" the version due to
copyright infringement, it provides either aliasing or sooner sort of
notification and time bomb before it goes offline.

If this were done, folks could be in the know about which packages and
dependencies are at risk, so they enter into the install with their eyes wide
open.

------
homero
Shouldn't have voted against increasing character count, we could've had a
free cdn

------
0x7fffffff
Well there you go. Problem solved.

------
t1amat
Standardized modules like this are exactly what the node.js-stack bot herding
community has needed!

On the plus side: if you saw this dependency in a module you were looking at
you would know to think twice.

------
anotherevan
There's still another eight days until April first.

------
sorenjan
There's also a package manager for it: [http://require-from-
twitter.github.io/](http://require-from-twitter.github.io/)

> require-from-twitter is the core code for the tweet package manager. Our
> beta version has only one dependency: npm. But we're working hard on adding
> more dependencies as quick as possible.

------
olegp
Along similar lines, I made it possible to use NPM packages in the browser
without a build step or server:
[https://github.com/olegp/bpm](https://github.com/olegp/bpm)

More info here: [https://meetabit.com/talks/37](https://meetabit.com/talks/37)

------
peterkelly
What we really need is require-from-stackoverflow

------
amptorn
One of the interesting side-effects here is that while it encourages you to
write very small packages, it also strictly caps the maximum number of
packages which you can add as dependencies of your own package. There's only
so many `require` calls you can fit in a Tweet.

------
mooreds
Twitter finally has a business model! Who knew that source code hosting would
be the killer app?

------
howeyc
I know this is supposed to be funny, BUT if you vendored and kept a local copy
in you're build environment, you wouldn't have to worry if the tweet gets
deleted.

This is the lesson I see noone talking about.

Of course, using a tweet as a source for a library is silly.

------
escoundel
TDD - Twitter Driven Development

------
andremendes
Well, twitter staff was saying they'd last at least another ten years, would
NPM?

------
amelius
Filesystem interface to Twitter:

[http://softwaretechnique.jp/DownLoad/twfs_en.html](http://softwaretechnique.jp/DownLoad/twfs_en.html)

This is probably more generic than the project discussed here.

------
plugnburn
Why not just use anonymous gists in conjunction with RawGit CDN?

Unique IDs, no way to change or delete (since the gists are anonymous), served
right out-of-the-box with a proper content type from cdn.rawgit.com.

------
ikeboy
For deleted tweets:

On every fetch, submit the tweet to archive.org and archive.is if not already
there. If tweet is deleted, fetch from there instead.

------
bagnus
I'm impressed no one has posted their own version for a different language.

------
nivertech
twitter doesn't have an edit button, but it does have the delete button ;)

~~~
eric_h
martin-adams solved this problem:

[https://news.ycombinator.com/item?id=11352113](https://news.ycombinator.com/item?id=11352113)

------
wallzz
can someone explain what is this ? I really have no idea

~~~
joeblau
This person wrote a tweet and the tweet has code[1]. This snippet in
JavaScript allows you to import that code into your code as a module. I think
this is trolling on state of the Node community because over the previous few
days, people have found some pretty interesting dependency architecture[2].

[1] -
[https://twitter.com/rauchg/status/712799807073419264](https://twitter.com/rauchg/status/712799807073419264)

[2] -
[http://www.theregister.co.uk/2016/03/23/npm_left_pad_chaos/?...](http://www.theregister.co.uk/2016/03/23/npm_left_pad_chaos/?mt=1458720804410)

------
fallenshell
Let's host systemd on Twitter.

------
progx
Lol YMMD

------
cphoover
funny :)

------
dbpokorny
If you can get a good toolkit for writing a GLR parser, then people will write
their own tokenizers, BNF formal grammars, and plug it into your parser. It
would take a single person about two to six weeks to get something thoroughly
polished in JavaScript along the lines of what is described. However I think
that without some form of centralization, (perhaps a subreddit? idk) it will
be difficult for the standardization and namespace organization process to
take place. If it is just one person, there is no question of standardization;
if it is multiple people, the question of who is in charge of the namespace
becomes relevant. Who is in charge of the namespace in this particular
experiment?

------
chris_wot
npm over twitter? A site populated by trolls and spammers. What could
_possibly_ go wrong?

