Skip to content

Instantly share code, notes, and snippets.

View cggaurav's full-sized avatar
🏠
Working from home

Gaurav cggaurav

🏠
Working from home
View GitHub Profile
@cggaurav
cggaurav / content.json
Created November 17, 2016 13:50
Unfluff Extractor
{
"title": "Shovel Knight review",
"softTitle": "Shovel Knight review: rewrite history",
"date": "2014-06-26T13:00:03Z",
"copyright": "2016 Vox Media Inc Designed in house",
"author": [
"Griffin McElroy"
],
"publisher": "Polygon",
"text": "Shovel Knight is inspired by the past in all the right ways — but it's far from stuck in it. [.. snip ..]",
@cggaurav
cggaurav / rspec.rb
Created September 16, 2016 06:24
Assert select tests in Rspec
# assert_select ".subscription-title", text: /Hello World/, count: 1
@cggaurav
cggaurav / competencies.json
Last active May 29, 2016 14:00
Competencies
[{"key":"Legislators","region":"Chief Executives, Senior Officials and Legislators","subregion":"Legislators and Senior Officials","value":2},{"key":"Senior Government Officials","region":"Chief Executives, Senior Officials and Legislators","subregion":"Legislators and Senior Officials","value":1},{"key":"Traditional Chiefs and Heads of Villages","region":"Chief Executives, Senior Officials and Legislators","subregion":"Legislators and Senior Officials","value":2},{"key":"Senior Officials of Special-interest Organizations","region":"Chief Executives, Senior Officials and Legislators","subregion":"Legislators and Senior Officials","value":1},{"key":"Managing Directors and Chief Executives","region":"Chief Executives, Senior Officials and Legislators","subregion":"Managing Directors and Chief Executives","value":2},{"key":"Finance Managers","region":"Administrative and Commercial Managers","subregion":"Business Services and Administration Managers","value":1},{"key":"Human Resource Managers","region":"Administr
@cggaurav
cggaurav / endpoitns.txt
Last active May 29, 2016 10:55
Develop endpoints for Compentency
DEVELOP
API
http://competency-api-develop.competency.e176268b.svc.dockerapp.io:4001/
ES
http://competency-elasticsearch-develop.competency.b2392548.svc.dockerapp.io:9200/
SITE
http://competency-site-develop.competency.f86c9404.svc.dockerapp.io:4003/
it is very unusual that you needed to do an unsafe_rollback, unless some replicas were down.
In general, you can switch over the primary manually without a full reconfigure by doing the following. This can reduce the time of table unavailability compared to a full `reconfigure`:
1. Run `r.table(...).config()`
2. Copy out the value of the "shards" field. Here's a simple example:
[{"nonvoting_replicas": [], "primary_replica": "newton_s4j", "replicas": ["newton_s4j"]}]
3. Replace the values of the "primary_replica" fields where necessary by the new server name. If your goal is to shut down the old primary in the end, you should also remove it from all "replicas" lists. For easy editing, you can just copy the value into a text editor.
4. Run `r.table(...).config().update({shards: newShardsValue})` to apply the new configuration
@cggaurav
cggaurav / tag.js
Created April 28, 2016 14:11
Update tags during migration
r.db('rethinkdb').table('server_config').filter(function(doc){
return doc('name').match("api_rethinkdb_failover")
}).update({tags: ['secondary', 'default']})
@cggaurav
cggaurav / dc.bash
Created April 14, 2016 13:57
Docker compose stuff
drestart () { echo Restarting dev machine...; docker-machine restart dev; eval "$(docker-machine env dev)"; }
denv () { echo Setting dev env...; eval "$(docker-machine env dev)"; echo Done!; }
dstart () { echo Starting dev machine...; docker-machine start dev; denv; }
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ; } # to start vs code with alias code
sut-cache() { docker run --name builder_cache --entrypoint /bin/true tutum/builder; }
sut() { sut-cache; docker run --rm -it --privileged --volumes-from builder_cache -v $HOME/.docker:/.docker:ro -v $(pwd):/app tutum/builder; }
dc() { docker-compose -f docker-compose.yml build --no-cache && docker-compose -f docker-compose.yml up; }
drem() { docker-compose rm;}
@cggaurav
cggaurav / starfield.html
Created March 11, 2016 11:10
Starfield
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Starfield</title>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<meta http-equiv="content-language" content="en">
<meta name="description" content="javascript+canvas starfield">
<meta name="keywords" content="starfield, star,3d,effect,visual,javascript,canvas,dhtml,webdesign,google,chrome">
/var/lib/docker/containers/*/*.log {
rotate 7
daily
compress
delaycompress
copytruncate
sharedscripts
postrotate
/usr/bin/docker restart forwarder
endscript
@cggaurav
cggaurav / e.js
Created December 15, 2015 15:51
Ericson
{
"GetDataBySecureResult": {
"SearchNumber": "5560160680",
"TransactionId": "1450194642649",
"Block_Name": "TAXISTHLM_C_BASIC",
"Parameters": {
"schema": {
"attributes": {
"id": "NewDataSet"
},