Skip to content

Instantly share code, notes, and snippets.

@jastkand
jastkand / ability.rb
Created September 22, 2012 09:42 — forked from watson/ability.rb
Active Admin CanCan integration with shared front/backend User model and multi-level autherization
# app/models/ability.rb
# All front end users are authorized using this class
class Ability
include CanCan::Ability
def initialize(user)
user ||= AdminUser.new
case user.role
when "admin"
@jastkand
jastkand / voice-recognition.js
Created November 21, 2012 11:14
HTML5 Speech Input with Voice Recognition
// Thanks to http://ctrlq.org/code/19271-html5-speech-input article
$(function () {
// Check if the user's web browser supports HTML5 Speech Input API
if(document.createElement('input').webkitSpeech == undefined) {
$(".answer").append("We are sorry but Dictation requires Google Chrome.");
}
else {
@jastkand
jastkand / badge-generator.js
Last active December 10, 2023 00:46
An Adobe Illustrator Script that helps to generate a list of PDF documents from template. Replaces %name% and %lastname% with items from data array then saves the result to PDF file.
var data = [
["John", "Doe"],
["James", "Brown"]
];
function main() {
var firstName, lastName;
for (var key in data) {
firstName = data[key][0];
@jastkand
jastkand / image_loader.rb
Created March 15, 2013 13:45
Script that helps to download images from old server using url stored in database and old :host_url:
class HomeController
def download
require 'open-uri'
require 'fileutils'
icons = Icon.all
posts = Post.all
snapshots = Snapshot.all
icons.each do |icon|

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@jastkand
jastkand / pdf2avi.rb
Created November 17, 2013 16:17
Script that allows to convert pdf file to avi using ffmpeg
require 'RMagick'
require 'fileutils'
def clean_temp(dir)
FileUtils.rm_rf(dir) if File.exists?(dir)
end
pdf = Magick::ImageList.new("input.pdf")
dir = './temp'
sudo apt-get install tofrodos
fromdos file_path.file
@jastkand
jastkand / howto.md
Last active August 29, 2015 14:21
Upgrade PostgreSQL from 9.3 to 9.4

Upgrade steps were taken from this article.

sudo service postgresql stop 9.3

sudo service postgresql stop 9.4

sudo su - postgres

/usr/lib/postgresql/9.4/bin/pg_upgrade -b /usr/lib/postgresql/9.3/bin/ -B /usr/lib/postgresql/9.4/bin/ -d /var/lib/postgresql/9.3/main -D /var/lib/postgresql/9.4/main -o ' -c config_file=/etc/postgresql/9.3/main/postgresql.conf' -O ' -c config_file=/etc/postgresql/9.4/main/postgresql.conf'
@jastkand
jastkand / capybara-cheetsheet.md
Created August 20, 2015 15:14
Capybara Cheetsheet

Navigating

visit('/projects')
visit(post_comments_path(post))

Clicking links and buttons

click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button

click('Button Value')

@jastkand
jastkand / README.md
Last active December 22, 2015 11:45
Как выкладывать iOS сборки на сервер

Сервер обязательно должен быть с SSL

Необходимо загрузить файл сборки на сервер в какой-либо каталог и сохранить ссылку на этот файл. Пусть ссылка на сборку будет https://mysite.com/builds/my-app.ipa

Создать на сервере plist-файл с следующим содержанием

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">