Skip to content

Instantly share code, notes, and snippets.

View SuddenDevelopment's full-sized avatar
🤖

SuddenDevelopment SuddenDevelopment

🤖
View GitHub Profile
@SuddenDevelopment
SuddenDevelopment / kibana scripted field
Created May 7, 2020 20:17
example kibana painless script to allow missing values and dynamic field names
int intTotal = 0;
int intMissed = 0;
for (int i = 0; i < 2; ++i) {
for (int ii = 0; ii < 9; ++ii) {
String strField = 'Private.Network.EthSwitch'+ i + '.Port'+ ii+ '.RxBytes';
if (!doc.containsKey(strField) || doc[strField].empty){
intMissed += 1;
}else{
intTotal += doc[strField].value;
}
@SuddenDevelopment
SuddenDevelopment / kill docker.sh
Last active July 23, 2020 15:08
kill all docker on a host
# --kill everything
sudo docker stop $(sudo docker ps -a -q)
sudo docker rm $(sudo docker ps -a -q)
sudo docker volume prune
sudo docker network prune
// this was done on golang "net/http" to solve development environment issues and CORS security in browsers
//put this function before your handlers
func addCors(w *http.ResponseWriter, r *http.Request) {
(*w).Header().Add("Access-Control-Allow-Origin", "*")
(*w).Header().Add("Access-Control-Allow-Methods", "POST, GET, OPTIONS")
(*w).Header().Add("Access-Control-Allow-Headers", "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With")
if r.Method == "OPTIONS" {
# https://kubernetes.io/docs/reference/kubectl/cheatsheet/
# see what nodes are running
kubectl get nodes
# see what is running
kubectl get pods
kubectl get services
kubectl get pvc
kubectl get secrets
/**
*
* allows for setting properties deep within comlex json that has mixed arrays + objects
*
* fnCrawlProperty(['parentproperty',1,'childproperty in obj of array 1'],'somevalue',targetObject,'action')
var objUpdate = fnCrawlProperty(arrMap,v,objTmpP,strAction);
* the i is for recursive pruposes, dont need to specify when calling it
*
* @param {array} arrMap
* @param {*} v
/**
* dont know if value will be an ovject or a single value, so need to reutrn based on which
* simply call with the top level value to start the recursive rows { fnFormatValue(v) }
* @param {*} v
*/
const fnFormatValue=function(v){
if(Config.debug){ console.log('fnFormatValue',v,typeof v); }
if(v){
let strType=typeof v;
switch(strType){
@SuddenDevelopment
SuddenDevelopment / blender_face_lights.py
Last active June 22, 2022 04:16
blender python api patterns
bl_info = {
"name": "Match Area Light",
"author": "Anthony Aragues",
"version": (1, 2),
"blender": (2, 90, 0),
"location": "n > Lights",
"description": "Rapidly create area lights to match size and orientation of selected faces",
"warning": "",
"doc_url": "",
"category": "Lighting",
@SuddenDevelopment
SuddenDevelopment / blender_fnGetScale.py
Last active October 13, 2021 18:56
blender get the size in x,y,z for an array of vectors
#example calling
# arrVerts=[]
# for objVert in objMesh.verts:
# if objVert.select == True:
# arrVerts.append(objVert)
objScale= fnGetScale(arrVerts)
print(objScale)
def fnGetScale(arrVerts):
@SuddenDevelopment
SuddenDevelopment / react component template.jsx
Last active March 21, 2021 20:34
organized template for creating react components
/*----====|| LIBRARY IMPORTS || ====----*/
//import React, { useContext,useEffect,useState } from 'react';
//import { Layout } from 'antd';
/*----====|| COPMPONENT IMPORTS || ====----*/
//import MyComponent from './components/myComponent.js';
/*----====|| CONTEXT || ====----*/
import {UserContext,ConfigContext} from '../context.js';
/*----====|| STYLE IMPORTS || ====----*/
@SuddenDevelopment
SuddenDevelopment / importOps.py
Last active June 10, 2021 02:56
List of operations to cleanup imported objects Chipp Walters gave me, in script form to save time.
# List of common operations to run on imported objects like .stl
# paste all or some into a script window in blender and run.
# If there's any interest in seeing this in addon form somewhere let me know, it seemed too basic/common to be another addon to install.
import bpy
# resize objects imported that were unit=1mm and Blender is set at 1m
bpy.ops.transform.resize(value=(0.001, 0.001, 0.001), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
# toggle to edit mode for a few things
bpy.ops.object.editmode_toggle()