Skip to content

Instantly share code, notes, and snippets.

View boertel's full-sized avatar

Benjamin Oertel boertel

View GitHub Profile
@boertel
boertel / machine.js
Last active July 2, 2021 19:58
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@boertel
boertel / check_power.ps1
Created October 27, 2020 16:26
Task Scheduler for power mgmt 07:00 to 22:00
$DateTimeNow = Get-Date
$DateTimeMorning = Get-Date -Hour 7 -Minute 0
$DateTimeNight = Get-Date -Hour 22 -Minute 0
# 07:00 < now < 22:00
if ($DateTimeNow.TimeOfDay -gt $DateTimeMorning.TimeOfDay -and $DateTimeNow.TimeOfDay -lt $DateTimeNight.TimeOfDay) {
powercfg.exe /S SCHEME_MIN
} else {
powercfg.exe /S SCHEME_BALANCED
@boertel
boertel / machine.js
Last active June 3, 2020 21:40
Machine to handle service requests status changes: https://xstate.js.org/viz/?gist=966b9b5e77ed0316af0f7e42f5d082c0
const initial = undefined
const context = undefined
const machine = Machine(
{
id: 'service-request',
initial: initial || 'REQUESTED',
context: {
hasPayment: true,
hasApproval: true,
@boertel
boertel / machine.js
Last active June 3, 2020 21:39
Machine to handle service request steps on the device
const serviceRequestMachine = Machine({
id: 'service-request',
initial: 'service',
context: {
hasTerms: false,
hasQuantity: true,
quantity: 1,
terms: false,
},
states: {
@boertel
boertel / machine.js
Last active January 7, 2020 18:13
Generated by XState Viz: https://xstate.js.org/viz
const lightMachine = Machine({
id: 'gvg',
type: 'parallel',
states: {
art: {
initial: 'green',
states: {
green: {
after: {
2000: 'red',
#!/bin/bash
# usage: ./git-clean PATH TRASH_FOLDER
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
function github_url {
echo "https://`git config --get remote.origin.url | sed -e "s/git@//" -e "s/:/\//" -e s"/\.git//"`"
@boertel
boertel / france-inter.js
Last active October 17, 2017 18:22
France Inter à la bonne heure
/*
* Ecouter France Inter à la bonne heure
* https://www.franceinter.fr/programmes
*
*/
var emissions = $('.rich-section-list-gdp-item:not(.step)').map(function () {
var date = new Date($(this).attr('data-start-time') * 1000);
var emission = {
hours: (date.getHours() + 9) % 24,
@boertel
boertel / README.md
Last active July 25, 2017 18:35 — forked from eesur/README.md
d3js | hexagon world map built from canvas map

Hexagonal world map, that draws based hexagons on the generated canvas map (comment out display: hidden, in css, to see the canvas rendering)

Reference sources:

class Root extends React.Component {
render() {
const repos = this.props.response.data;
return (
<div>{repos.map(function(repo) { return <p>{repo.name}</p>; })}</div>
);
}
}
function connect(url, component) {
@boertel
boertel / instagram.js
Created January 24, 2017 19:06
j/k for instagram
var index = 0;
function navigate(evt) {
var media = document.getElementsByTagName('article')[index];
if (media) {
index += (evt.key === 'j' ? 1 : (evt.key === 'k' ? -1 : 0));
media.scrollIntoView();
}
}