Skip to content

Instantly share code, notes, and snippets.

View LucianBuzzo's full-sized avatar
👹
Plate Armor Enthusiast

Lucian Buzzo LucianBuzzo

👹
Plate Armor Enthusiast
View GitHub Profile
@LucianBuzzo
LucianBuzzo / import.drush.php
Created November 12, 2016 21:25
Import articles from movable type ~2.6 to Drupal 8
#!/usr/bin/env drush
<?php
use \Drupal\node\Entity\Node;
use \Drupal\file\Entity\File;
$posts = [];
$tempPost;
@LucianBuzzo
LucianBuzzo / update-test-group.sh
Last active March 20, 2018 14:08
update-test-group.sh
#!/usr/bin/env bash
# This script sets a group of devices to a specific commit,
# currently it will look for devices in an app that have an environment variable called "TEST"
# these devices will then update to whatever commit is supplied as arg $1
./check-configuration.sh || exit 1
COMMIT_HASH=$1
source ./resin.env
const KNOWN_SCHEMA_FORMATS = [
'data-url',
'date',
'date-time',
'email',
'hostname',
'idn-email',
'idn-hostname',
'ipv4',
'ipv6',
@LucianBuzzo
LucianBuzzo / docker-node.sh
Last active August 29, 2018 08:18
Run an existing node project inside a docker container
docker run --name assignment -p 3001:3001 -dit node
docker cp . assignment:app
docker exec -it assignment bash
# enter the app directory and install the project etc
cd app && npm i
# once you're done, clean up the container
docker stop assignment
docker rm assignment
@LucianBuzzo
LucianBuzzo / jsonschema-filtering.md
Last active November 28, 2018 21:48
Definitions for filtering properties in JSON schema

Definitions for filtering properties in JSON schema

Using additionalProperties: false to remove undefined fields from an object. When filtering, an object that validates against the provided schema will have any undefined properties removed if additionalProperties is set to false. This behaviour prevents the usual additionalProperties: false behaviour from working. As such when validating an object to see if it is valid against the provided schema, the value of additionalProperties should be evaluated as though it were set to true.

@LucianBuzzo
LucianBuzzo / fill.js
Created December 2, 2018 15:57
Tile walking algorithms for dungeoneer
const wait = () => {
return new Promise((resolve) => {
setTimeout(resolve, 5)
})
}
exports.fill = async (dungeon, ctx, cellSize) => {
const width = dungeon.tiles.length
const height = dungeon.tiles[0].length
@LucianBuzzo
LucianBuzzo / lintconfig.vim
Created February 26, 2019 09:33
Set Syntastic checker to eslint if a a config file is found, otherwise use standardjs
"====[ Syntastic ]============================================
function! SetJSChecker()
for name in [ '.eslintrc', '.eslintrc.yml', '.eslintrc.json' ]
let file = findfile(name, '.;')
if len(file) > 0
echo "Found eslint configuration file"
let b:syntastic_checkers = ['eslint']
return
endif
endfor
@LucianBuzzo
LucianBuzzo / fieldexport.drush.php
Created February 27, 2019 11:24
Drush script for printing valid php field export code
#!/usr/bin/env drush
<?php
/**
* This script will echo valid php for programatically creating a field.
* The field must already exist for this to work, so it's value is in deploying
* changes from a development environment onto a live site.
*
* Call the script with "drush fieldexport.drush.php" specifying a field name using
@LucianBuzzo
LucianBuzzo / main.py
Created March 8, 2019 16:17
Retrieve Balena app git url
import os
from balena import Balena
balena = Balena()
token = os.environ['TOKEN']
appId = os.environ['APP_ID']
balena.auth.login_with_token(token)
user = balena.auth.who_am_i()
app = balena.models.application.get(appId)
delete-merged-branches = "!f() { git checkout --quiet master && git branch --merged | grep --invert-match '\\*' | xargs -n 1 git branch --delete; git checkout --quiet @{-1}; }; f"