Skip to content

Instantly share code, notes, and snippets.

View mlnkrish's full-sized avatar
💭
You'll not abandon ship in a storm just because you could not control the winds.

MLN mlnkrish

💭
You'll not abandon ship in a storm just because you could not control the winds.
View GitHub Profile
@mlnkrish
mlnkrish / hash2sheet.rb
Last active December 11, 2018 11:22
Convert Ruby Hash to XLSX Workbook
require 'Axlsx'
mapping = {"Key 1"=> ['Val 1', 'Val 2', 'Val 3'], "Key 2"=> ['Val 1', 'Val 2', 'Val 3']}
Axlsx::Package.new do |p|
mapping.keys.each do |key|
p.workbook.add_worksheet(:name => "#{key}") do |sheet|
vals = mapping[key]
vals.each {|v| sheet.add_row ["#{v}"]}
end
@mlnkrish
mlnkrish / test.exs
Last active December 11, 2018 11:24
Ecto Phoenix Not found Handling
test "404 for non existing user" do
{:ok, data} = Poison.encode(%{email: "nonexisting@user.com", password: "mypass"})
assert conn()
|> put_req_header("content-type", "application/json")
|> post(session_path(@endpoint, :create), data)
|> json_response(:not_found) == %{}
end
end
### Keybase proof
I hereby claim:
* I am mlnkrish on github.
* I am mlnkrish (https://keybase.io/mlnkrish) on keybase.
* I have a public key whose fingerprint is 8E58 8E58 E446 059A 9C78 7A7C D505 CEB6 85C2 064F
To claim this, I am signing this object:
@mlnkrish
mlnkrish / DatabaseOpenHelper.java
Last active August 14, 2018 10:04
Managing database migrations for Android
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.util.List;
public class DatabaseOpenHelper extends SQLiteOpenHelper {
final private static String NAME = "your_db";
final private static Integer VERSION = Migrations.migrations.size();;