Skip to content

Instantly share code, notes, and snippets.

View tamizhgeek's full-sized avatar

Azhaguselvan SP tamizhgeek

View GitHub Profile
\documentclass {beamer}
\usepackage{graphics}
\usepackage{listings}
\usetheme{Berkeley}
\title {Plugin frameworks}
\subtitle {3 approaches to designing plugin APIs}
@tamizhgeek
tamizhgeek / add_sheet_count.diff
Created August 30, 2011 10:36
Diff for adding a sheet_count method to spreadsheet gem
diff --git a/lib/spreadsheet/workbook.rb b/lib/spreadsheet/workbook.rb
index 06e17af..eef4f19 100644
--- a/lib/spreadsheet/workbook.rb
+++ b/lib/spreadsheet/workbook.rb
@@ -56,6 +56,12 @@ module Spreadsheet
add_worksheet Worksheet.new(opts)
end
##
+ # Returns the count of total worksheets present.
+ # Takes no arguments. Just returns the length of @worksheets array.
@tamizhgeek
tamizhgeek / Contact.java
Created March 10, 2012 13:49
Contact class
class Contact {
protected String name;
protected String number;
protected String id;
protected Contact(String name, String number) {
this.name = name;
this.number = number;
}
@tamizhgeek
tamizhgeek / ContactActivity.java
Created March 10, 2012 13:52
contact activity class
public class ContactActivity extends ListActivity {
private EditText filterText;
private ArrayAdapter<Contact> adapter;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Use our custom layout
setContentView(R.layout.contact);
@tamizhgeek
tamizhgeek / ruby-titbits
Last active October 4, 2015 13:27
Ruby snippets/tit bits which I find useful and don't wish to forget.
.present? is opposite of .blank? = Don't use ugly !blank?
xx
Missing attribute error occurs when you don't select a certain attr in SQL query but
try to use it in ActiveRecord.
xx
User Time.now.to_s(:db) while comparing datetime in mysql.
@tamizhgeek
tamizhgeek / aaa.rb
Created May 30, 2012 12:57
sample class AAA
class AAA < ActiveRecord::Base
belongs_to :parent, :class_name => "AAA", :foreign_key => "parent_id"
end
@tamizhgeek
tamizhgeek / bbb.rb
Created May 30, 2012 13:02
ruby console
?> a = AAA.new()
=> #<AAA id: nil, parent_id: nil>
>> a.save!
=> true
>> b = AAA.new()
=> #<AAA id: nil, parent_id: nil>
>> b.save!
=> true
>> b.parent = a
=> #<AAA id: 1, parent_id: nil>
@tamizhgeek
tamizhgeek / ListUtils.scala
Last active August 29, 2015 14:09
Bootcamp week-1 list related problems. Test cases are here : https://gist.github.com/tamizhgeek/6e09fbb4d6e448bea213
package assignments
object ListUtils {
def findLast(list : List[Int]) :Int = {
list match {
case a :: Nil => a
case a :: b => findLast(b)
}
}
@tamizhgeek
tamizhgeek / MiscUtils.scala
Last active August 29, 2015 14:09
Bootcamp week 1 problems, not related to lists. Test cases are here : https://gist.github.com/tamizhgeek/60b1a4ece4ecbb79a1e7
package assignments
object MiscUtils {
def listPrimes(start : Int, end : Int) : List[Int] = {
def collect(currentIdx : Int, newList : List[Int]) : List[Int] = {
currentIdx match {
case a if(a == 2 || a == 3 || (a % 2 != 0 && a % 3 != 0)) => collect(a + 1, newList :+ a)
case a if(a >= end) => newList
case a => collect(a + 1, newList)
@tamizhgeek
tamizhgeek / ListUtilsTest.scala
Created November 15, 2014 13:43
Tests for bootcamp week-1 list problems
import assignments.ListUtils._
import org.scalatest.FlatSpec
class ListUtilsTest extends FlatSpec {
behavior of "ListUtils"
it should "find last of the list" in {
assert(findLast(List(1,2,3,4,5)) == 5)
assert(findLast(List(1)) == 1)
}