Skip to content

Instantly share code, notes, and snippets.

View jmwind's full-sized avatar

Jean-Michel Lemieux jmwind

View GitHub Profile
const logIt = (text) => {
console.log('LOG: ' + text);
}
@jmwind
jmwind / geojson
Last active March 7, 2024 15:43
geojson
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[-81.37728, 13.37925],
@jmwind
jmwind / metrics.md
Last active May 7, 2023 21:21
metrics api

metrics widget data:

  • name: string (shown in top right corner)
  • unit: angle, knots, feet, meters (shown in a few places and if angle show superscript and otherwise below large metric number)
  • timeScale: scale (in minutes, default to 10 mins max 12 hours)
  • value: number (one decimal place, current value of the metric and the widget will be given a new value often)
  • values (optional): [{value: number, timestamp},...] (values is a list of historical values, the widget is expected to save a value ever 10 seconds and use to show the trends graph to the timescale provided. Max timescale is 12hr, which would mean at most 4320 values will be stored for the historical graph)
@jmwind
jmwind / main.py
Created December 3, 2020 21:21
recursion example
def makeSteps(s, path, result):
if s == 0:
path.append(0)
rev = [ele for ele in reversed(path)]
path_strings = [str(int) for int in rev]
val = "-".join(path_strings)
result.append(val)
print("Found a path: " + val)
if s >= 1:
p1 = path[:]
const jsonQ = require('jsonq');
const fetch = require('node-fetch');
const open = require('open');
const shop_url = 'https://sc-bushfire-appeal.com';
const generosity_level = 5;
function extractAllVariants(data) {
const json = jsonQ(data);
const products = json.find('products');
@jmwind
jmwind / extract_perf_wins_slack.js
Created January 7, 2020 22:11
Quick script to extract all messages in a Slack channel and group by total reactions
const { WebClient } = require('@slack/web-api');
async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
}
// An access token (from your Slack app or custom integration - xoxp, xoxb)
const token = process.env.SLACK_TOKEN;
[
{
"id": 1,
"name": "Sony Xperia Z3",
"price": 899,
"specs": {
"manufacturer": "Sony",
"storage": 16,
"os": "Android",
"camera": 15
@jmwind
jmwind / elevator2.js
Last active May 19, 2016 13:37
Elevator Saga Take Two
{
init: function(elevators, floors) {
var waiting_up = new Array(floors.length).fill(0);
var waiting_down = new Array(floors.length).fill(0);
function bestFloor(waiting) {
var selected_floor = {num_waiting: 0, floor: 0};
for(var floor = 0; floor < waiting.length; floor++) {
var num_waiting = waiting[floor];
if(num_waiting > 0 && num_waiting > selected_floor.num_waiting) {
@jmwind
jmwind / elevator.js
Created May 19, 2016 02:59
Elevator Saga Take One
{
init: function(elevators, floors) {
var waiting_up = new Array(floors.length).fill(0);
var waiting_down = new Array(floors.length).fill(0);
function bestFloor(waiting) {
var max_num_waiting = 0;
var next_floor = 0;
for(var floor = 0; floor < waiting.length; floor++) {
var num_waiting = waiting[floor];
@jmwind
jmwind / What
Created April 13, 2011 05:21
Asf
asdfadfasdf