Skip to content

Instantly share code, notes, and snippets.

{
title: 'Harvest',
# HTTP basic auth example.
connection: {
fields: [
{
name: 'subdomain',
control_type: 'subdomain',
url: '.harvestapp.com',
module BulkInsertHelper
extend ActiveSupport::Concern
def insert_sql
fill_time_stamps
self.class.arel_table.
create_insert.tap do |im|
im.insert(
self.send(
:arel_attributes_with_values_for_create,
self.attribute_names
@kandadaboggu
kandadaboggu / calculator.rb
Last active August 29, 2015 14:02
Calculator DSL
# Implement a calculator DSL that supports following functions:
# calculate do
# add 2
# subtract 3
# multiply 4
# divide 5
# end
describe 'Calculator' do
@kandadaboggu
kandadaboggu / HistoryWrapper.js
Last active March 1, 2018 11:02
The `History.js` triggers `statechange` event for `pushState` and `replaceState` API calls. There is no way to distinguish between Back button events and API generated events. The dev branch of the library has fixed this issue. I wanted a simple fix until the fix is public. This is my attempt.
if (History && History.enabled) {
// START OF WRAPPER SECTION
var HistoryWrapper = {
apiEventInProgress: false,
isBrowserEvent: function () {
return !this.apiEventInProgress;
},
@kandadaboggu
kandadaboggu / game_of_life.rb
Created July 11, 2012 18:32
Sample implementation for Conway's Game of Life
# Ruby implementation of Conway's Game of Life
# run the program as : ruby game_of_life.rb
require 'rbconfig'
class GameOfLife
def self.windows?
!!(RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
end
@kandadaboggu
kandadaboggu / theme.html
Created June 16, 2011 17:20
Tumblr theme customization for kandadaboggu.com
<html>
<head>
<!-- Custom CSS -->
<style>
pre {
background-color: #F9F9F9;
color: #333333;
margin: 30px 0;
-moz-border-bottom-colors: none;
-moz-border-image: none;