Skip to content

Instantly share code, notes, and snippets.

View diatmpravin's full-sized avatar

Pravin Mishra diatmpravin

View GitHub Profile
@diatmpravin
diatmpravin / jenkins-docker
Created November 3, 2016 02:58
Jenkins: Can't connect to Docker daemon
After the installation of Jenkins and Docker. Add jenkins user to dockergroup (like you did)
sudo gpasswd -a jenkins docker
Edit the following file
vi /usr/lib/systemd/system/docker.service
@diatmpravin
diatmpravin / mesos-jenkins-marathon
Created March 31, 2016 19:17
mesos-jenkins-marathon json
{
"id": "jenkins",
"cmd": "cd jenkins-standalone-master && ./jenkins-standalone.sh -z $(cat /etc/mesos/zk) -r 127.0.0.1:6379",
"cpus": 0.5,
"mem": 256,
"disk": 1024,
"instances": 1,
"ports": [
0
],
{
"id": "jenkins",
"cmd": null,
"cpus": 1,
"mem": 512,
"disk": 1000,
"instances": 1,
"container": {
"docker": {
"image": "jenkins",
@diatmpravin
diatmpravin / jenkins-json-with-volume
Created April 2, 2016 09:51
jenkins-json-with-volume
{
"id": "jenkins",
"cmd": "cd jenkins-mesos-deployment-master && ./jenkins-standalone.sh -z $(cat /etc/mesos/zk) -r 10.1.0.18:6379",
"cpus": 1,
"mem": 1024,
"disk": 1024,
"instances": 1,
"ports": [
0
],
@diatmpravin
diatmpravin / any_of
Last active December 18, 2015 07:09
Add `#any_of` query method to active_record
1.9.3-p392 :060 > Address.all
Address Load (0.4ms) SELECT "addresses".* FROM "addresses"
+----+---------+--------+---------+---------+----------+-------+--------+-------------------------+-------------------------+
| id | user_id | extra | city | country | postcode | state | street | created_at | updated_at |
+----+---------+--------+---------+---------+----------+-------+--------+-------------------------+-------------------------+
| 1 | 1 | ankit | asansol | india | 71475 | w.b. | 100 | 2013-06-09 09:22:04 UTC | 2013-06-09 09:22:04 UTC |
| 2 | 1 | sanyam | asansol | india | 71476 | w.b. | 101 | 2013-06-09 09:22:05 UTC | 2013-06-09 09:22:05 UTC |
| 3 | 2 | abhay | asansol | india | 71476 | w.b. | 102 | 2013-06-09 09:22:05 UTC | 2013-06-09 09:22:05 UTC |
| 4 | 3 | abhay | bettiah | india | 71476 | w.b. | 102 | 2013-06-09 09:22:05 UTC | 2013-06-09 09:22:05 UTC |
+----+---------+--------+---------+---------+---
@diatmpravin
diatmpravin / gist:4654474
Created January 28, 2013 10:31
rspec code
require 'spec_helper'
describe Import do
TEST_FILENAME = 'test/fixtures/csv/2XU.txt'
ERROR_FILENAME = 'test/fixtures/csv/2XU_errors.txt'
before :all do
HEADER_ROWS = 2
VARIATION_THEMES = %w(Size Color SizeColor)
@diatmpravin
diatmpravin / gist:4596654
Created January 22, 2013 17:54
multi-table-ex
class User < ActiveRecord::Base
attr_accessible :fname, :lname
has_many :parents, :dependent => :destroy
def self.export_to_csv(filename, model, options = {})
csv_options = {}
csv_options[:col_sep] = options[:separator] || ','
header = User.header(model,options = {})
data = User.data(model)
@diatmpravin
diatmpravin / gist:4503766
Created January 10, 2013 16:59
active-admin-sample-form-index-show for nested form
ActiveAdmin.register Bar do
# controller.load_and_authorize_resource
controller do
load_and_authorize_resource :except => [:update, :index, :show, :edit]
def scoped_collection
end_of_association_chain.accessible_by(current_ability)
end
end
D, [2015-03-19T06:01:53.847340 #8589] [task:296] DEBUG -- : Acquired connection: 44478040
D, [2015-03-19T06:01:53.847695 #8589] [task:296] DEBUG -- : (0.000233s) SELECT * FROM "tasks" WHERE "id" = 296
D, [2015-03-19T06:01:53.848068 #8589] [task:296] DEBUG -- : Released connection: 44478040
D, [2015-03-19T06:01:53.948256 #8589] [task:296] DEBUG -- : Acquired connection: 44478040
D, [2015-03-19T06:01:53.948610 #8589] [task:296] DEBUG -- : (0.000248s) SELECT * FROM "tasks" WHERE "id" = 296
D, [2015-03-19T06:01:53.948964 #8589] [task:296] DEBUG -- : Released connection: 44478040
D, [2015-03-19T06:01:54.049156 #8589] [task:296] DEBUG -- : Acquired connection: 44478040
D, [2015-03-19T06:01:54.049490 #8589] [task:296] DEBUG -- : (0.000230s) SELECT * FROM "tasks" WHERE "id" = 296
D, [2015-03-19T06:01:54.049838 #8589] [task:296] DEBUG -- : Released connection: 44478040
E, [2015-03-19T06:01:54.061176 #8589] [compile_package(memcached/cb508a2dc25a3aeafacddbd43574f300a50101da, bosh-openstack-kvm-ubuntu/2427)] ERROR -- :
def facebook
if facebook.nil?
FbGraph::User.new('me', :access_token => self.fbauth.token).fetch
else
return facebook
end
end