Skip to content

Instantly share code, notes, and snippets.

View shishirmk's full-sized avatar

Shishir Kakaraddi shishirmk

View GitHub Profile
@shishirmk
shishirmk / git diff
Created February 25, 2018 03:30
diff of fast_jsonapi dev branch to try key_transfrom :unaltered
diff --git a/spec/lib/object_serializer_performance_spec.rb b/spec/lib/object_serializer_performance_spec.rb
index e718953..c589ea8 100644
--- a/spec/lib/object_serializer_performance_spec.rb
+++ b/spec/lib/object_serializer_performance_spec.rb
@@ -107,13 +107,13 @@ describe FastJsonapi::ObjectSerializer, performance: true do
data[k][:time] = Benchmark.measure { data[k][:json] = v.send(json_method) }.real * 1000
end
- print_stats(message, movie_count, data)
+ # print_stats(message, movie_count, data)
# require 'benchmark/ips'
# require 'awesome_print'
# require 'pry-byebug'
# require 'kalibera'
# require 'benchmark-memory'
require 'bundler'
require 'bundler/setup'
Bundler.require(:default)
@shishirmk
shishirmk / names.txt
Created October 21, 2017 21:30
List of country names
Afghanistan
Australia
Albania
Algeria
Aruba
Antigua and Barbuda
Austria
Azerbaijan
Argentina
Armenia
@shishirmk
shishirmk / dice_throw_test.rb
Created July 23, 2014 02:07
# Just simulating and checking dice throw probabilities and prediction based on least occuring number in history
# Just simulating and checking probabilities
# Hence proved i was wrong
def dice_throw
random_gen = Random.new
return random_gen.rand(6) + 1
end
def random_predict
random_gen = Random.new
def add_headers_and_higher_is_better
test_ids = @table.keys - self.metadata_names
tests = Testname.where(:id => test_ids)
testnames_hash = Hash.new
testdetails = Testdescription.where(:dashboard_id => @dashboard_id, :testname_id => test_ids)
testdetails_hash = Hash[testdetails.collect{ |testdetail| [testdetail.testname_id, testdetail] }]
tests.each do |test|
if testdetails_hash[test.id]
self.insert_higher_is_better(testdetails_hash[test.id])
end
@shishirmk
shishirmk / gist:4028237
Created November 6, 2012 22:55
Error when i calculate 500th root of a number less than 1
#<Class:0x00000005bc6538> can't be coerced into BigDecimal
@shishirmk
shishirmk / gist:3990571
Created October 31, 2012 23:17
Error message on rails 3.2 for a simple @milestone.destroy
Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1: DELETE FROM `milestones` WHERE `milestones`.`id` = ?
These were the params according to the error message
{"_method"=>"delete",
"authenticity_token"=>"something something",
"id"=>"12"}
@shishirmk
shishirmk / gist:3543348
Created August 30, 2012 22:34
RedisWrapper class.
class RedisWrapper
attr_accessor :client
def initialize
begin
@c = Redis.new(:host => "localhost")
rescue
return false
end
resque-web
[2012-08-28 12:02:11 -0700] Starting 'resque-web'...
[2012-08-28 12:02:11 -0700] trying port 5678...
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/open-uri.rb:346:in `open_http': 403 Forbidden (OpenURI::HTTPError)
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/open-uri.rb:775:in `buffer_open'