Skip to content

Instantly share code, notes, and snippets.

# https://unix.stackexchange.com/questions/82598/how-do-i-write-a-retry-logic-in-script-to-keep-retrying-to-run-it-upto-5-times/82610
function fail {
echo $1 >&2
exit 1
}
function retry {
local n=1
local max=5
@mosfet1kg
mosfet1kg / retry.sh
Created December 4, 2017 13:24 — forked from dublx/retry.sh
Bash - retry command N times
#!/bin/bash
set -euo pipefail
function myFunction() {
myCommand
return $?
}
retry=0
maxRetries=5
@mosfet1kg
mosfet1kg / class_decorator.ts
Created October 8, 2017 15:01 — forked from remojansen/class_decorator.ts
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@mosfet1kg
mosfet1kg / hbase.rest.scanner.filters.md
Created August 4, 2017 08:27 — forked from stelcheck/hbase.rest.scanner.filters.md
HBase Stargate REST API Scanner Filter Examples

Stargate Scanner Filter Examples

Introduction

So yeah... no documentation for the HBase REST API in regards to what should a filter look like...

So I installed Eclipse, got the library, and took some time to find some of the (seemingly) most useful filters you could use. I'm very green at anything regarding HBase, and I hope this will help anyone trying to get started with it.

What I discovered is that basically, attributes of the filter object follow the same naming than in the documentation. For this reason, I have made the link clickable and direct them to the HBase Class documentation attached to it; check for the instantiation argument names, and you will have your attribute list (more or less).

var redis = require("redis")
, subscriber = redis.createClient()
, publisher = redis.createClient();
subscriber.on("message", function(channel, message) {
console.log("Message '" + message + "' on channel '" + channel + "' arrived!")
});
subscriber.subscribe("test");
@mosfet1kg
mosfet1kg / sayswho.js
Created April 19, 2017 10:47
sayswho
navigator.sayswho= (function(){
var ua= navigator.userAgent, tem,
M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if(/trident/i.test(M[1])){
tem= /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE '+(tem[1] || '');
}
if(M[1]=== 'Chrome'){
tem= ua.match(/\b(OPR|Edge)\/(\d+)/);
if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
@mosfet1kg
mosfet1kg / resource_timing.js
Created April 13, 2017 12:07
resource timing api example
<!doctype html>
<html>
<head>
</head>
<body onload="loadResources()">
<script>
function loadResources()
{
var start = new Date().getTime();
var image1 = new Image();
@mosfet1kg
mosfet1kg / gulpfile.js
Last active March 13, 2017 08:04
gulpfile.js
var gulp = require('gulp');
var browserSync = require("browser-sync").create();
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var livereload = require('gulp-livereload');
var usemin = require('gulp-usemin');
var uglify = require('gulp-uglify');
@mosfet1kg
mosfet1kg / date.js
Created March 7, 2017 05:07
java date
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Solution 11.2</title>
<script type = "text/javascript">
function printNow()
{
var curr = new Date();
window.alert("The time and date are: " + curr.toString());
}
@mosfet1kg
mosfet1kg / get_dom_position.js
Created March 5, 2017 11:26
GET DOM Position with Angular
console.log( cumulativeOffset( el[0].children[0]) );
function cumulativeOffset(element) {
var top = 0, left = 0;
do {
top += element.offsetTop || 0;
left += element.offsetLeft || 0;
element = element.offsetParent;
} while(element);
return {