A site that went kinda viral that lets you put Bernie Sanders in places

Overview

Bernie In Places

Deploy

An app that accidentally went viral! Read the story in WIRED here

Install

First, create a python virtual environment, and install all of the depenedencies.

python3 -m venv ve
source ve/bin/activate
pip install -r requirements.txt

Next, create a google cloud platform project with Street View Static API access (you will need a credit card to set this up)

https://console.cloud.google.com/apis/library/street-view-image-backend.googleapis.com

Set the following environment variables by adding the following lines to your .bash_profile, .zshrc, etc:

export API_URL='https://maps.googleapis.com/maps/api/streetview'
export KEY='YOUR-MAPS-STREETVIEW-KEY'
export SECRET='YOUR-GOOGLE-SECRET'

You might want to rename the variables to not conflict with existing ones.

Running

To run the web application locally

flask run

and, visit http://localhost:5000

For production deployment, I used gunicorn.

Since the site is down now, you can also use images.py as a command-line bernie meme creation tool with

python images.py 'FILENAME.jpg' 'LOCATION' 

If you plan on exceeding the rate limits or call cap, make sure to sign the url with -s or --sign (this also happens by default). If you're just doing this for fun, or want to look at a request url without the signature, you can use -n or --no-sign.

Procfile and Aptfile are required to deploy with Heroku

Contribute!

I'd like to make a self-sustaining version of this site that automatically tracks crowdfunding vs api/other site costs and pulls core functionality when funding dips below cost, bringing it back when funding returns. Check out the idea and contribute to the discussion!

Also join me in Discussions to discuss the future of the site. We'll be maintaining an aesthetically and functionally identical version of the original viral site, and another souped-up version with all the features requested. Backend optimizations like caching can go in the original version. Still trying to decide which version should be main

PRs and issues welcome!

Please don't deploy without permission! I'm working on figuring out the proper licensing and attributions for others to be able to deploy.

Licensing

This site is licensed under the GNU Affero General Public License

THANKS

This has been insane. 9,849,938 Bernie memes were created during the lifetime of this site!

