Skip to content

Instantly share code, notes, and snippets.

View panda01's full-sized avatar

Khalah Jones Golden panda01

View GitHub Profile
@panda01
panda01 / quest_make_tables.js
Created July 19, 2021 10:59
A simple node program to create a bunch of tables inside of a questdb server running locally
const request = require('request');
function makeANewTable(idx, limit) {
const urlEncodedQuery = encodeURIComponent(`CREATE TABLE IF NOT EXISTS trades${idx} (ts TIMESTAMP, date DATE, name STRING, value INT) timestamp(ts);`);
const wholeUrl = 'http://localhost:9000/exec?query=' + urlEncodedQuery;
// For those really really annoying manual reviews <.<
$(".slider.slider-horizontal").each(function() {
const sliderBoundingRect = this.getBoundingClientRect();
const rightEdgeOfSlider = (sliderBoundingRect.left + sliderBoundingRect.width);
const mouseDownEvt = new MouseEvent("mousedown", {clientY: sliderBoundingRect.top, clientX: rightEdgeOfSlider});
this.dispatchEvent(mouseDownEvt);
const mouseUpEvt = new MouseEvent("mouseup", {clientY: sliderBoundingRect.top, clientX: rightEdgeOfSlider});
document.dispatchEvent(mouseUpEvt);
});
#include <stdio.h>
#include <limits.h>
int main(void)
{
int len;
int len2;
/* Some tests with 1 arg */
-- Here Do some cleanup
DROP DATABASE IF EXISTS trollrepellent;
CREATE DATABASE trollrepellent TEMPLATE = template0;
\connect trollrepellent
create extension if not exists pgcrypto;
create extension if not exists "uuid-ossp";
@panda01
panda01 / flatten.js
Created July 22, 2016 16:08
Flatten an arbitrarily nested array
function flattenArr(nestedArr, retVal = []) {
nestedArr.forEach(val => {
// this should be the only check since no object are expected
const isArr = (typeof val === 'object');
if(isArr) {
flattenArr(val, retVal);
} else {
retVal.push(val);
}
});
@panda01
panda01 / chart.js
Last active January 7, 2016 19:12
Charts!!!
const Vector = require('vector');
const Tangible = require('tangible')
class Chart extends Tangible {
constructor(options) {
super(null, new Vector(options.width, options.height));
}
get margin() { return this._margin; }
set margin(obj) {
// only do a partial update if necessary
this._margin = _.assign({}, this.margin, obj);
function chart() {
this.init();
}
_.assign(chart.prototype, {
xAxis: function(opt) {
if (!val) { return this.state.xAxis; }
this.state.xAxis = _.assign(defaultXAxisOptions, opt);
return this;
}
});
@panda01
panda01 / Flatten
Created February 2, 2015 12:36
Simple flatten
(function() {
function flatten(obj, prevObj, path) {
var newPath = null,
makeNewPath = function(p, j) {
return p ? (p + '.' + j) : j;
};
// stop undefined from being printed
path = path || '';
prevObj = prevObj || {};
@panda01
panda01 / Sum of Any N equals X
Last active August 29, 2015 14:13
Just some interesting code, for
(function() {
var sumOfAnyTwo = function(sum, operandsArr) {
var oper1 = null,
oper2 = null;
for(var i = 0; i < operandsArr.length; i++) {
for(var j = 0; j < operandsArr.length; j++) {
if(j !== i) {
if(operandsArr[i] + operandsArr[j] === sum) {
return true;
@panda01
panda01 / Floating point problem solver
Last active August 29, 2015 14:06
Allows for floating point math to be done in js
function Num(v, precision) {
this.val = v;
var multiplier = Math.pow(10, precision || 3),
// Helper fn, Makes a new num for chaining
m = function(n) {
return new Num(n, Math.log10(multiplier));
}
// pseduo operand overriding to allow for generic addition of nums
this.valueOf = function() {
return this.val * multiplier;