Skip to content

Instantly share code, notes, and snippets.

View rantav's full-sized avatar
🎯
Focusing

Ran Tavory rantav

🎯
Focusing
View GitHub Profile
@rantav
rantav / call_for_papers_reversim_summit.rb
Created December 6, 2012 23:47
Call for Papers, Reversim Summit 2013
require 'speaker'
require 'israel'
module Israel
module Summit
def call_for_papers(speaker, subject)
apply(spekaer) if ["DevOps, NoOps, Continuous Deployment, Dev Culture",
"Software Craftsmanship",
"Mobile dev",
"Web dev",
@rantav
rantav / gist:3945810
Created October 24, 2012 12:28
Chef processes
$ ps aux | grep chef
ubuntu 6122 0.0 0.0 7800 636 pts/3 S+ 12:24 0:00 grep --color=auto chef
root 8819 0.1 2.7 137336 47132 ? Sl Oct18 10:54 /opt/chef/embedded/bin/ruby /usr/bin/chef-client -d -P /var/run/chef/client.pid -L /var/log/chef/client.log -c /etc/chef/client.rb -i 1800 -s 20
chef 16025 0.2 7.4 649552 127244 ? Sl Sep19 101:34 java -Xmx256M -Xms256M -Dsolr.data.dir=/var/lib/chef/solr/data -Dsolr.solr.home=/var/lib/chef/solr/home -jar /var/lib/chef/solr/jetty/start.jar
chef 16084 0.5 4.3 186180 74012 ? Sl Sep19 282:09 merb : chef-server (api) : worker (port 4000)
chef 16152 0.5 3.2 141916 54408 ? Sl Sep19 259:50 merb : chef-server-webui : worker (port 4040)
$ ps aux | grep couch
ubuntu 6124 0.0 0.0 7800 640 pts/3 S+ 12:25 0:00 grep --color=auto couch
couchdb 7466 0.0 0.0 4220
{ robot:
{ name: 'bot',
brain: [Object],
alias: false,
adapter: [Object],
commands: [Object],
Response: [Function: Response],
listeners: [Circular],
loadPaths: [Object],
enableSlash: undefined,
@rantav
rantav / uname
Created October 13, 2012 19:22
Kernel bug found by chef-client on ubuntu 11.04 ec2
[119832.732086] BUG: unable to handle kernel NULL pointer dereference at 0000000000000038
[119832.732111] IP: [<ffffffff81053527>] pick_next_task_fair+0xa7/0x1a0
[119832.732124] PGD 1cee6f067 PUD 1cd5e7067 PMD 0
[119832.732132] Oops: 0000 [#1] SMP
[119832.732137] last sysfs file: /sys/devices/system/cpu/cpu1/cache/index2/shared_cpu_map
[119832.732145] CPU 1
[119832.732147] Modules linked in: acpiphp raid456 async_pq async_xor xor async_memcpy async_raid6_recov raid10 raid6_pq async_tx raid1 raid0 multipath linear
[119832.732172]
[119832.732177] Pid: 7896, comm: chef-client Not tainted 2.6.38-8-virtual #42-Ubuntu
[119832.732186] RIP: e030:[<ffffffff81053527>] [<ffffffff81053527>] pick_next_task_fair+0xa7/0x1a0
@rantav
rantav / call_for_papers_devopsil.rb
Created October 12, 2012 12:50
Call For Papers DevOps IL 2013
require 'speaker'
require 'israel'
module Israel
module DevOps
def call_for_papers(speaker, subject)
# Speakers should apply for the call for papers if they have talks on the subjects of Continuous Deployment of DevOps tooling
# Assuming they are available Jan 13.
apply(spekaer) if ["Continuous Deployment Case Studies", "DevOps tools"].include(subject) and speaker.available?(Date.new(2013,1,13))
end
@rantav
rantav / read.md
Created September 12, 2012 07:40
Using newrelic with maven, Java

When using newrelic in java, it isn't obvious how to mavenize things. Newrelic has two java jars: newrelic.jar and newrelic-api.jar. There's also another newrelic.yaml of course. For development you need the api.jar in your classpath. In production you want the api jar in the classpath, but also newrelic.jar as an agent. Newrelic have a good explanation about how to set up newrelic.jar as an agent but they don't have anything regarding how to develop and get the api jar in place using maven, so here goes...

Add the repository:

<repositories>
  <repository>
    <id>newrelic</id>

newrelic

// Old style mongodb group and a bit more of javascript to complete the task (Array.sort and Array.slice)
db.Session.group({
key: {user: true},
cond: {
serviceId: '888',
end: {$gte: ISODate('2012-08-30T00:00:00Z'), $lte: ISODate('2012-08-31T00:00:00Z')},
start: {$lte: ISODate('2012-08-31T00:00:00Z')}
},
initial: {durationSeconds: 0},
reduce: function(obj, prev) {prev.durationSeconds += obj.durationSeconds;}
@rantav
rantav / README.md
Created August 23, 2012 06:13
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...

@rantav
rantav / README.md
Created June 27, 2012 05:18
MongoDB increment or insert

In mongodb it's easy to make at upsert, meaning update-or-insert by calling

db.collection.update({criteria}, {updated fields}, true)

The third parameter means - insert a new document if the document doesn't exist yet. So, for example, the following will insert a new document for the user if there's no document for that user yet, and will update it if it already exists:

 db.users.update({user_id: '1234'}, {user_id: '1234', name: 'Ran'}, true)
@rantav
rantav / SpringBoardIconCell.h
Created November 9, 2011 08:53
AQGridView AQGridViewLayoutDirectionHorizontal bug
#import <UIKit/UIKit.h>
#import "AQGridViewCell.h"
@interface SpringBoardIconCell : AQGridViewCell
{
UIImageView * _iconView;
UILabel* indexLabel;
}
- (id) initWithFrame:(CGRect)frame reuseIdentifier:(NSString*)reuseIdentifier;