Skip to content

Instantly share code, notes, and snippets.

View imechemi's full-sized avatar

Tenzin Chemi imechemi

  • Apollo.io
  • India
  • 15:44 (UTC +05:30)
View GitHub Profile
@imechemi
imechemi / gist:87a46eb8547762ba7738
Last active August 29, 2015 14:27 — forked from rb2k/gist:8372402
A jenkins script to clean up workspaces on slaves
// Check if a slave has < 10 GB of free space, wipe out workspaces if it does
import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
for (node in Jenkins.instance.nodes) {
@imechemi
imechemi / fix-homebrew-npm.md
Created October 9, 2015 05:41 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

If you just want to fix the issue quickly, scroll down to the "solution" section below.

Explanation of the issue

If you're a Homebrew user and you installed node via Homebrew, there is a major philosophical issue with the way Homebrew and NPM work together. If you install node with Homebrew and then try to do npm update npm -g, you may see an error like this:

$ npm update npm -g
@imechemi
imechemi / error.log
Created March 6, 2017 09:42
splunk-ruby-sdk `sysread_nonblock': end of file reached (EOFError)
/usr/local/ruby/2.2.3/lib/ruby/2.2.0/openssl/buffering.rb:182:in `sysread_nonblock': end of file reached (EOFError)
from /usr/local/ruby/2.2.3/lib/ruby/2.2.0/openssl/buffering.rb:182:in `read_nonblock'
from /usr/local/ruby/2.2.3/lib/ruby/2.2.0/net/protocol.rb:153:in `rbuf_fill'
from /usr/local/ruby/2.2.3/lib/ruby/2.2.0/net/protocol.rb:134:in `readuntil'
from /usr/local/ruby/2.2.3/lib/ruby/2.2.0/net/protocol.rb:144:in `readline'
from /usr/local/ruby/2.2.3/lib/ruby/2.2.0/net/http/response.rb:39:in `read_status_line'
from /usr/local/ruby/2.2.3/lib/ruby/2.2.0/net/http/response.rb:28:in `read_new'
from /usr/local/ruby/2.2.3/lib/ruby/2.2.0/net/http.rb:1414:in `block in transport_request'
from /usr/local/ruby/2.2.3/lib/ruby/2.2.0/net/http.rb:1411:in `catch'
from /usr/local/ruby/2.2.3/lib/ruby/2.2.0/net/http.rb:1411:in `transport_request'
@imechemi
imechemi / error.log
Created July 11, 2017 04:25
This is the actual error log with PassengerLogLevel 7 and during incident time.
[ 2017-07-09 08:55:01.1282 6743/7fb4a7f34700 Uti/ScopeGuard.h:113 ]: File descriptor closed: 66
[ 2017-07-09 08:55:01.1284 6743/7fb4a7f34700 App/Poo/AnalyticsCollection.cpp:71 ]: Analytics collection done; next analytics collection in 4.872 sec
[ 2017-07-09 08:55:02.0688 6743/7fb476bfd700 Ser/Server.h:241 ]: [ApiServer] New clients can be accepted on a server socket
[ 2017-07-09 08:55:02.0690 6743/7fb476bfd700 Ser/Server.h:363 ]: [ApiServer] Creating new client object
[ 2017-07-09 08:55:02.0690 6743/7fb476bfd700 Ser/Server.h:575 ]: [Client A2041] Client associated with file descriptor: 66
[ 2017-07-09 08:55:02.0690 6743/7fb476bfd700 Ser/Server.h:261 ]: File descriptor purpose: 66: Server ApiServer, client A2041
[ 2017-07-09 08:55:02.0691 6743/7fb476bfd700 Ser/Server.h:267 ]: [ApiServer] 1 new client(s) accepted; there are now 1 active client(s)
[ 2017-07-09 08:55:02.0691 6743/7fb476bfd700 Ser/HttpServer.h:668 ]: [Client A2041] Event: onClientAccepted
[ 2017-07-09 08:55:02.0691 6743/7fb476bfd700 Ser/HttpServer
{"timestamp":"2017-07-09T13:54:54Z","severity":"FATAL","type":"exception","message":"ActionController::RoutingError(No route matches [HEAD] \"/client-solution-configuration-service/meta/availability\"): vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'","exception_id":"d39ef109fc87cd75b225cce1ceb03e5ed2103d5c","class":"ActionController::RoutingError","backtrace":["vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'","vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'","vendor/bundle/ruby/2.2.0/gems/streetcar-logging-0.6.0/lib/streetcar/logging/middleware.rb:22:in `block in call'","vendor/bundle/ruby/2.2.0/gems/streetcar-logging-0.6.0/lib/streetcar/logging/middleware.rb:33:in `block in instrument'","vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/notifications.rb:164:in `block in instrument'","vendor/bundle/ruby/2
{
"ensure_newline_at_eof_on_save": true,
"font_size": 13,
"ignored_packages":
[
"Vintage"
],
"line_padding_bottom": 1,
"line_padding_top": 1,
"rulers":
@imechemi
imechemi / prime_generator.rb
Created June 13, 2019 09:28
Object Oriented Prime Generator
class Prime
def initialize()
@value = 2
end
def value
@value
end
def next
@imechemi
imechemi / Application.java
Created November 5, 2019 03:56
How to use Standalone MongoTemplate in Main class
@SpringBootApplication
public class Application implements CommandLineRunner {
@Autowired
private DeviceRepository deviceRepository;
public static void main(String[] args) {
SpringApplication.run(Application.class);
// MongoOperations mongoOps = new MongoTemplate(new SimpleMongoDbFactory(new MongoClient(), "test"));
// RepositoryFactorySupport repositoryFactorySupport = new MongoRepositoryFactory(mongoOps);
@imechemi
imechemi / Application.java
Created November 6, 2019 05:39
How to get ApplicationContext from Spring with Java config
public class Application {
public static void main(String[] args) {
ApplicationContext ctx = new AnnotationConfigApplicationContext(SOTelemetryDbConfig.class);
}
}