Skip to content

Instantly share code, notes, and snippets.

View nisanthchunduru's full-sized avatar

Nisanth Chunduru nisanthchunduru

View GitHub Profile
@nisanthchunduru
nisanthchunduru / gist:4608499
Last active February 13, 2020 09:38
Installing nodejs on debian using checkinstall
#!/bin/sh
##############################################################
#
# Rock-Solid Node.js Platform on Ubuntu
# Auto-config by apptob.org
# Author: Ruslan Khissamov, email: rrkhissamov@gmail.com
# GitHub: https://github.com/rushis
#
##############################################################
@nisanthchunduru
nisanthchunduru / gist:7514049
Created November 17, 2013 14:31
Using Auth Tokens in ActiveResource
#!/usr/bin/env ruby
# Using Auth Tokens in ActiveResource
# Borrowed from http://stackoverflow.com/questions/2918419/add-api-key-to-every-request-in-activeresource/6124110#6124110
require 'active_resource'
require 'awesome_print'
class Resource < ActiveResource::Base
class << self
@nisanthchunduru
nisanthchunduru / gist:9444421
Last active August 25, 2016 05:29
Iterate over file line by line using Enumerable
module ReadIngredients
class << self
include Enumerable
def each
while input = gets.chomp
break if end_of_input?(input)
yield input
end
@nisanthchunduru
nisanthchunduru / delete_failed_jobs.rb
Last active September 15, 2022 18:37
Selectively remove/retry failed jobs in Resque 1.x
def delete_failed_job_if
redis = Resque.redis
(0...Resque::Failure.count).each do |i|
string = redis.lindex(:failed, i)
break if string.nil?
job = Resque.decode(string)
should_delete_job = yield job
next unless should_delete_job
class CommentCreated < Action
include WatchersToBeNotified
watchers_to_be_notified {
ticket_attr_reader :ticket
categories {
agents to_be_notified_if: :all_comments
user_assignees to_be_notified_if: :comment_assignment
group_assignees to_be_notified_if: :comment_group_assignment
describe RepoSynchronizationJob do
it 'sets refreshing_repos to true before synchronization' do
is_refreshing_repos_set_to_true = Proc.new do |user_id|
User.find(user_id).refreshing_repos == true
end
user = create(:user, refreshing_repos: false)
github_token = 'token'
expect(user.refreshing_repos).to be_false
flexmock(RepoSynchronization).should_receive(:call).with(FlexMock.on(&is_refreshing_repos_set_to_true), Flexmock.any).once
@nisanthchunduru
nisanthchunduru / feature.rb
Last active August 29, 2015 14:13
Simple Feature Flipper in Ruby
require 'mock_redis'
class Feature
class << self
attr_accessor :redis
end
def initialize(name)
@name = name
end
# ...
namespace :deploy do
desc 'Restart application'
task :restart => ["eye:reload", "eye:restart"]
after :published, :restart
end
@nisanthchunduru
nisanthchunduru / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@nisanthchunduru
nisanthchunduru / gist:5f3a13260e036755b37a
Last active August 29, 2015 14:18
TDD Demo BITS Goa
require 'ansi'
def puts_red(text)
puts ANSI.red { text }
end
def puts_green(text)
puts ANSI.green { text }
end