Comments
  • Licensing

    Licensing

    I'm looking for some insight on how to license this thing. I'd like to be as open as possible with it, open source is awesome and I want others to be able to deploy this site if they want to. However, I have a few preferences (none of which are set in stone) that I'd like to use to guide which license to pick. If anyone has experience with this kind of thing, I'd love your insight!

    • I'd like credit for creating the original site if possible
    • I don't love the idea of others making a version of the site with ads and deploying it for themselves
    • I want to encourage open source contribution and creativity
    • I want to protect myself from an elasticsearch-type-situation
    help wanted question 
    opened by nicksawhney 9
  • What's Next?

    What's Next?

    I'm thinking we maintain a relatively original-looking version of the site, and have another branch where we can go absolutely wild with everything people want to contribute -- styling, different images and overlays (like people have been asking for on twitter), changing image placement, all the rest! That version could become a more general open-source web based meme creation app. Would love anyone's thoughts!

    (via @nicksawhney https://github.com/nicksawhney/bernie-sits/pull/8#issuecomment-766295945)

    Keep the site up? I wonder if there's some free way of keeping this up to get to 10M memes

    • @heremaps @Tafkas ?
    • leaflet? https://github.com/Leaflet/Leaflet or mapbox @mourner
    • google maps? @jpoehnelt
    opened by JackHowa 8
  • TypeError: 'NoneType' object is not subscriptable

    TypeError: 'NoneType' object is not subscriptable

    $ flask run

    • Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
    • Debug mode: off
    • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) 127.0.0.1 - - [25/Jan/2021 19:37:24] "GET / HTTP/1.1" 200 - 127.0.0.1 - - [25/Jan/2021 19:37:25] "GET /favicon.ico HTTP/1.1" 404 - requesting from https://maps.googleapis.com/maps/api/streetview?location=new+york&size=640x640&key= 403 [2021-01-25 19:37:34,720] ERROR in app: Exception on / [POST] Traceback (most recent call last): File "/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functionsrule.endpoint File "/home/aswin/Documents/bernie-sits/app.py", line 18, in login image = add_bernie(img_bytes) File "/home/aswin/Documents/bernie-sits/images.py", line 75, in add_bernie alpha_l * l_img[y1:y2, x1:x2, c]) TypeError: 'NoneType' object is not subscriptable 127.0.0.1 - - [25/Jan/2021 19:37:34] "POST / HTTP/1.1" 500 -
    opened by masapasa 6
  • Add recaptcha security

    Add recaptcha security

    Sorry to hear your fame is costing you. Thought recaptcha might be helpful to monitor in case you're getting spam. (Also it's a pretty interesting story in and of itself.) Anyway, if you create a site key, you should be able to monitor this better. Let me know if you need help once you get up and running.

    https://developers.google.com/recaptcha/docs/v3#top_of_page

    You may also need to apply for a higher rate of traffic. This is a link for that https://developers.google.com/recaptcha/docs/faq#are-there-any-qps-or-daily-limits-on-my-use-of-recaptcha

    • it's mostly just monitoring traffic and potentially malicious requests
    • to do more complex logic and prevent responses, it'd take a backend to verify if you're interested @nicksawhney https://dev.to/kumar_abhirup/implementing-google-recaptcha-with-react-and-node-js-1jgf

    Screen Shot 2021-01-21 at 23 17 54 Screen Shot 2021-01-21 at 23 20 08

    opened by JackHowa 4
  • Breakdown on API Costs

    Breakdown on API Costs

    Hi, Can you give a breakdown of the API cost from google. When I checked the pricing it seems that Streetview API would cost 5.6 dollars per 1000 requests [ $56K USD for 10 million requests]. Also, can you give a breakdown of how much you have got via public donations? Putting these numbers publically can probably help increase trust and further receive funds to help you breakeven in case donations didn't match the costs

    opened by Jeevantk 3
  • installation tips

    installation tips

    Hi,

    I made a fresh PR, since my last was made through the web and this seemed simpler. If you are actively working on this now, feel free to just take any of my copy.

    opened by mrenoch 3
  • You can use CSS to overlay bernie

    You can use CSS to overlay bernie

    There's no need to do any computation server-side to overlay bernie, or use numpy/cv etc.

    A CSS stylesheet can overlay the bernie.png image directly on top of a div that holds the result from google maps. I'll work on a PR on this in the evening if no one else gets to it.

    opened by astrowonk 3
  • checks location input for empty search/white space

    checks location input for empty search/white space

    An empty search was causing an internal server error, was able to check input before running the API request (which should help with requests/costs). Also made get_image() return None for a non-200 response code.

    opened by aykae 3
  • Installation tips

    Installation tips

    Hey,

    Amazing work!

    Non-python folks who may want to run this locally may be unfamiliar w/ installation. Could alleviate direct load on your installation.

    Cheers!

    opened by mrenoch 2
  • Basic mobile setup

    Basic mobile setup

    • thought the downloaded image was cool and the idea hilarious
    • had a hard time seeing on mobile though
    • setup responsive font size based on the document size (rem)

    before mobile:

    Screen Shot 2021-01-22 at 00 08 34

    after mobile:

    Screen Shot 2021-01-22 at 00 08 47

    opened by JackHowa 2
  • App fails to load in Heroku

    App fails to load in Heroku

    I just attempted to simply deploy to Heroku from the Github page and faced the following issue right away.

    I created my API key in APIs & Services, restricted the key to Street View Static API leaving application restrictions to None. I grabbed my Street View Static API secret from: https://console.cloud.google.com/google/maps-apis/credentials

    Jan 26 11:42:08 my-heroku-app heroku/web.1 Starting process with command `gunicorn --timeout=0 app:app`
    Jan 26 11:42:12 my-heroku-app heroku/web.1 State changed from starting to up
    Jan 26 11:42:13 my-heroku-app app/web.1 [2021-01-26 19:42:13 +0000] [9] [ERROR] Exception in worker process
    Jan 26 11:42:13 my-heroku-app app/web.1 Traceback (most recent call last):
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    Jan 26 11:42:13 my-heroku-app app/web.1     worker.init_process()
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
    Jan 26 11:42:13 my-heroku-app app/web.1     self.load_wsgi()
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
    Jan 26 11:42:13 my-heroku-app app/web.1     self.wsgi = self.app.wsgi()
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
    Jan 26 11:42:13 my-heroku-app app/web.1     self.callable = self.load()
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
    Jan 26 11:42:13 my-heroku-app app/web.1     return self.load_wsgiapp()
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
    Jan 26 11:42:13 my-heroku-app app/web.1     return util.import_app(self.app_uri)
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
    Jan 26 11:42:13 my-heroku-app app/web.1     mod = importlib.import_module(module)
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
    Jan 26 11:42:13 my-heroku-app app/web.1     return _bootstrap._gcd_import(name[level:], package, level)
    Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
    Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
    Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
    Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
    Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
    Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/app.py", line 3, in <module>
    Jan 26 11:42:13 my-heroku-app app/web.1     import cv2
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/cv2/__init__.py", line 5, in <module>
    Jan 26 11:42:13 my-heroku-app app/web.1     from .cv2 import *
    Jan 26 11:42:13 my-heroku-app app/web.1 ImportError: libGL.so.1: cannot open shared object file: No such file or directory
    Jan 26 11:42:13 my-heroku-app app/web.1 [2021-01-26 19:42:13 +0000] [9] [INFO] Worker exiting (pid: 9)
    Jan 26 11:42:13 my-heroku-app app/web.1 [2021-01-26 19:42:13 +0000] [10] [ERROR] Exception in worker process
    Jan 26 11:42:13 my-heroku-app app/web.1 Traceback (most recent call last):
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    Jan 26 11:42:13 my-heroku-app app/web.1     worker.init_process()
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process
    Jan 26 11:42:13 my-heroku-app app/web.1     self.load_wsgi()
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
    Jan 26 11:42:13 my-heroku-app app/web.1     self.wsgi = self.app.wsgi()
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
    Jan 26 11:42:13 my-heroku-app app/web.1     self.callable = self.load()
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
    Jan 26 11:42:13 my-heroku-app app/web.1     return self.load_wsgiapp()
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
    Jan 26 11:42:13 my-heroku-app app/web.1     return util.import_app(self.app_uri)
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 358, in import_app
    Jan 26 11:42:13 my-heroku-app app/web.1     mod = importlib.import_module(module)
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
    Jan 26 11:42:13 my-heroku-app app/web.1     return _bootstrap._gcd_import(name[level:], package, level)
    Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
    Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
    Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
    Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
    Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
    Jan 26 11:42:13 my-heroku-app app/web.1   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/app.py", line 3, in <module>
    Jan 26 11:42:13 my-heroku-app app/web.1     import cv2
    Jan 26 11:42:13 my-heroku-app app/web.1   File "/app/.heroku/python/lib/python3.6/site-packages/cv2/__init__.py", line 5, in <module>
    Jan 26 11:42:13 my-heroku-app app/web.1     from .cv2 import *
    Jan 26 11:42:13 my-heroku-app app/web.1 ImportError: libGL.so.1: cannot open shared object file: No such file or directory
    Jan 26 11:42:13 my-heroku-app app/web.1 [2021-01-26 19:42:13 +0000] [10] [INFO] Worker exiting (pid: 10)
    Jan 26 11:42:14 my-heroku-app app/web.1 [2021-01-26 19:42:13 +0000] [4] [INFO] Shutting down: Master
    Jan 26 11:42:14 my-heroku-app app/web.1 [2021-01-26 19:42:13 +0000] [4] [INFO] Reason: Worker failed to boot.
    
    opened by larsen161 1
  • Automate Crowdfunding and API Usage (KEEP THE SITE ALIVE!)

    Automate Crowdfunding and API Usage (KEEP THE SITE ALIVE!)

    I just had an idea about how to keep the site going while keeping everything open source and community oriented. Let's automate the crowdfunding aspect. Monitor API calls and donations to crowdfunding, pull functionality when money runs out, bring it back when money returns. Duh! This is probably a bigger undertaking than most of the suggestions so far, but I am getting so many messages from people wanting to bring the site back. What if we used it to try a completely community supported site model, which doesn't even have to go through me.

    If you're on board with this idea, let me know and let's discuss implementation details below. The hardest part will be figuring out how big a role third-parties play in the collection of funds.

    enhancement help wanted 
    opened by nicksawhney 20
  • Caching

    Caching

    The biggest cost for this site was API requests. Caching will help offset this greatly. It would be nice to cache from some kind of unique image identifier instead of input string, since different inputs can cause the same image to be returned.

    opened by nicksawhney 7
  • Add bernie on the client side and add the ability to drag/drop to move him around

    Add bernie on the client side and add the ability to drag/drop to move him around

    The backend at this point is just a proxy to the streetview api (although I left your routes in there).

    Feedback welcome...I just got inspired and thought this would be a fun little sunday project.

    opened by keevie 2
  • Testing, logging, metrics!

    Testing, logging, metrics!

    I should've done this at the very beginning, but this site sorely needs testing, logging, and metrics. Feel free to submit any and all that you think are relevant! More updates to come in comments.

    good first issue 
    opened by nicksawhney 0
  • Make the form method GET so links to a location are sharable

    Make the form method GET so links to a location are sharable

    I'd like to share specific locations, while still pointing people to the site. So when the form is submitted the url might be something like https://bernie-sits.herokuapp.com/?location=niagara%20falls

    opened by baffalop 3
