This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # First-boot setup for a fresh DigitalOcean Ubuntu 26.04 droplet. Run it once, as root. | |
| # | |
| # Steps: | |
| # As root: | |
| # 1. create the user panda01 and ask you for its password | |
| # 2. add panda01 to the sudo group | |
| # 3. copy root's ~/.ssh/authorized_keys to panda01, so the key you log in with today | |
| # also logs you in as panda01 | |
| # As panda01 (the script re-runs itself through `su - panda01`): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <limits.h> | |
| int main(void) | |
| { | |
| int len; | |
| int len2; | |
| /* Some tests with 1 arg */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function chart() { | |
| this.init(); | |
| } | |
| _.assign(chart.prototype, { | |
| xAxis: function(opt) { | |
| if (!val) { return this.state.xAxis; } | |
| this.state.xAxis = _.assign(defaultXAxisOptions, opt); | |
| return this; | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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 || {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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; |
NewerOlder