Skip to content

Instantly share code, notes, and snippets.


Frank Kany kany

  • Rickman, TN
View GitHub Profile
kany / sudo_crontab_e
Last active Aug 29, 2015
Cronjob to reboot server 1 minute past every hour
View sudo_crontab_e
# To Edit Root Cron Jobs
#sudo crontab -e
# Reboot 1 minute past every hour, log errors if any generate
01 * * * * /sbin/reboot > /home/calvin2/miner_cron_job_log.txt 2>&1
# Reboot every 30 minutes, log errors if any generate
*/30 * * * * /sbin/reboot > /home/calvin2/miner_cron_job_log.txt 2>&1
kany / active_record_outside_of_rails.rb
Created Mar 27, 2014
Using ActiveRecord outside of a Rails app
View active_record_outside_of_rails.rb
require 'active_record'
require 'mysql2'
# Database Connection
adapter: 'mysql2', # or 'postgresql' or 'sqlite3'
host: 'localhost',
database: 'chc_user_auth_direct_login',
username: 'root',
password: ''
kany / cropper.rb
Created Sep 24, 2014
Cropping images with paperclip
View cropper.rb
# lib/paperclip_processors/cropper.rb
module Paperclip
class Cropper < Thumbnail
def transformation_command
if crop_command
puts "CROP: #{crop_command + super.join(' ').sub(/ -crop \S+/, '').split(' ')}"
crop_command + super.join(' ').sub(/ -crop \S+/, '').split(' ')
kany /
Created Jan 14, 2015
rubocop - script to install rubocop and rubocop-rspec gems before running rubocop
# -------
# rubocop
# -------
# example usage:
# check a directory: rubocop app/controllers
# check a file: rubocop app/controllers/application_controller.rb
# check rspec directory: rubycop spec/controllers
# check rspec file: rubycop spec/controllers/application_controller_spec.rb
if gem list | gem list | grep 'rubocop\|rubocop-rspec' ; then
kany / libv8.rb
Created Apr 23, 2015
libv8 issues
View libv8.rb
gem uninstall libv8
brew install v8
gem install therubyracer
gem install libv8 -v '' -- --with-system-v8
kany / iZoom.min.js
Created Aug 5, 2012
Image - Magnifying Glass - jQuery
View iZoom.min.js
def show
@consignment_item = ConsignmentItem.find(params[:id])
@magnified_images = ""
@consignment_item.images.each_with_index do |image, index|
@magnified_images += "jQuery('#magnifyimage_#{index}').iZoom();"
kany / gist:3640501
Created Sep 5, 2012
Importing Large MySQL Databases - Mac OS
View gist:3640501
1) Install Keka
2) (optional) split your import file(
3) Compress your sql dump file(s) into a 7z file using Keka.
4) From the terminal, run:
7z x -so backup_some_app_data.sql.7z | mysql -u root some_app_db
kany / gist:3658110
Created Sep 6, 2012
WTF MySQL! Eating up diskspace
View gist:3658110
How to clear all those 'mysql-bin.00000**' files from /usr/local/var/mysql:
1) mysql -u root
2) flush logs;
3) reset master;
kany / unpack a gem
Created Sep 16, 2012
Unpacking a gem to a specific directory
View unpack a gem
Rhodes application stack needs required gem unpacked to the lib directory.
frankkany:rhodesprojects $ gem unpack mechanize --target ~/Desktop
Unpacked gem: '/Users/frankkany/Desktop/mechanize-2.5.1'
kany / ubuntu,rvm,crontab
Created Nov 5, 2012
View ubuntu,rvm,crontab
RVM, Rake and Cron on Ubuntu
by admin on August 24th, 2011
Tennnngh! I read countless blog posts, tried numerous approaches that I found and rebuilt the server more than a couple times. And finally I found what the missing piece was for getting a rake command to run in cron with rvm.
Most of the results I found (on stackoverflow) flagged the solution as adding the path to your rvm in your line item in crontab. Something like /home/username/.rvm/gems/rake my_awesome_task… etc. I tried every variation of that I could think of and got the same results.
I dont use cron every day so this was a revelation to me. I found out that you can set variables, environment variables in your crontab file.