Skip to content

Instantly share code, notes, and snippets.

View tomassedovic's full-sized avatar

Tomas Sedovic tomassedovic

View GitHub Profile
@dio
dio / hello-wasm.js
Last active September 10, 2023 07:42
This is a simpe example on embedding wasm inside an offline single html page
// this code is from a simple add function in c:
//
// // hello.c
// int add(int a, int b) {
// return a + b;
// }
//
// compiles it with emcc (http://webassembly.org/getting-started/developers-guide/)
// $ git clone https://github.com/juj/emsdk.git
@petrblaho
petrblaho / virip
Created September 3, 2012 08:44
Simple script for detecting IP address of running virtual machine
#!/bin/bash
DOMAIN=$1
XML=`sudo virsh dumpxml $DOMAIN`
MAC=`echo "$XML" | grep 'mac address' | awk -F\' '{print $2}'`
VIRNETWORK=`echo "$XML" | grep 'source network' | awk -F\' '{print $2}'`
VIRBRIDGE=`sudo virsh net-info $VIRNETWORK | grep Bridge | awk '{print $2}'`
VIRNET=`ifconfig $VIRBRIDGE | grep inet | awk '{print $2}' | awk -F. '{print $1"."$2"."$3".*"}'`
nmap -sn $VIRNET &> /dev/null
@agibsonsw
agibsonsw / hide_element
Created February 5, 2012 16:35
JS Bookmarklet to hide an element on click
javascript:(function(){var%20d=document,useMine=true,prevEl;function%20AddHandler(orig,mine)
{return%20function(e){if(useMine)mine(e);else%20if(orig)orig(e);};}function%20Myonmouseover(e)
{var%20evt=e||window.event;var%20elem=evt.target||evt.srcElement;elem.style.outline='2px%20solid%20gray';
prevEl=elem;}function%20Myonmouseout(e){var%20evt=e||window.event;var%20elem=evt.target||evt.srcElement;elem.style.outline='';}
function%20Myonclick(e){var%20evt=e||window.event;var%20elem=evt.target||evt.srcElement;elem.style.display='none';}
function%20Myonkeydown(e){var%20evt=e||window.event;if(evt.keyCode==27){prevEl.style.outline='';useMine=false;}}
d.onmouseover=AddHandler(d.onmouseover,Myonmouseover);d.onmouseout=AddHandler(d.onmouseout,Myonmouseout);
d.onclick=AddHandler(d.onclick,Myonclick);d.onkeydown=AddHandler(d.onkeydown,Myonkeydown);})()