Owner
null
scap is a tool for putting code in places and for other purposes

Scap is the deployment script used by Wikimedia Foundation to publish code and configuration on production web servers.

Wikimedia 7 Nov 2, 2022
Digdata presented 'BrandX' as a clothing brand that wants to know the best places to set up a 'pop up' store.

Digdata presented 'BrandX' as a clothing brand that wants to know the best places to set up a 'pop up' store. I used the dataset given to write a program that ranks these places.

Mahmoud 1 Dec 11, 2021
An extension for Arma 3 that lets you write extensions in Python 3

An Arma 3 extension that lets you to write python extensions for Arma 3. And it's really simple and straightforward to use!

Lukasz Taczuk 48 Dec 18, 2022
An addin for Autodesk Fusion 360 that lets you view your design in a Looking Glass Portrait 3D display

An addin for Autodesk Fusion 360 that lets you view your design in a Looking Glass Portrait 3D display

Brian Peiris 12 Nov 2, 2022
A program that lets you use your tablet's tilting to emulate an actual joystick on a Linux computer.

Tablet Tilt Joystick A program that lets you use your tablet's tilting to emulate an actual joystick on a Linux computer. It's called tablet tilt joys

null 1 Feb 7, 2022
A tool to allow New World players to calculate the best place to put their Attribute Points for their build and level

