Skip to content

Instantly share code, notes, and snippets.

View chris-gunawardena's full-sized avatar

Chris Gunawardena chris-gunawardena

View GitHub Profile
from pybricks.pupdevices import Remote
from pybricks.parameters import Button, Color
from pybricks.hubs import TechnicHub
from pybricks.pupdevices import Motor
from pybricks.parameters import Port
from pybricks.tools import wait
hub = TechnicHub()
trigger: none
# trigger:
# branches:
# include:
# - feature/3809-faster-tests
#schedules:
# - cron: "*/15 * * * *"
# displayName: every 15 min build
# always: true
'use strict';
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const resolve = require('resolve');
const PnpWebpackPlugin = require('pnp-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin');
@chris-gunawardena
chris-gunawardena / gist:8158ede94ff71a89ec138de014f573bd
Created October 16, 2019 11:03
ovchipcart csv to travel expense sheet
var x = {}
csv.split("\n").slice(1).map(r => {
const [date, amount] = [r.split(";")[0], r.split(";")[5]].map(c => c.replace(/"/g, ''));
const [day] = date.split('-');
x[day] = (x[day] || 0) + Number(amount);
});
Object.keys(x).map(day => document.querySelector(`#d${day}-0`).value = x[day]);
console.log(x);
@chris-gunawardena
chris-gunawardena / test-gen.js
Last active July 6, 2018 11:30
polymer test generator
copy(Reflect.ownKeys(Reflect.getPrototypeOf(element)).filter(p=>element [p] instanceof Function).map(funcName => `
suite('${funcName}()', () => {
test('yyyyy', () => {
assert.equal(element.${funcName}(''), 'xxxx');
});
});
`).join(''))
/* sample output */
suite('_getWeek', () => {
@chris-gunawardena
chris-gunawardena / server.js
Created June 19, 2018 09:22
CORS server example
var express = require('express')
var app = express()
var port = 8081;
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header("Access-Control-Allow-Methods", "POST, PUT, GET, OPTIONS");
next();
});
ssh -NT -R 12345:localhost:22 [email protected] -o ServerAliveInterval=60
ssh -p12345 chris@localhost
https://blog.kylemanna.com/osx/ssh-reverse-tunnel-on-mac-os-x/
{
"actions": [{
"name": "actions.devices",
"deviceControl": {
},
"fulfillment": {
"conversationName": "automation"
}
}],
"conversations": {
{
"requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
"payload": {
"devices": [{
"id": "456",
"type": "action.devices.types.LIGHT",
"traits": [
"action.devices.traits.OnOff",
"action.devices.traits.Brightness",
"action.devices.traits.ColorSpectrum"
!#
/Users/`whoami`/Library/Android/sdk/tools/emulator -avd `android list avd | grep Name -m 1 | cut -c 10-99` -http-proxy `ipconfig getifaddr en0`:8888