- David Schovanec
- Prague Ruby Meetup 20.4.2017
- virtualizace
- minimální vrstva
// This will open up a prompt for text to send to a console session on digital ocean | |
// Useful for long passwords | |
(function () { | |
window.sendString = function (str) { | |
f(str.split("")); | |
function f(t) { | |
var character = t.shift(); | |
var i=[]; | |
var code = character.charCodeAt(); | |
var needs_shift = character.match(/[A-Z!@#$%^&*()_+{}:\"<>?~|]/); |
You'll need to do the following:
You need to make your bot a python app. Do this by making another directory (can be the same name as the regular one) and put all your python code in that, and make an empty file called __init__.py
in it as well. See how I structured mine if this isn't clear. In your base directory, create two files: "requirements.txt" and "runtime.txt". The requirements.txt file should be the output of pip freeze (you can run the command "pip freeze > requirements.txt"). If you're not using virtualenv, you'll need to go through after and delete all the lines with packages your code doesn't actually use. Check out mine to see what I mean. Runtime.txt just specifies with python version for heroku to use. Mine just has the line "python-2.7.4" in it. All of this will tell heroku to recognize your bot as a python app.
Make a heroku account and
Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.
It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media
This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.