Skip to content

Instantly share code, notes, and snippets.

@foofoodog
foofoodog / Octoprint on windows
Last active August 29, 2015 14:22
Octoprint on windows
Requires Python 2.7 assumed to be at C:\Python27.
Assumes global Python install has pip and virtualenv and maybe other stuff.
Either git clone or unzip the repo files somewhere.
Assuming you are bleeding edge and want to try the dev branch https://github.com/foosel/OctoPrint/archive/devel.zip.
Assuming here that you unzipped it to c:\Temp and now have this directory C:\Temp\OctoPrint-devel\OctoPrint-devel.
Hint: Text after the colon in the commands below can be pasted into the cmd window.
Hint: To paste to the cmd window press [alt]+[space],e,p in the cmd window.
@foofoodog
foofoodog / nuke.cmd
Last active August 29, 2015 14:26
Rip and replace OctoPrint
#!/usr/bin/env bash
cd ~
sudo service octoprint stop
sudo rm -Rf OctoPrint
sudo rm -Rf .octoprint
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install python-pip python-dev python-setuptools python-virtualenv git libyaml-dev
git clone https://github.com/foosel/OctoPrint.git
cd OctoPrint
@foofoodog
foofoodog / folger toc.linq
Last active September 20, 2015 15:04
LINQPad to parse specific github README.md and generate reddit markdown TOC
var readme = "https://github.com/cyberkni/FolgertechManuals/blob/master/2020i3/README.md";
var includes = new[] { "id=\"user-content-", "href=\"#" };
var excludes = new[] { "<article" };
// input
IEnumerable<XElement> elements;
using (var client = new WebClient())
{
elements = from line in client.DownloadString(readme).Split('\n')
where
includes.All(include => line.Contains(include))
@foofoodog
foofoodog / App.js
Last active November 15, 2015 23:09
octoprint client libs
var App = function(ready) {
var self = this;
self.config = {
options : {baseurl: "http://localhost:5000", apikey:"raspberry"},
scripts: ["/static/webassets/packed_libs.js", "/static/webassets/packed_client.js"]
};
self.load = function(idx) {
idx = idx || 0;
if (idx === self.config.scripts.length) return self.done();
var tag = document.createElement("script");
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@foofoodog
foofoodog / index.htm
Last active May 7, 2016 17:54
OctoPrint monitoring starter
<html>
<head>
<script>
var printers = [
{name: "folger", key: "raspberry"},
{name: "simple", key: "raspberry"},
{name: "solid", key: "raspberry"},
{name: "printrbot", key: "raspberry"}
];
</script>
@foofoodog
foofoodog / dl.cmd
Created March 28, 2018 22:31
youtube-dl as a linux docker on windows
@echo off
if %1.==. goto err
docker build -q -t utube . > nul
docker run --rm -v"%cd%":/data -e url="%*" utube
goto :eof
:err
echo needs 1 url arg
@foofoodog
foofoodog / -node-red with dashboard and mosquitto in alpine docker.md
Last active April 7, 2018 13:22
node-red with dashboard and mosquitto in alpine docker

node-red with dashboard and mosquitto in alpine docker

Cmd wrapper around docker commands to build and run an IoT dashboard kind of thing. Tries to do the right thing:

  • Create the image if it does not exist then run the container.
  • Run the container if it does not exist and the image does.
  • Start the container if it exists and is stopped.
Usage: node-red-local [clean]
    clean: Remove container and image to start from scratch. Note that all flows and dashboard items will be lost.
# REF https://www.talkingdotnet.com/how-to-create-an-angular-6-app-with-visual-studio-2017/
# REF https://docs.docker.com/engine/examples/dotnetcore/#build-and-run-the-docker-image
FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN apt-get update; \
apt-get install -y gnupg gnupg2 gnupg1; \
async Task Main()
{
Action<WorkItem> actionItem = (WorkItem w) => w.DoWork();
var jobs = (from x in Enumerable.Range(1, 64)
let workItem = new WorkItem() { Id = x }
select new ActionItem<WorkItem>()
{
item = workItem,
action = (t) => actionItem(t)
}).ToList();