Skip to content

Instantly share code, notes, and snippets.

:octocat:
Focusing

kamal namdeo kamal-github

:octocat:
Focusing
Block or report user

Report or block kamal-github

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kamal-github
kamal-github / graceful.go
Created Apr 1, 2018 — forked from peterhellberg/graceful.go
*http.Server in Go 1.8 supports graceful shutdown. This is a small example.
View graceful.go
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"time"
)
View redis_pubsub_demo.rb
# 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
View concurrent-non-redundant-non-blocking-cache.go
// Func is the type of the function to memoize.
type Func func(key string) (interface{}, error)
type result struct {
value interface{}
err error
}
type entry struct {
res result
View gist:95f44c7fe22225c7b5cd59bce400355a
type T struct {
A int
B string
}
t := T{23, "skidoo"}
s := reflect.ValueOf(&t).Elem()
typeOfT := s.Type()
for i := 0; i < s.NumField(); i++ {
@kamal-github
kamal-github / program-for-array-rotation-continued-reversal-algorithm
Created Mar 27, 2017
program-for-array-rotation-continued-reversal-algorithm
View program-for-array-rotation-continued-reversal-algorithm
#ex array
def rev_rotation_by_d(a, d)
d.times do
a << a.shift
end
a
end
def rotation_by_d(a, d)
d.times do
View jpaContext.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
<context:annotation-config />
<context:component-scan base-package="com.lorem.Todo" />
@kamal-github
kamal-github / gist:b89802cc06b1fae85666fa0028b9526a
Created Aug 25, 2016
Include this module to make your class instance variable accessible to subclass which doesn't declare that variable(ref - http://www.railstips.org/blog/archives/2006/11/18/class-and-instance-variables-in-ruby/)
View gist:b89802cc06b1fae85666fa0028b9526a
module ClassLevelInheritableAttributes
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def inheritable_attributes(*args)
@inheritable_attributes ||= [:inheritable_attributes]
@inheritable_attributes += args
args.each do |arg|
View sneakers.rb
require 'sneakers'
Sneakers.configure heartbeat: 5,
amqp: ENV['RABBITMQ_BIGWIG_URL'] || 'amqp://guest:guest@localhost:5672/order',
workers: 1,
timeout_job_after: 60,
threads: 5,
prefetch: 5,
after_fork: Proc.new { ActiveRecord::Base.establish_connection },
durable: true
View rails snippets
snippet art
assert_redirected_to ${1:action}: '${2:index}'
snippet artnp
assert_redirected_to ${1:parent}_${2:child}_path(${3:@$1}, ${0:@$2})
snippet artnpp
assert_redirected_to ${1:parent}_${2:child}_path(${0:@$1})
snippet artp
assert_redirected_to ${1:model}_path(${0:@$1})
snippet artpp
assert_redirected_to ${0:model}s_path
You can’t perform that action at this time.