Skip to content

Instantly share code, notes, and snippets.

View opichals's full-sized avatar

Standa Opichal opichals

  • Prague, Czech Republic
View GitHub Profile
# 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 / 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 {
@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
@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
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 / pathtoapp.scpt
Created April 13, 2012 22:01
OSX AppleScript path to .app
set pathToApp to (POSIX path of (path to me))
do shell script "echo " & pathToApp
@opichals
opichals / git-topic
Created March 28, 2012 22:42
Find the merge commit that brought the <hash> into the current branch
#/usr/bin/env bash
git log --reverse --merges $1.. | head
@opichals
opichals / README
Created January 4, 2012 08:51
Google Chrome Frame No Content on POST 204
https://gist.github.com/1559168
Reproduction stuff for POST resulting in 204 'No Content' on the server returns XMLHttpRequest result == 0.
The example uses YUI3, but it was verified that the result status of 0 comes from the XMLHttpRequest object status field.
* install nodejs
Download and install the appropriate package from nodejs.org
* install express (nodejs web stack)