Skip to content

Instantly share code, notes, and snippets.

View pikender's full-sized avatar

Pikender Sharma pikender

  • Faridabad, Haryana
View GitHub Profile
@pikender
pikender / gist:f253ae296f25bdaf3e4b
Last active August 29, 2015 14:02 — forked from bkimble/gist:1365005
Debug it - Get all keys in memcache
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []
@pikender
pikender / Reload Grape API in Dev Env.rb
Created November 22, 2012 09:53
Reload Grape API in Development Environment for Rails 3.1 and higher
INSPIRATION: https://github.com/intridea/grape/issues/131#issuecomment-10413342
File: config/application.rb
config.autoload_paths += %W(#{config.root}/app/api #{config.root}/app/api/*/*)
File: config/environments/development.rb
# Add below code before DummyApp::Application.configure BLOCK
@pikender
pikender / enable_firebug_in_cucumber_javascript_features.rb
Created December 31, 2012 06:04
Debug Javascript Enabled Cucumber Features - Enable Firebug in Firefox
- Start Firefox ProfileManager on Ubuntu
CMD: /usr/lib/firefox/firefox -ProfileManager
- Create Profile
- Let's say, profile name is WebDriver
- Select the WebDriver Profile
- Start Firefox
- Install Firebug
- Close Firefox
@pikender
pikender / delete_branches_older_than.sh
Created December 10, 2015 08:54
Delete Feature Branches as Sprint Deployed on Production
#!/bin/sh
## Script to clean old git branches
echo "Delete branches having last commit before 1st June 2015 - DRY_RUN=1 to show commands - ignore if execution"
echo "DRY_RUN=1 delete_branches_older_than.sh '2015-06-01'"
echo $DRY_RUN
echo $1
@pikender
pikender / product.ex
Last active April 11, 2016 17:27
Ecto Model Schema Extension
## Library Code
## Defines DSL to be used by Service Code
## in order to get properly consumed by Consumer
defmodule Nectar.ModelExtension do
defmacro __using__(_opts) do
quote do
Module.register_attribute(__MODULE__, :schema_changes, accumulate: true)
import Nectar.ModelExtension, only: [add_to_schema: 1]
@before_compile Nectar.ModelExtension
end
diff --git a/product.ex b/product.ex
index 25efbae..21632ff 100644
--- a/product.ex
+++ b/product.ex
@@ -1,3 +1,6 @@
+## Library Code
+## Defines DSL to be used by Service Code
+## in order to get properly consumed by Consumer
defmodule Nectar.ModelExtension do
defmacro __using__(_opts) do
@pikender
pikender / product.ex.extension.bash
Created April 12, 2016 11:34
Check Model Extension to have same behaviour while refactoring (creating model extension)
nectarcommerce ~/elixir$ iex -S mix
## File Compilation Removed
iex(4)> a = Nectar.Product.changeset(%Nectar.Product{}, %{}); a.model.special;
nil
iex(5)> b = Ecto.Changeset.put_change(a, :special, true); b.changes.special;
true
@pikender
pikender / nectar-web-router.ex.test-extension.bash
Created April 12, 2016 15:08
Check Nectar Router to have same behaviour while refactoring (creating router extension)
nectarcommerce ~/elixir$ mix phoenix.routes Nectar.Router | grep Favorite
favorite_path GET /favorites FavoriteProducts.FavoriteController :index
@pikender
pikender / nectar-web-router.ex
Last active April 12, 2016 16:26
Phoenix Router Extension
## Library Code
## Defines DSL to be used by Service Code
## in order to get properly consumed by Consume
defmodule Nectar.RouterExtension do
defmacro __using__(_opts) do
quote do
Module.register_attribute(__MODULE__, :defined_routes, accumulate: true)
import Nectar.RouterExtension, only: [define_route: 1]
@before_compile Nectar.RouterExtension