Skip to content

Instantly share code, notes, and snippets.

View mshustov's full-sized avatar

Mikhail Shustov mshustov

  • ClickHouse
  • Berlin, Germany
View GitHub Profile
@mshustov
mshustov / genereate-so.js
Created January 10, 2022 17:18
generate empty dashboard and index-pattern SOs
/**
* A script to generate a bunch on empty dashboard and index-pattern SOs.
* Result of the script is written into bulk-create-api.json file.
* Created file can be imported into a Cloud instance with any network client.
* An example with curl:
POST https://{cloud_url}/s/{space-name}/api/saved_objects/_bulk_create?overwrite=true
Authorization: Basic {token}
Accept: application/json
Content-Type: application/json
kbn-xsrf: true
const config = {
endpointUrl: process.URL
}
if (document.body && ['complete', 'loaded', 'interactive'].indexOf(document.readyState) > -1) {
run();
} else {
document.addEventListener('DOMContentLoaded', run, false);
}
function run(){
console.log('I ran');
window.get()();
}
@mshustov
mshustov / error-stack-parser.js
Last active December 28, 2017 11:38
parse error stack
// "error-stack-parser": "2.0.1",
// "stacktrace-gps": "3.0.2"
// additional sources https://github.com/stacktracejs/stacktrace.js/blob/master/stacktrace.js#L102-L116
import fs from 'fs';
import path from 'path';
import { SourceMapConsumer } from 'source-map';
import StackTraceGPS from 'stacktrace-gps';
import ErrorStackParser from 'error-stack-parser';
import mapValues from 'lodash/mapValues';
var getSources = function(name) {
var filename = name.substr(templateParams.htmlWebpackPlugin.files.publicPath.length);
return templateParams.compilation.assets[filename].source();
}
templateParams.htmlWebpackPlugin.files.css.map(getSources)
templateParams.htmlWebpackPlugin.files.js.map(getSources)
var hello = 'hello';
var world = 'world';
var mark = '!';
var options = {
silent: true
};
function greet(options, first, second){
if (options.silent){
#!/bin/bash
REL_PATH=$(dirname $0)
cd $REL_PATH
env=$1
CONFIG=$(cat container-config/env-$env.sh | base64)
# delete the old config
sed -e "s/{{config_data}}/''/g" container-config/config-template.yaml | kubectl delete -f -
function(fn, cb){
var a = fn(cb);
var b;
setTimeout(function(){
b = fn(cb);
}, 100);
}
function Man(name, age){
this.name = name;
@mshustov
mshustov / checks.js
Last active August 29, 2015 14:16 — forked from andre487/checks.js
exports.fastElements = function(obj) {
if (%HasFastSmiElements(obj)) {
console.log('Fast SMI elements');
}
if (%HasFastSmiOrObjectElements(obj)) {
console.log('Fast SMI or Object elements');
}
if (%HasFastObjectElements(obj)) {
console.log('Fast Object elements');
}
@mshustov
mshustov / gist:82ef15b95bcdccce34aa
Last active August 29, 2015 14:14
handlebars like template
var reg = /\{\{(.+?)\}\}/gim;
var zz = 'hello {{name}} {{surname}}'.replace(reg, function(full, key){
switch(key){
case 'name':
return 'myName';
case 'surname':
return 'mySurname'
}
});