docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
echo "$STRING" | iconv -t ascii//TRANSLIT | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z |
Press minus + shift + s
and return
to chop/fold long lines!
import multiprocessing | |
# split a list into evenly sized chunks | |
def chunks(l, n): | |
return [l[i:i+n] for i in range(0, len(l), n)] | |
def do_job(job_id, data_slice): | |
for item in data_slice: | |
print "job", job_id, item |
# Replace Jekyll's handling of the Redcarpet code_block (which already adds | |
# support for highlighting, but needs support for the very non-standard | |
# "code fences with line highlights" extension). | |
# Since this is currently depending on Redcarpet to cooperate, we are going to | |
# be naive, and only allow line highlighting when a language is specified. If | |
# you don't want any syntax highlighting but want to highlight lines, then you | |
# need to specify text as your language (or it will break), like: | |
# ```text{4} | |
module Jekyll |
$ ActiveRecord::Base.connection.reset_pk_sequence!('table_name')
If you need the table names:
$ ActiveRecord::Base.connection.tables
=> ["accounts", "assets", ...]
In addition to the charts that follow, you might want to consider the Frequently Asked Questions section for a selection of common questions about MongoDB.
The following table presents the MySQL/Oracle executables and the corresponding MongoDB executables.
By default, Rails applications build URLs based on the primary key -- the id
column from the database. Imagine we have a Person
model and associated controller. We have a person record for Bob Martin
that has id
number 6
. The URL for his show page would be:
/people/6
But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6
here, is called the "slug". Let's look at a few ways to implement better slugs.