Skip to content

Instantly share code, notes, and snippets.

Anatoliy Plastinin antlypls

Block or report user

Report or block antlypls

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View passwords_controller.rb
# app/controllers/users/password_controller.rb
class Users::PasswordsController < Devise::PasswordsController
def resource_params
params.require(:user).permit(:email, :password, :password_confirmation)
private :resource_params
antlypls /
Created Sep 8, 2011
repair mongodb if it's not started after crash
sudo rm /var/lib/mongodb/mongod.lock
sudo mongod --repair
sudo service mongodb start
antlypls /
Created Jun 14, 2011
This script runs all .py files in all subdirectories
import os
path = os.getcwd()
for root, dirs, files in os.walk(path):
print("visiting: ", root)
py_files = [file for file in files if file[-3:]=='.py']
for py_file in py_files:
cmd = "python {0}".format(py_file)
print("running: ", cmd)
antlypls /
Created Feb 28, 2011
transforms pdf to booklet layout (two pages side by side) fixed version of required packages: pdftk and pdfjam (as well as tex-live, pdflatex required by pdfjam)
FILE=$(echo $1 | sed 's/.pdf//')
echo "$ pdfcrop $FILE.pdf --margins 12"
pdfcrop $FILE.pdf --margins 12
echo "$ pdftops $FILE-crop.pdf"
pdftops $FILE-crop.pdf
View active_record_sanitized_query.rb
def prepare_sql params
ActiveRecord::Base.send 'sanitize_sql_array', params
ActiveRecord::Base.connection.execute(prepare_sql ["update users set total_visits = total_visits + ? where id = ?", visits_increment, user_id])
View people_controller.rb
class PeopleController < ApplicationController
def index
@people = Person.all @people.inspect
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @people }
You can’t perform that action at this time.