Skip to content

Instantly share code, notes, and snippets.

@silphire
silphire / tfjs_blazepose_test.html
Last active May 22, 2021 02:08
test code of tensorflow.js with BlazePose
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-converter"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-webgl"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/pose-detection"></script>
</head>
<body>
<img id="image" src="./image.jpg">
@silphire
silphire / barcode.js
Created January 5, 2021 10:15
Google Chrome 83以降で正式対応になったBarcode Detection APIのテスト (うまく動かない)
var barcodeDetector = new BarcodeDetector({formats: ['qr_code']});
const bodyElement = document.getElementById('body');
bodyElement.ondragover = (event) => {
event.stopPropagation();
event.preventDefault();
event.dataTransfer.dropEffect = 'copy';
};
@silphire
silphire / main.rs
Last active May 27, 2019 11:53
mutability exercise
struct Foo {
pub foo: Vec<isize>,
}
impl Foo {
pub fn get_foo(&self) -> &Vec<isize> {
return &self.foo;
}
pub fn get_foo_mut(&mut self) -> &mut Vec<isize> {
@silphire
silphire / function_table.rs
Created April 5, 2019 20:54
I don't know why function type cannot be used as a type parameter
use std::collections::HashMap;
use std::any::Any;
fn main() {
let funcs: Option<HashMap<isize, &Any>> = Some(HashMap::new());
// expected expression, found keyword `fn`
let func = funcs.map(|v| (*v.get(0)).downcast_ref<fn(n: isize)>());
}
fn sort(data: &mut Vec<i32>) {
for i in 0..data.len() {
for j in i..data.len() {
if data[i] > data[j] {
data.swap(i, j);
}
}
}
}
fn fizzbuzz() {
for x in 1..100 {
if x % 3 == 0 {
print!("Fizz ");
} else if x % 5 == 0 {
print!("Buzz ");
} else if x % 3 == 0 && x % 5 == 0 {
print!("FizzBuzz ");
} else {
print!("{} ", x);
s = [Array.new(24){rand(256).chr}.join].pack('m').chomp until /^\w+$/ =~ s
puts s
(function() {
function show_visits(url, tbody)
{
var visit_keys = [ "id", "visitId", "visitTime", "referringVisitId", "transition" ];
chrome.history.getVisits({
"url": url,
}, function(visits) {
// clear previous result
while(tbody.firstChild) {
@silphire
silphire / jumplist.patch
Created March 9, 2014 13:15
Windows 7 jumplist patch for mintty
Index: Makefile
===================================================================
--- Makefile (revision 1322)
+++ Makefile (working copy)
@@ -69,7 +69,7 @@
endif
LDFLAGS := -L$(shell $(CC) -print-file-name=w32api) -static-libgcc
-LDLIBS := -mwindows -lcomctl32 -limm32 -lwinspool -lole32 -luuid
+LDLIBS := -mwindows -lcomctl32 -limm32 -lwinspool -lole32 -luuid -lshlwapi
@silphire
silphire / index.html
Created April 20, 2011 12:33
マウスクリックで指定した2点間をの経路を算出する
<html lang="ja"> <head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<title>test</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="map.js"></script>
</head>
<body onload="initialize()">
<div id="control" style="width: 100%; height: 10%">
<input type="button" value="clear" onclick="clear_markers()">