New World Damage Simulator A tool designed to take a characters base stats including armor and weapons, level, and base damage of their items (slash d

Joseph P Langford 31 Nov 1, 2022
Time tracking program that will format output to be easily put into Gitlab

time_tracker Time tracking program that will format output to be easily put into Gitlab. Feel free to branch and use it yourself! Getting Started Clon

Jake Strasler 2 Oct 13, 2022
List of Linux Tools I put on almost every linux / Debian host

Linux-Tools List of Linux Tools I put on almost every Linux / Debian host Installed: geany --> GUI editor/ notepad++ like chkservice --> TUI Linux ser

Stew Alexander 20 Jan 2, 2023
lets learn Python language with basic examples. highly recommended for beginners who just start coding.

Lets Learn Python ?? Learn python from basic programs. learn python from scratch. 1.Online python compiler: https://www.onlinegdb.com/online_python_co

Subhranshu Choudhury 1 Jan 18, 2022
This is a vscode extension with a Virtual Assistant that you can play with when you are bored or you need help..

VS Code Virtual Assistant This is a vscode extension with a Virtual Assistant that you can play with when you are bored or you need help. Its currentl

Soham Ghugare 6 Aug 22, 2021
You can easily send campaigns, e-marketing have actually account using cash will thank you for using our tools, and you can support our Vodafone Cash +201090788026

*** Welcome User Sorry I Mean Hello Brother ✓ Devolper and Design : Mokhtar Abdelkreem ========================================== You Can Follow Us O

Mo Code 1 Nov 3, 2021
Tiny demo site for exploring SameSite=Lax

samesite-lax-demo Background on my blog: Exploring the SameSite cookie attribute for preventing CSRF This repo holds some tools for exploring the impl

Simon Willison 6 Nov 10, 2021
Companion Web site for Fluent Python, Second Edition

Fluent Python, the site Source code and content for fluentpython.com. The site complements Fluent Python, Second Edition with extra content that did n

Fluent Python 49 Dec 8, 2022
An alternative site to emplea.do due to inconsistent service of the app.

feline a agile and fast alternative to emplea.do License: MIT Settings Moved to settings. Basic Commands Setting Up Your Users To create a normal user

Codetiger 8 Nov 10, 2021
Module for working with the site dnevnik.ru with python

dnevnikru Module for working with the site dnevnik.ru with python Dnevnik object accepts login and password from the dnevnik.ru account Methods: homew

Aleksandr 21 Nov 21, 2022
Site de gestion de cave à vin utilisant une BDD manipulée avec SQLite3 via Python

cave-vin Site de gestion de cave à vin utilisant une bdd manipulée avec MySQL ACCEDER AU SITE : Pour accéder à votre cave vous aurez besoin de lancer

Elouann Lucas 0 Jul 5, 2022
A Python program for calculating the 95%CI for GNSS-derived site velocities

GNSS_Vel_95%CI A Python program for calculating the 95%CI for GNSS-derived site velocities Function_GNSS_95CI.py is a Python function for calculating

BobWang@UH 4 Dec 16, 2022
A small site to list shared directories

Nebula Server Directories This site can be used to list folder and subdirectories in your server : Python It's required to have Python 3.8 or more ins

Adrien J. 1 Dec 28, 2021
Djangoblog - A blogging site where people can make their accout and write blogs and read other author's blogs

This a blogging site where people can make their accout and write blogs and read other author's blogs.

null 1 Jan 26, 2022