Skip to content

Instantly share code, notes, and snippets.

View SuddenDevelopment's full-sized avatar
🤖

SuddenDevelopment SuddenDevelopment

🤖
View GitHub Profile
@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",
/**
* 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){
/**
*
* 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
# 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
// 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" {
@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
@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;
}
<div style={{"background":'linear-gradient(90deg, #f00 70%, transparent 30%)'}}> {objV.label} </div>
@SuddenDevelopment
SuddenDevelopment / index.js
Created August 25, 2017 23:30
nvd3 focus zoom brush values callback
//add data to the array like this
$scope.chartData=[{x:0,y:0}];
$scope.chartOptions = {
"chart": {
"type": 'linePlusBarChart',
//...the other options...
"callback": function(chart){
chart.dispatch.on( 'brush', function (objBrush) {
// objBrush.extent these are array index values!
@SuddenDevelopment
SuddenDevelopment / index.js
Created July 30, 2017 03:02
electron OSX menu that enables clipboard copy and paste
//this is a modified electron-forge default main.js file
import { app, BrowserWindow, ipcMain, shell, protocol, dialog, session, clipboard, Menu } from 'electron';
const metastream = require('metastream');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
process.on('uncaughtException', (err) => { console.error(err); });
const createWindow = () => {