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 / DownloadCatalogOperation.h
Created June 6, 2011 23:06
ASINetworkQueue - not calling my selectors.
#import <Foundation/Foundation.h>
@class ASINetworkQueue, Catalog, ASIHTTPRequest;
@interface DownloadCatalogOperation : NSOperation {
/* queue for downloading many assets in paralel */
ASINetworkQueue* networkQueue;
NSString* tmpDownloadPath;
Catalog* catalog;
@rantav
rantav / 2011_08_07.stderrout.log
Created August 8, 2011 11:22
errors in glu from outbrain
506543691 [qtp2136389305-1580] ERROR org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver - org.eclipse.jetty.io.EofException
org.eclipse.jetty.io.RuntimeIOException: org.eclipse.jetty.io.EofException
at org.eclipse.jetty.io.UncheckedPrintWriter.setError(UncheckedPrintWriter.java:107)
at org.eclipse.jetty.io.UncheckedPrintWriter.write(UncheckedPrintWriter.java:234)
at tmp_jetty_0_0_0_0_8080_org_linkedin_glu_console_webapp_3_2_0_war__console_any__webapp_WEB_INF_grails_app_views_layouts_main_gsp.run(tmp_jetty_0_0_0_0_8080_org_linkedin_glu_console_webapp_3_2_0_war__console_any__webapp_WEB_INF_grails_app_views_layouts_main_gsp:190)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:534)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1351)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1322)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1322)
at org.eclipse.jetty.se
@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;
@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 / 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...

// 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 / 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

@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 / 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
{ robot:
{ name: 'bot',
brain: [Object],
alias: false,
adapter: [Object],
commands: [Object],
Response: [Function: Response],
listeners: [Circular],
loadPaths: [Object],
enableSlash: undefined,