Skip to content

Instantly share code, notes, and snippets.

View xmlking's full-sized avatar
🌝
Write code that will last longer than You

Sumanth Chinthagunta xmlking

🌝
Write code that will last longer than You
View GitHub Profile
@xmlking
xmlking / Enum.es6.js
Last active June 25, 2019 18:09
JavaScript Enums with ES6, Type Checking and Immutability
export class EnumSymbol {
sym = Symbol.for(name);
value: number;
description: string;
constructor(name: string, {value, description}) {
if(!Object.is(value, undefined)) this.value = value;
if(description) this.description = description;
@xmlking
xmlking / MessagingController.groovy
Last active November 15, 2019 13:59
How to secure WebSocket connections (WebSocket over STOMP) ? Grails sample app : https://github.com/xmlking/grails-batch-rest
import grails.plugin.springsecurity.annotation.Secured
import org.springframework.messaging.handler.annotation.DestinationVariable
import org.springframework.messaging.handler.annotation.MessageMapping
import org.springframework.messaging.handler.annotation.SendTo
import org.springframework.messaging.simp.annotation.SendToUser
import org.springframework.messaging.simp.annotation.SubscribeMapping
import org.sumo.apiapp.stomp.StompExceptionHandler
import java.security.Principal
@xmlking
xmlking / test.html
Last active August 29, 2015 14:26
Demonstrate streaming JSON data parsing with OboeJS lib. Client consuming streaming REST endpoint implemented using NodeJS/RxJava/Ratpack etc and -chunked transfer- encoding
<html>
<head>
<title>OboeJS demo</title>
<script src="https://rawgit.com/jimhigson/oboe.js/v2.1.2/dist/oboe-browser.min.js"></script>
</head>
<body>
<div ></div>
<ul id="content">
<li>AUD_CAD:</li>
</ul>
@xmlking
xmlking / info.md
Created September 4, 2015 23:59
installing angular-new-router with JSPM without pulling unnecessary dependencies

How to install angular-new-router with JSPM without pulling unnecessary dependencies into jspm.config.js:

 jspm install npm:angular-new-router -o '{"main": "dist/router.es5", "format": "es6",  "dependencies": {"jspm:angular": "^1.4.5"}, "shim": { "dist/router.es5": {"deps": ["angular"]} } }'

Change Angular version if you are different version. with shim it also makesure angular is loaded before angular-new-router

@xmlking
xmlking / README.md
Last active September 21, 2015 21:50
Amazon Dash Button triggering Auth0's `webtask` to send text message when button is pressed.

Node-Dash-Button-Webtasks

Simple demo showcasing IoT and Auto0's Webtask integration.

npm install wt-cli -g

wt create send_text.js --name send_text -s TWILIO_ACCOUNT_SID=aaaa -s TWILIO_AUTH_TOKEN=aaa -s TWILIO_NUMBER=+15005550006
@xmlking
xmlking / server.js
Created October 25, 2015 23:30
Koa 2.0.0 supports ES2016 async/await
import Koa from 'koa';
const app = new Koa();
// x-response-time
app.use(async (ctx, next) => {
var start = new Date;
await next();
const ms = new Date - start;
ctx.set('X-Response-Time', ms + 'ms');
@xmlking
xmlking / README.md
Created May 13, 2016 17:51 — forked from johnlindquist/README.md
Angular 2 Wikipedia Image Search

Angular2 Starter Gist Run

@xmlking
xmlking / nifi-twitter.groovy
Last active June 1, 2016 21:48
Example script for Apache NiFi's ExecuteScript Processor using @grab Ref: http://funnifi.blogspot.com/2016/05/using-groovy-grab-with-executescript.html . Set dynamic properties for ExecuteScript with your twitter consumerKey, consumerSecret accessToken and secretToken
@Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.7')
@Grab('oauth.signpost:signpost-core:1.2.1.2')
@Grab('oauth.signpost:signpost-commonshttp4:1.2.1.2')
import groovy.json.JsonOutput
import groovyx.net.http.RESTClient
import static groovyx.net.http.ContentType.*
import org.apache.http.params.HttpConnectionParams
import com.crossbusiness.nifi.processors.NiFiUtils as util
@xmlking
xmlking / TodosService.ts
Created May 28, 2016 16:22
Observable - Observer
import { Http } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';
import 'rxjs/add/operator/share';
import { Todo } from 'app/interfaces';
export class TodosService {
todos$: Observable<Todo[]>;
private _todosObserver: Observer<Todo[]>;
private _dataStore: {
@xmlking
xmlking / index.html
Last active July 19, 2025 18:30
web-bluetooth demo with Polar H7 Heart Rate Monitor *** need Chrome v54 ***
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
<script src="script.js"></script>
</head>
<body>
<div class='hr-table'>
<div class='hr-row'>
<div class='hr-cell'>
<div class='hr-header'>Heart Rate:</div>