Skip to content

Instantly share code, notes, and snippets.

View ravinsinghd's full-sized avatar

Ravin Singh D ravinsinghd

View GitHub Profile
@ravinsinghd
ravinsinghd / Procfile
Created July 25, 2018 18:06 — forked from jordansissel/Procfile
Jenkins on Heroku
# Only listen on http; disable ajp and https
web: java -jar jenkins.war --httpPort=$PORT --ajp13Port=-1 --httpsPort=-1
@ravinsinghd
ravinsinghd / serviceworker.js
Created January 25, 2018 18:54 — forked from kosamari/serviceworker.js
cache index.html using Service Worker
/*
* CHALLANGE:
* Cache `index.html` file using service worker.
*
* This bit of code is included in <script> tag of index.html
* if (navigator.serviceWorker) {
* navigator.serviceWorker.register('serviceworker.js', {scope: '/'})
* }
*
*/
// Approach 1
function getMapping(){
const tagMap = {};
this.selectedTags.forEach(( tag, index ) => {
if ( tag !== undefined ) {
tagMap[ tag ] = this.headers[ index ];
}
} )
return tagMap;
}
getCounterLimit(limit=10){
return limit
}
validateLimit(getCounterLimit());
// want to overwrite the value for special case
validateLimit(getCounterLimit(15));
validateLimit(10);
.
.
.
validateLimit(10);
.
.
.
validateLimit(10);
function validateLimit(limit){
if(currentValue>limit){
return false;
}
return true;
}
let counterLimit;
function setCounterLimit(){
counterLimit=10;
}
function validateLimit(){
if(currentValue>counterLimit){
return false;
}
return true;
let counterLimit;
function setCounterLimit(){
counterLimit=10;
}
function validateLimit(){
if(currentValue>counterLimit){
return false;
}
return true;
@ravinsinghd
ravinsinghd / ckeditor.component.ts
Last active September 13, 2016 10:21
Angular2 CK Editor component
import { Component, ViewChild, EventEmitter, Output} from '@angular/core';
@Component({
selector: 'ck-editor',
template: '<textarea class="editor" #editor></textarea>'
})
export class CKEditorComponent {
@Output() change = new EventEmitter();
@ViewChild('editor') editor;
editorInstance: any = {};
@ravinsinghd
ravinsinghd / gist:c538401ddbed9e20a089ceac6899ae96
Created June 21, 2016 02:51 — forked from angeldm/gist:4663739
Detecting Font size using Tesseract+Leptonica
/*
http://pastebin.com/0dV84hBa
g++ -o test_font_features test_font_features-2.cpp -ltesseract
*/
#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>
int main() {
tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();