Create a gist now

Instantly share code, notes, and snippets.

@rauchg /
Last active Jan 15, 2018

What would you like to do?


Since Twitter doesn't have an edit button, it's a suitable host for JavaScript modules.

How to use

Source tweet:

const leftPad = await requireFromTwitter('712799807073419264');
console.log(leftPad(1, 5));      // '00001'
console.log(leftPad(1234, 5));   // '01234'
console.log(leftPad(12345, 5));  // '12345'

Running this example

# populate `twitter-config.json` with your API tokens
$ npm install
$ npm test
import { babel } from './package';
import { transform } from 'babel-core';
import { decodeHTML as decode } from 'entities';
import Twit from 'twit';
// edit twitter-config.json first
const twit = new Twit(require('./twitter-config'));
export default async function requireFromTwitter (id) {
const tweet = await twit.get(`/statuses/show/:id`, { id });
if (tweet.errors) throw new Error(`Cannot find module '${id}'`);
const { text } =;
const exports = {};
eval(transform(decode(text), babel).code);
return exports.default;
"name": "require-from-twitter",
"version": "0.0.1",
"description": "require(), but from a tweet",
"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"
"babel": {
"presets": [
"plugins": [
"scripts": {
"test": "babel-node test"
import requireFromTwitter from './';
.then((leftPad) => {
console.log(leftPad(1, 5));
console.log(leftPad(1234, 5));
console.log(leftPad(12345, 5));
}, (err) => console.error(err.stack));
"consumer_key": "",
"consumer_secret": "",
"access_token": "",
"access_token_secret": ""

karan commented Mar 24, 2016




rauchg commented Mar 24, 2016

Mandatory disclaimer: this is not serious and not safe.

@rauchg what?! I just updated all of my production apps to it... don't delete your tweet


xero commented Mar 24, 2016

you had me at eval

sphvn commented Mar 24, 2016

How do we solve deleted tweets?

aroman commented Mar 24, 2016

i love the internet

@sphvn replicate via RTs + backend to walk the RT DAG for a non-deleted status

also, safe-eval.

requireFromTwitter(status, [context])

This is absolutely genius!



NamPNQ commented Mar 24, 2016


eul721 commented Mar 24, 2016

Dude you're amazing. Will use 10/10.
Keep up the good work.

With twitter 140 char limit going away, it will be next platform for js libs 😆

quite often i click through on these kinds of things and it's you, sir.

Man, with a webpack loader we could require from Twitter at build time!

daysv commented Mar 24, 2016

It doesn't work in China. 😂


methou commented Mar 24, 2016

@daysv I believe their people can make most out of Weibo, which doesn't have 140 words limit.

Mandatory disclaimer: this is not serious and not safe.

This can be made somewhat serious and somewhat safe with a javascript transpiler for example

A lot of mandatory packages actually fit into the 140 character limit.

Deleted tweets? No problem:

Kudos for the Brilliant idea.
Guess a lot of other mandatory packages will start doing this..

I had to pause for a second until i fully got it. bravo. hahah

Art4 commented Mar 24, 2016

"If you have a bad idea there is always an idiot who implements it."

It doesn't work in China. 😂

@daysv we can build a mirror 😂

justim commented Mar 24, 2016

Next level cloud hosting 💯

l1x commented Mar 24, 2016

Finally twitter gets a great use case, have you seen the impact on the price of the shares yet??

Now we need a tweet package manager that will keep a record of all the tweet modules id's and assign them a module name :)

I bow to you!

Next-level social engineering

pmuens commented Mar 24, 2016

That's genius!

Incredible, there is a complete tweet package manager:

Until someone removes a tweet and breaks the Internet.

Ehekatl commented Mar 24, 2016



cu39 commented Mar 24, 2016


Bye bye npm, there's a new big dog in town

pmolina commented Mar 24, 2016

Absolutely brilliant!

pluma commented Mar 24, 2016

Can we have a require hook for this so we can just require('twitter:712799807073419264') pls?

I need this for a production app. Pls fix ASAP.

birdy- commented Mar 24, 2016

Leftpad INC. will ask twitter to delete your tweet. You'll break the Internet.

Hi @rauchg, this is David from Rauchg Global Worldwide, LLC. I was wondering if you'd consider switching your Twitter handle so that we can use it for an upcoming marketing campaign.

Listen, I don’t mean to be a dick about it, but it’s a registered Trademark in most countries around the world and if you actually release any tweets from @rauchg, our trademark lawyers are going to be banging on your door and taking down your accounts and stuff like that — and we’d have no choice but to do all that because you have to enforce trademarks or you lose them.

dbergey commented Mar 24, 2016

I propose the nomenclature "twackages" for these modules

BillyWM commented Mar 24, 2016

I'd love to use this but according to your example it depends on async/await, which needs Babel transpiling, which depends on line numbers, which depends on classic Leftpad (tm) (c) Kik Interactive.

Can you write me a self-hosting leftpad implementation? Thanks

Pilfer commented Mar 24, 2016

This is old technology. I've been instagramming QR codes containing my JS libs for years now. It's secure, too. I just use the hashtag "#MyProjectName", and the code inside the QT code automagically gets included and evaluated on my prod box - 100% safe. Instagram has the best CDN, too, so you get maximum code availability in the cloud for free!

maliqq commented Mar 24, 2016


Xiphe commented Mar 24, 2016

How do we solve deleted tweets?

You should definitely bundle dependent tweets into yours before publishing a new version to twitter!

fengmk2 commented Mar 24, 2016

require-from-weibo instead in China. :)

drac commented Mar 24, 2016

@daysv nothing works in China. 😄

thebouv commented Mar 24, 2016

I'm with dbergey here. twackages or gtfo.

What happens when Twitter decides to reassign my tweet to someone else??

Brilliant. Also, twackages FTW.

Warning!'s link to "call function by name" links to /#.. did someone remove this? I can't call my functions!

@ymschaap That is the best thing I have ever seen today. Better start updating production code ASAP.

adizam commented Mar 24, 2016

+1 twackages.

And the next major outage will be labeled The Twacalpyse

So... I like this a lot. I think I would only use it for user password storage, however. Don't see any other good uses... ;)

emonti commented Mar 24, 2016

why stop with code? boasting an impressive 140 character limit, twitter is also an excellent option for key storage up to 1024-bit keys!!!

Correction: I mean 1120-bit keys. That's a thing right?

josser commented Mar 24, 2016

What about splitting bigger modules into 140-char chunks?


Cameri commented Mar 24, 2016

RT is the new fork?

jsen- commented Mar 24, 2016

We should ask Pirate Bay to host npm stuff. I can imagine the reply to the Kik's lawyer ... 😂

Flet commented Mar 24, 2016

webpack loader plz :)

Please implement requireFromGist so I can require this gist to require left-pad



rauchg commented Mar 24, 2016

@bleonard it was C.D. Cooney

brilliant!! 😄 ❤️

you guys are too much... lol

I'm surprised no one has mentioned IPFS as a solution to it getting deleted.

This is.... Amazing. WELL DONE

Who needs testing in 140 character piece of code anyway?

wow.....this changes how we see the cloud.

pengx17 commented Mar 25, 2016

Time for a TPM (Twitter Package Manager)

You, Sir, have won the internet!

Reminds me of (who needs NPM anyway?)

I took this a little more seriously, I think this might actually help out:

Create a file with a list of one-liners from anywhere (gist, github raw file, etc). It will pull them once into a directory and expose them via an index.js.

yisibl commented Mar 25, 2016

It doesn't work in China. 😂

fordnox commented Mar 25, 2016

waiting for 'require from DNS TXT record'

What about the simple :


Looks safe

Excellent. I just hosted all my shell scripts on Twitter and now hashtag "!" is trending

rgaidot commented Mar 26, 2016


this relies on centralized infrastructure operated by a corporation!
The only safe way to do this is to use my package ... require-from-torrent.



What about require-from-blockchain? That cannot be deleted or taken down. Never ever!

This is great. Just pushed to production, thanks! Never using NPM again.

is it possible to use inside the tweet and then require functions from other tweets?

tsia commented Mar 31, 2016

how about a google cache fallback for deleted tweets?

vrunoa commented Apr 1, 2016

calsioro commented Apr 7, 2016

Port it to rebmu!
Actually useful!

awnumar commented May 7, 2016

This is actually pretty clever. Inspired me to make a python version:

So.... basically like 25-50% of sindresorhus' modules can use this, no problem. Right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment