Skip to content

Instantly share code, notes, and snippets.

@suryart
suryart / keybase.md
Created February 25, 2015 07:13
keybase

Keybase proof

I hereby claim:

  • I am suryart on github.
  • I am srt (https://keybase.io/srt) on keybase.
  • I have a public key whose fingerprint is 0BEA 34ED DE36 3D58 3601 FC41 BED2 86EA 420A F92C

To claim this, I am signing this object:

@suryart
suryart / mysql2sqlite.sh
Created December 27, 2011 12:11 — forked from esperlu/mysql2sqlite.sh
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
#!/usr/bin/env ruby
require 'rubygems'
require 'roo'
pwd = File.dirname(__FILE__)
Dir.glob("#{pwd}/*.xls") do |file|
file_path = "#{pwd}/#{file}"
file_basename = File.basename(file, ".xls")
xls = Excel.new(file_path)
@suryart
suryart / statement.rb
Created October 29, 2012 18:42
Travel Allowance Statement generation Script
t1 = (Time.now-6.months).beginning_of_month # Start Date Time
t2 = (Time.now).end_of_month # End Date and Time
t = t1
amounts = [155, 140, 160]
from = "Banashankari 3rd Satge, Vyalikaval"
to = "Vyalikaval, Banashankari 3rd Satge"
month = t.month
year = t.year
leaves = {"26/01/2012" => "Republic Day", "23/03/2012" => "Chandramana Ugadi", "01/05/2012" => "May Day", "15/08/2012" => "Independence Day", "19/09/2012" => "Ganesha Chaturthi", "02/10/2012" => "Gandhi Jayanti", "23/10/2012" => "Audha Pooja", "01/11/2012" => "Kannada Rajyotsava", "12/11/2012" => "Naraka Chaturdashi", "14/11/2012" => "Balipadyami" }
activerecord (3.2.13) lib/active_record/persistence.rb:347:in `create_or_update'
activerecord (3.2.13) lib/active_record/callbacks.rb:264:in `block in create_or_update'
activesupport (3.2.13) lib/active_support/callbacks.rb:425:in `_run__3652904023592825844__save__1349650235203356801__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
activerecord (3.2.13) lib/active_record/callbacks.rb:264:in `create_or_update'
activerecord (3.2.13) lib/active_record/persistence.rb:84:in `save'
activerecord (3.2.13) lib/active_record/validations.rb:50:in `save'
activerecord (3.2.13) lib/active_record/attribute_methods/dirty.rb:22:in `save'
source 'https://rubygems.org'
gem 'rails', '3.2.13'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
➜ my_store rvm:(ruby-2.0.0) bundle update
Fetching https://github.com/spree/spree.git
remote: Counting objects: 130666, done.
remote: Compressing objects: 100% (48435/48435), done.
remote: Total 130666 (delta 82214), reused 119957 (delta 72967)
Receiving objects: 100% (130666/130666), 27.04 MiB | 380.00 KiB/s, done.
Resolving deltas: 100% (82214/82214), done.
Updating https://github.com/spree/spree_gateway.git
Updating https://github.com/spree/spree_auth_devise.git
Updating git://github.com/suryart/spree_active_sale.git
@suryart
suryart / order_spec.rb
Last active December 19, 2015 07:49
orders spec example for spree frontend
require 'spec_helper'
describe 'Orders' do
let!(:product) { create(:product, :available_on => 1.day.ago) }
stub_authorization!
before(:each) do
visit spree.admin_path
click_link "Products"
@suryart
suryart / output
Created July 3, 2013 18:20
console output for order spec example for spree frontend
[#<Spree::Product id: 1, name: "Product #1 - 6731", description: "Dicta tenetur maxime velit facere. In quisquam odit...", available_on: "2013-07-02 18:13:39", deleted_at: nil, permalink: "product-number-1-6731", meta_description: nil, meta_keywords: nil, tax_category_id: 1, shipping_category_id: 1, created_at: "2013-07-03 18:13:40", updated_at: "2013-07-03 18:13:40">]
#<Spree::Product id: 1, name: "Product #1 - 6731", description: "Dicta tenetur maxime velit facere. In quisquam odit...", available_on: "2013-07-02 18:13:39", deleted_at: nil, permalink: "product-number-1-6731", meta_description: nil, meta_keywords: nil, tax_category_id: 1, shipping_category_id: 1, created_at: "2013-07-03 18:13:40", updated_at: "2013-07-03 18:13:40">
/products/product-number-1-6731
F
Failures:
1) Orders should allow a user to see product name
Failure/Error: find('.product-title').text.should equal product.name
Capybara::ElementNotFound:
@suryart
suryart / spec_helper.rb
Created July 4, 2013 08:18
spec_helper for spree testing. Enables :js to run without any warning.
# Configure Rails Environment
ENV['RAILS_ENV'] = 'test'
require File.expand_path('../dummy/config/environment.rb', __FILE__)
require 'rspec/rails'
require 'database_cleaner'
require 'ffaker'
require 'factory_girl'