Skip to content

Instantly share code, notes, and snippets.

View opichals's full-sized avatar

Standa Opichal opichals

  • Prague, Czech Republic
View GitHub Profile
@opichals
opichals / 0README.md
Created August 31, 2020 20:43 — forked from artizirk/0README.md
Apple macOS Catalina under Linux KVM with GVT-g Intel GPU passthrough notes
# Version: 1.0.2-use-oci-config
# Usage:
# oci-curl <host> <method> [file-to-send-as-body] <request-target> [extra-curl-args]
#
# ex:
# oci-curl iaas.us-ashburn-1.oraclecloud.com get "/20160918/instances?compartmentId=some-compartment-ocid"
# oci-curl iaas.us-ashburn-1.oraclecloud.com post ./request.json "/20160918/vcns"
function oci-curl {
@opichals
opichals / background.js
Created June 21, 2019 16:24 — forked from josephrocca/background.js
Chrome extension to force-enable CORS based on request's *source* url (i.e. the url of the browser tab) rather than the target url
// Notes: we need the `sourceTabUrl &&` before the URL check because chromebooks make weird requests that don't come from "real" tabs.
let accessHeaders = new Map();
let tabIdToUrlMap = new Map();
let requestListener = function (details) {
const accessControlRequestHeader = details.requestHeaders.find(elem => elem.name.toLowerCase() === "access-control-request-headers");
if(accessControlRequestHeader) {
accessHeaders.set(details.requestId, accessControlRequestHeader.value);
}
@opichals
opichals / morphingNumbers.js
Last active December 16, 2018 15:12
Espruino morphing numbers rendering based on `espruino/EspruinoDocs/examples/Morphing Clock.js`
/*<!-- Copyright (c) 2018 Gordon Williams. See the file LICENSE for copying permission. -->
*/
//
// based on https://github.com/espruino/EspruinoDocs/blob/master/examples/Morphing%20Clock.js */
//
// Made more size independent
//
/* Get array of lines from digit d to d+1.
n is the amount (0..1)
@opichals
opichals / webGraphics.js
Last active December 16, 2018 15:12
Simple Espruino Graphics webGraphics over websocket
function wrapInstance(g, args) {
var width = g.getWidth();
var height = g.getHeight();
var page = `<script>
var ws;
setTimeout(function(){
ws = new WebSocket("ws://" + location.host + "/webGraphics", "protocolOne");
ws.onmessage = function (event) {
if (event.data.length > 40) {
// base64 -> Uint8Array
@opichals
opichals / mdns.js
Last active November 24, 2021 11:24
Espruino experimental mDNS module
function init(hostname, ip) {
const dgram = require('dgram');
const srv = dgram.createSocket({ type: 'udp4', reuseAddr: true, recvBufferSize: 2000 });
srv.addMembership('224.0.0.251', ip); // Bounjour link-local multicast IP
const socket = srv.bind(5353, function(bound) {
function onDatagram(msg, rinfo) {
//console.log('>MEM', JSON.stringify(process.memory()));
//console.log('MSG', msg.length, rinfo.address, rinfo.port);
try {
if (typeof console === 'undefined') {
// also see
//
// https://blogs.oracle.com/nashorn/entry/setinterval_and_settimeout_javascript_functions
// https://gist.github.com/kayhadrin/4bf141103420b79126e434dfcf6d4826
//
// https://avatar-js.java.net/index.html
// https://java.net/projects/avatar-js/sources
var console = {};
@opichals
opichals / designer.html
Last active August 29, 2015 14:06
designer
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../google-map/google-map-search.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@opichals
opichals / sinon-useFakeTimers-to-avoid-touching-window-Date.js
Last active August 29, 2015 13:57
Mod to make sinon.useFakeTimers() compatible with Ember.js runloop
if (!sinon._originalUseFakeTimers) {
sinon._originalUseFakeTimers = sinon.useFakeTimers;
sinon.useFakeTimers = function() {
// make sure we don't override window.Date used in
// Backburner.setTimeout() to optimize window.setTimeout() call numbers
return sinon._originalUseFakeTimers.apply(this, [new Date().getTime(), "setTimeout", "setInterval", "clearTimeout", "clearInterval"]);
};
sinon._originalTest = sinon.test;
sinon.test = function(callback) {
@opichals
opichals / gist:9527732
Created March 13, 2014 12:42
Em.Logger...
+ Em.Logger.assert = function myAssert(test, message) {
+ if (!test) {
+ try {
+ throw new Error(message);
+ } catch(e) {
+ console.log('ASSERT LOG: '+e.message+e.trace);
+ } finally {
+ console.trace('ASSERT: '+message);
+ console.assert(test, 'ASSERT: '+message);