Skip to content

Instantly share code, notes, and snippets.

@sithu
sithu / lab_output
Last active August 29, 2015 14:22
LAB: IO Pattern & Strategies
### Test 1 Output
ubuntu@ip-172-31-3-94:~/IO-LAB/FIO-CFG$ fio rread-latency.cfg
rread-latency-test: (g=0): rw=randread, bs=16K-16K/16K-16K, ioengine=libaio, iodepth=1
fio 1.59
Starting 1 process
rread-latency-test: Laying out IO file(s) (1 file(s) / 10240MB)
Jobs: 1 (f=1): [r] [100.0% done] [28397K/0K /s] [1733 /0 iops] [eta 00m:00s]
rread-latency-test: (groupid=0, jobs=1): err= 0: pid=1813
read : io=2044.1MB, bw=34900KB/s, iops=2181 , runt= 60001msec
slat (usec): min=14 , max=2010 , avg=18.95, stdev= 7.17
@sithu
sithu / application.cpp
Created October 9, 2015 07:22 — forked from harrisonhjones/application.cpp
Spark Community - kokoro - Web Browser Issue
// Original Spark Community Thread: http://community.spark.io/t/how-to-access-the-core-via-we-browser/9711
// Code adapted from: http://arduino.cc/en/Tutorial/WebServer
/* Includes ------------------------------------------------------------------*/
#include "application.h"
SYSTEM_MODE(AUTOMATIC);
TCPServer server = TCPServer(80);
$ python cbdemo.py
Call-1:
Result=SUCCESS
Call-2:
Result=SUCCESS
Call-3:
Threw Dependency Exception
Call-4:
Threw Dependency Exception
Call-5:
@sithu
sithu / cbdemo.py
Created October 26, 2016 22:13
Test Code for cb.py
from time import sleep
from cb import CircuitBreaker
MY_EXCEPTION = 'Threw Dependency Exception'
@CircuitBreaker(max_failure_to_open=3, reset_timeout=3)
def dependency_call(call_num):
if call_num in (3, 4, 5, 6, 7, 17, 19):
raise Exception(MY_EXCEPTION)
else:
@sithu
sithu / Coding.txt
Last active October 27, 2016 01:27
Complete this Two-Stage (Open-and-Closed) circuit breaker implementation.
Initial state is set to _is_closed = True.
When the number of failure reaches to the limit, set the status to _is_closed = False along with _open_since time. Whenever the current time passes _open_since + _reset_timeout, the circuit breaker will let the call go through.
If the attempt is successful, reset the status to _is_closed = True and reset the failure count to zero.
To test your code, place this cbdemo.py (Links to an external site.) under the same location as cb.py. See the expected output (Links to an external site.) for a correct solution.
### cbdemo.py ####
https://gist.github.com/sithu/6aa4c0b1832f50704a5dc9f733b91a61
@sithu
sithu / .gitconfig
Created February 3, 2017 18:08 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
@sithu
sithu / gist:c56642b9e42cb6e2d9f191c5736ee506
Created March 21, 2017 16:39 — forked from trongthanh/gist:2779392
How to move a folder from one repo to another
# source: http://st-on-it.blogspot.com/2010/01/how-to-move-folders-between-git.html
# First of all you need to have a clean clone of the source repository so we didn't screw the things up.
git clone git://server.com/my-repo1.git
# After that you need to do some preparations on the source repository, nuking all the entries except the folder you need to move. Use the following command
git filter-branch --subdirectory-filter your_dir -- -- all
# This will nuke all the other entries and their history, creating a clean git repository that contains only data and history from the directory you need. If you need to move several folders, you have to collect them in a single directory using the git mv command.
@sithu
sithu / gradle-executable-jar.md
Created May 26, 2017 15:24 — forked from dehora/gradle-executable-jar.md
Executable fat jars via gradle

Executable fat jars are easy to deploy and upgrade, and don't need wrapper scripts to pull in the classpath. You can use the Gradle fatjar plugin to create executable, self-contained jars in Gradle, akin to the Shade plugin for Maven -

apply plugin: 'fatjar'
buildscript {
  dependencies {
  classpath 'eu.appsatori:gradle-fatjar-plugin:0.1.3'  
  }
}
"""
You must use hashlib to hash the node ('0.0.0.0:3000') and key ('mykey') combination.
Example:
x = '0.0.0.0:3000' + 'my-key'
x = node + key
hash = hashlib.md5(x).hexdigest()
More@https://docs.python.org/2/library/hashlib.html
"""
# TODO: Add any required import
@sithu
sithu / foo.log
Created July 10, 2017 16:07 — forked from ibeex/foo.log
Flask logging example
A warning occurred (42 apples)
An error occurred