Skip to content

Instantly share code, notes, and snippets.

View tryHarder.js
async function tryHarder(howHard, delay, callback) {
let wait = (milliseconds) => new Promise(resolve => setTimeout(resolve, milliseconds));
while (true) {
try {
return await callback();
} catch (ex) {
if (--howHard < 1) throw (ex);
}
await wait(delay);
}
View freejoy-build-notes.sh
# todo: see if --device can be used
docker run --rm -it --privileged -v $PWD:/pwd -w /pwd ubuntu:19.10
docker run --rm -it --privileged -v $PWD:/pwd -w /pwd debian:10
# make, curl, git, ...
# stlink-tools (https://github.com/texane/stlink#installation)
# gcc-arm-toolchain (https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
apt-get update && apt-get install -y make git-core stlink-tools gcc-arm-none-eabi
# FreeJoy
@piccaso
piccaso / gotenberg.cs
Created Nov 19, 2019
using gotenberg from dot net (c#)
View gotenberg.cs
using var client = new HttpClient {BaseAddress = new Uri("https://localhost:3000/")};
using var content = new MultipartFormDataContent {
{new StringContent(html), "files", "index.html"},
{new StringContent("8.27"), "paperWidth"},
{new StringContent("11.69"), "paperHeight"},
{new StringContent("0"), "marginTop"},
{new StringContent("0"), "marginBottom"},
{new StringContent("0"), "marginLeft"},
{new StringContent("0"), "marginRight"},
{new StringContent("true"), "landscape"}
View keybase.md

Keybase proof

I hereby claim:

  • I am piccaso on github.
  • I am 0xf10 (https://keybase.io/0xf10) on keybase.
  • I have a public key ASB-1ICagn2bExPuoBcQxVxdPbVM5mLsb6Hh7rNGYK0N4Ao

To claim this, I am signing this object:

@piccaso
piccaso / ionic-on-docker.md
Last active Sep 4, 2018
runnung ionic inside a docker container
View ionic-on-docker.md

Ionic on Docker

start container

docker run --rm -it -v "${PWD}:/src" -p 8100:8100 -p 35729:35729 -p 53703:53703 -w /src beevelop/ionic

start serve (inside container)

CHOKIDAR_USEPOLLING=1 ionic serve
View dotnet-docker-458-corehost-trace.txt
Tracing enabled
--- Invoked dotnet [version: 2.0.6, commit hash: 74b1c703813c8910df5b96f304b0f2b78cdf194d] main = {
dotnet
WebApiSample.dll
}
Reading fx resolver directory=[/usr/share/dotnet/host/fxr]
Considering fxr version=[..]...
Considering fxr version=[2.0.6]...
Considering fxr version=[.]...
Detected latest fxr version=[/usr/share/dotnet/host/fxr/2.0.6]...
View UriAppend.cs
using System;
using System.Linq;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UriAppend
{
public static class UriExtensions
{
public static Uri Append(this Uri baseUri, string relativeUrl) => new Uri(baseUri, relativeUrl);
@piccaso
piccaso / lobmosq.c
Created Sep 6, 2016
libmosquitto example
View lobmosq.c
/*
needs libmosquitto-dev
$ gcc -o libmosq libmosq.c -lmosquitto
*/
#include <stdio.h>
#include <mosquitto.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@piccaso
piccaso / img2linkedvmdk.bat
Created Jul 29, 2015
create a linked vmdk for a raw (dd style) disk image - acts like a real drive
View img2linkedvmdk.bat
VBoxManage.exe internalcommands createrawvmdk -filename "%1-linked.vmdk" -rawdisk "%1"
@pause
View onepage.js
jQuery(document).ready(function($){
'use strict';
function nurseLinks(){
$('a').each(function(i,e){
function trySel(sel){
if($(sel).length > 0){ $(e).attr('href', sel); return true; }
return false;
}
var h = e.hash.toString().match(/^#.+/);