Skip to content

Instantly share code, notes, and snippets.

View karthiks's full-sized avatar
😄
Playing with GraphQL

Karthik Sirasanagandla karthiks

😄
Playing with GraphQL
View GitHub Profile
@karthiks
karthiks / hn.java
Created February 12, 2014 10:48
Examples of Hungarian Notation
ArrayList arrlstCbosPagedDetails;
ArrayList arrlstCbosTotalDetails;
String sOperation = request.getParameter(ABCConstants.OPERATION);
int iTotalRecords = objConsolidatedBOSForm.getTotalRecords();
@karthiks
karthiks / moreHN.java
Created February 12, 2014 10:55
Some more examples of Hungarian Notation
ArrayList arrlstCbomPagedDetails; // Systems Hungarian notation
Array arrStudents; // Systems Hungarian notation
rwPosition = 5; // App Hungarian notation where rw implies row, indicating the variable is row position. This variable could have well be named rowPosition making things a lot clearer.

Notes on teaching both test/unit and RSpec to new Ruby developers

@tenderlove asked "Is it good to teach RSpec (vs t/u) to people who are totally new to Ruby?" I have experience suggesting that it is a good thing; after a short back and forth, it seemed useful to write it up in detail.

Background

This goes back several years, to when I was the primary Ruby/Rails trainer for Relevance from 2006-2009. I'm guessing that worked out to probably 6-8 classes a year during those years. Since then, RSpec has changed a fair amount (with the addition of expect) and test/unit has changed radically (it has an entirely new implementation, minitest, that avoids some of the inconsistencies that made test/unit a bit confusing during the time I'm writing about here).

I started out as an RSpec skeptic. I've never been afraid of what a lot of people denigrate as "magic" in Ruby libraries … to me, if you take the trouble to understand it, that stuff's just pr

@karthiks
karthiks / BigFactorial.java
Created July 18, 2014 10:26
How to find Factorial of Numbers whose result is way toooo big for the native data structure to accommodate in any platform?
/*
* How to find Factorial of Numbers whose result is way toooo big for the native datastructure to accomodate in any platform?
* Source of Inspiration: CodeChef
* Discussion src: http://discuss.codechef.com/questions/7349/computing-factorials-of-a-huge-number-in-cc-a-tutorial
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
@karthiks
karthiks / debugging_shebang.rb
Created August 6, 2014 16:48
Debugging Shebang
#!/usr/bin/env ruby
puts "Hi there!"
@karthiks
karthiks / pre-express3.js
Created August 9, 2014 09:58
Code during pre Express 3.x days in Node.js platform
var express = require('express');
var web_app = express();
web_app.get('/', function(request, response) {
response.send('Hello World');
});
web_app.listen(8080, function() {
console.log("The server is now up and running...listening on port %d", web_app.address().port);
@karthiks
karthiks / from-express3.js
Created August 9, 2014 10:06
Code from Express 3.x version in Node.js platform
var express = require('express');
var http = require('http');
var web_app = express();
var web_server = http.createServer(web_app);
web_app.get('/', function(request, response) {
response.send('Hello World');
});
@karthiks
karthiks / modify_title_metadata_tag.rb
Created September 1, 2014 16:58
To set the title metadata tag of a media file to that of its base_file_name
#!/usr/bin/env ruby
puts "Starting.."
require 'taglib'
#Dir['path/to/dir/*'].select { |e| File.file?(e) }
Dir.glob("./*.wma").each do |filename|
puts "File name: #{filename}"
TagLib::FileRef.open(filename) do |f|
title = File.basename(filename, ".*")
@karthiks
karthiks / convert_avi_to_mp4.rb
Last active August 29, 2015 14:05
Convert avi file to mp4 media file using ffmpeg and Ruby
#!/usr/bin/env ruby
puts "Starting.."
#Dir['path/to/dir/*'].select { |e| File.file?(e) }
Dir.glob("./*.avi").each do |filename|
puts "Converting File name: #{filename}"
puts `mkdir "#{File.join( File.dirname(filename), "mp4")}"`
newfilename = File.join(
File.dirname(filename),
@karthiks
karthiks / hr-spam-mails.txt
Created December 22, 2014 09:03
Reply to HR mails that spam your inbox
Hey HR,
Pleased by your mail. How about a return offer? We are looking forward to hire enthusiastic Jr. HRs in our company.
Should you be interested, do feel free to forward your resume to our HR.
Our folks should be interested to talk to you about an opportunity to have you onboard.
Cheers!
Karthik