Skip to content

Instantly share code, notes, and snippets.

View antlypls's full-sized avatar
🤘

Anatoliy Plastinin antlypls

🤘
View GitHub Profile
@antlypls
antlypls / onchange.sh
Last active August 29, 2015 14:15 — forked from senko/onchange.sh
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@antlypls
antlypls / s3.sh
Last active August 29, 2015 14:21 — forked from chrismdp/s3.sh
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
class PeopleController < ApplicationController
def index
@people = Person.all
logger.info @people.inspect
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @people }
end
end
def prepare_sql params
ActiveRecord::Base.send 'sanitize_sql_array', params
end
ActiveRecord::Base.connection.execute(prepare_sql ["update users set total_visits = total_visits + ? where id = ?", visits_increment, user_id])
@antlypls
antlypls / runall.py
Created June 14, 2011 18:22
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)
os.chdir(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
antlypls / mongodb_repair.sh
Created September 8, 2011 10:07
repair mongodb if it's not started after crash
#!/bin/sh
sudo rm /var/lib/mongodb/mongod.lock
sudo mongod --repair
sudo service mongodb start
# app/controllers/users/password_controller.rb
class Users::PasswordsController < Devise::PasswordsController
def resource_params
params.require(:user).permit(:email, :password, :password_confirmation)
end
private :resource_params
end
# create the template
template = PageOfflineTemplate.new
template.quote = quote
template.pages = quote.build_pages
# Here I render a template with layout to a string then a PDF
pdf = PDFKit.new template.render_to_string(:template=>"quotes/review.html.haml")
# app/uploaders/avatar_uploader.rb
process :fix_exif_rotation
process :strip
process :resize_to_fill => [1024, 768]
process :quality => 90 # Percentage from 0 - 100
# config/locales/en.yml
en:
exception:
show:
not_found:
title: "Not Found"
description: "The page you were looking for does not exists."
internal_server_error:
title: "Internal Server Error"