Skip to content

Instantly share code, notes, and snippets.

View PankajWorks's full-sized avatar

Pankaj Singh PankajWorks

  • HortonWorks, Cloudera, Delphix
View GitHub Profile
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
path("in") {
extractUri { uri =>
val st:Future[String] = getDefaultStrategy("abc").map(st=>st.name).recover{case f => "invalid" }
val urlTo = s match {
case "case1" => UriBuilder.build("abc").withPath(Uri.Path("/test/continue")).withQuery(Uri.Query(uri.rawQueryString))
case "case2" => UriBuilder.build("abc").withPath(Uri.Path("/test/login")).withQuery(Uri.Query(uri.rawQueryString))
case _ => UriBuilder.build("abc").withPath(Uri.Path("/test/login")).withQuery(Uri.Query(uri.rawQueryString))
}
// After the future resolve we want to redirect using redirect(urlTo, StatusCodes.SeeOther)

OS - Ubuntu 16.04.4 LTS

Install

sudo apt-get update
sudo ntpdate pool.ntp.org
sudo apt-get install ntp

Install Python3.7

@PankajWorks
PankajWorks / release-summary-card.hbs
Created July 3, 2018 04:26
release-summary component
{{#if getSummary.isIdle}}
<div class="card card-shadow card-body">
<div class="card-header">
{{build}}
{{!--
<div class="col-md-2">
<div class="input-group">
<span class="input-group-addon lowrisk">Low Risk : Pass% &gt; </span>
{{input value=risk.low class="form-control"}}
<div class="card-deck-wrapper">
<div class="card-deck">
{{#each-in releaseVersions as |key value|}}
<div class="col-md-4 col-sm-6">
<div class="card" style="margin-top:10px">
<div class="card-header">
{{key}}
</div>
<div class="card-block">
{{#each value as |version|}}
@PankajWorks
PankajWorks / mongoc.py
Created April 30, 2018 09:03
Sample code related to mongo using aggregation
'''
# Sample api endpoint
@app.route('/api/v1/test')
def testapi():
oid = oid_from_now(5)
col = 'unit_test'
result = []
import re
REGEX = re.compile('HDF-3.2.0.0*')
query = {"$and": [{"_id": {"$gt": bson.ObjectId(oid)}},
@PankajWorks
PankajWorks / get_json_data.py
Created February 7, 2018 08:53
convert to json
def get_task_json_data(data,length=256):
try:
json_data = None
if data and len(data)>length:
return error(400, 'value is > expected characters i.e. %s' % length)
elif data and not isinstance(data,dict):
return error(400, 'value is not a dictonary/json: %s' % data)
elif data and isinstance(data,dict):
json_data = json.dumps(data)
status = 0
@PankajWorks
PankajWorks / person-form.hbs
Created December 21, 2017 09:53
Ember : submit a form
<form {{action 'savePerson' person on='submit'}} class="form-inline">
<div class="input-group">
{{input value=person.name class='form-control'}}
<div class="input-group-btn">
<button type="submit" class="btn btn-success" disabled={{person.isNotValid}}>Save</button>
<button class="btn btn-danger" {{action 'cancelPersonEdit' person}}>Cancel</button>
</div>
</div>
</form>
@PankajWorks
PankajWorks / updateDateTime.js
Last active March 2, 2017 10:11
Ember - How to update date time - Example
// Sample handelbar code <h5> Current System Date- {{utctime}} (UTC)</h5>
import Ember from 'ember';
import config from './../config/environment';
export default Ember.Route.extend({
query: 'from_unixtime(start_time)>=curdate() and from_unixtime(start_time)<=DATE_ADD(curdate(),INTERVAL+1 day)',
model() {
var store = this.store;
return Ember.RSVP.hash({
@PankajWorks
PankajWorks / .gitignore
Created December 2, 2016 15:15 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #