Skip to content

Instantly share code, notes, and snippets.

View deepakkumarnd's full-sized avatar
🏠
Working from home

Deepak Kumar deepakkumarnd

🏠
Working from home
View GitHub Profile
@deepakkumarnd
deepakkumarnd / anorm.scala
Created April 16, 2020 05:51 — forked from davegurnell/anorm.scala
A short guide to Anorm
/*
Overview
--------
To run a query using anorm you need to do three things:
1. Connect to the database (with or without a transaction)
2. Create an instance of `anorm.SqlQuery` using the `SQL` string interpolator
3. Call one of the methods on `SqlQuery` to actually run the query
@deepakkumarnd
deepakkumarnd / Rakefile
Created November 17, 2016 07:13 — forked from schickling/Rakefile
Activerecord without Rails
require "active_record"
namespace :db do
db_config = YAML::load(File.open('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
ActiveRecord::Base.establish_connection(db_config_admin)
@deepakkumarnd
deepakkumarnd / benchmark.sh
Created November 4, 2016 11:49 — forked from peterjmit/benchmark.sh
Bash Benchmark Script (using time)
#!/bin/bash
# REQUIRES SUDO
# Benchmark runner
repeats=20
output_file='benchmark_results.csv'
command_to_run='echo 1'
run_tests() {
# --------------------------------------------------------------------------
@deepakkumarnd
deepakkumarnd / query.rb
Last active August 29, 2015 14:24 — forked from austenito/query.rb
if Moped.logger == Rails.logger
Moped.logger = Logger.new($stdout)
true
else
Moped.logger = Rails.logger
false
end
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby