Skip to content

Instantly share code, notes, and snippets.

View sonianand11's full-sized avatar
🌞

Anand Soni sonianand11

🌞
View GitHub Profile
{
"handlers": {
"graphite": {
"type": "amqp",
"exchange": {
"type": "topic",
"name": "metrics",
"passive": "true"
},
"send_only_check_output": true
{
"rabbitmq": {
"port": 5672,
"host": "127.0.0.1"
},
"redis": {
"host": "localhost",
"port": 6379
},
"api": {
I want to create Task management app. Task has many assignee and one assignor. This is how I have created a association. Getting error of
ActiveRecord::HasManyThroughAssociationNotFoundError: Could not find the association :assignment in model User
class User < ActiveRecord::Base
attr_accessible :name
has_many :assignments,:foreign_key => "assignee_id"
has_many :tasks, :through => :assignment
end
<script>
$(document).ready(function(){
var startRecording = document.getElementById('start-recording');
var stopRecording = document.getElementById('stop-recording');
var uploadRecordingBtn = document.getElementById('upload-recording');
var cameraPreview = document.getElementById('camera-preview');
@sonianand11
sonianand11 / TestingFile
Last active August 29, 2015 14:02
This is for testing
class Foo
def initialize(thing)
@thing = thing
end
def test_me
if @thing.big?
'Big!'
else
'Small!'
package com.healthseva.widget;
import com.healthseva.R;
import com.healthseva.services.RandomTipService;
import com.healthseva.utility.ServiceUtility;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    passenger_root /path/to/.rvm/gems/ruby-2.3.0/gems/passenger-5.0.24;
    passenger_ruby /path/to/.rvm/gems/ruby-2.3.0/wrappers/ruby;
    include       mime.types;
#! /bin/sh
### BEGIN INIT INFO
# Provides:          nginx
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server
# Description:       starts nginx using start-stop-daemon
1) ActiveModel validation in rails server side :
class MyObject < ActiveRecord::Base
  validates :state, :presence => true
  validates :other_state, :presence => true, if: state.persent?
end
2) Lets say we have drop down with following state : 
<select id="stateDropdown" name="state">
#View original : https://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb
class Users::RegistrationsController < Devise::RegistrationsController
respond_to :json
# POST /resource
def create
build_resource(sign_up_params)