Skip to content

Instantly share code, notes, and snippets.

View kwikwag's full-sized avatar

kwikwag kwikwag

  • Developer of the world
View GitHub Profile
@kwikwag
kwikwag / closest.m
Created June 9, 2013 23:01
Creates a matrix with the same dimensions as 'needle', placing in each element the closest value from 'haystack'; thanks to http://stackoverflow.com/users/279858/bill-cheatham
function [val, i] = closest(haystack, needle)
[~, i] = min(abs( ...
repmat(reshape(haystack,numel(haystack),1),1,numel(needle)) - ...
repmat(reshape(needle,1,numel(needle)),numel(haystack),1) ...
), [], 1);
val = reshape(haystack(i), size(needle));
end
@kwikwag
kwikwag / jqm-make-bugs.html
Created August 31, 2012 04:27
for JQM bug: dynamic listview creation in a multipage doc fails if page has no '.ui-page' class
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
<style type="text/css">
</style>
<script type="text/javascript">
function make_bugs() {
$('#container').html(
IPP Printer : HL2240D-local
IPP Printer : HL2240D
IPP Printer : HP-LaserJet-4050
printDataTransferCompleted
106
PrintEvent on sun.print.UnixPrintJob@107ebe1
printDataTransferCompleted
106
PrintEvent on sun.print.UnixPrintJob@107ebe1
PrintJobEvent: printJobNoMoreEvents
@kwikwag
kwikwag / HelloPrint.java
Created April 10, 2012 10:56
sample print app trying to monitor a print job in progress
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.net.URI;
import java.util.Date;
import java.util.Locale;
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintException;