Skip to content

Instantly share code, notes, and snippets.

@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|
@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 / 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 / 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"