Skip to content

Instantly share code, notes, and snippets.

View allupaku's full-sized avatar

Alt Ctrl Del allupaku

  • Diamond Light Source
  • United Kingdom
View GitHub Profile

Parse the kubernetes manifest in yaml or json, don't care a manifest type.

Examples:

package main

import (
	"bytes"
	"context"
@allupaku
allupaku / .htaccess
Created January 20, 2017 07:01 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
/**
* Flatten an Array of Integers
*
* @param {Array} integers_array - Array of Numbers
* @return {Array} - Array of Numbers , flattened
*
*/
function flatten(integers_array) {
all_results = [];
@allupaku
allupaku / Order.js
Last active November 7, 2017 14:38
This is a modified version for createChangeStream - because the default implementation as of today is not supporting where filter. This is using the same approach from persisted model and using loopback-filters for parsing the data which is been passed in. This may not be a perfect solution but a good workaround till we get the filters in core c…
var applyFilter = require('loopback-filters');
var loopback = require('loopback');
var PassThrough = require('stream').PassThrough;
module.exports = function(Order) {
Order.createChangeStream = function(options,cb) {
/* Based on persisted-model#createChangeStream
@allupaku
allupaku / controller.snippet.js
Created February 15, 2016 08:31 — forked from njcaruso/controller.snippet.js
Custom loopback change-stream to only show stream updates from the logged in user. The intent is to have a `Message` model that contains private messages for users. The current implementation of change-stream while it accepts an options.where clause, it does not use it. See https://github.com/strongloop/angular-live-set/issues/11.
var url = '/api/messages/stream-updates' +
'?access_token=' + LoopBackAuth.accessTokenId;
var src = new EventSource(url);
var changes = createChangeStream(src);
var set;
Message.find({
filter: {
where: {