Skip to content

Instantly share code, notes, and snippets.

@mems
mems / gist:4739515
Last active April 30, 2018 22:32
Download full size image from OLCL's CONTENTdm http://www.contentdm.org/

Example here : http://cdm16038.contentdm.oclc.org/cdm/compoundobject/collection/p15017coll23/id/1842 (from list : http://cdm16038.contentdm.oclc.org/cdm/landingpage/collection/p15017coll23 Hagley Digital Archives)

Execute on each image page, the following JS:

prompt("copy this metalink file data:",'<file name="'+$.trim($("#metadata_object_title").text())+'">\n<resources>\n<url type="http">'+server_api_url + "?CISOROOT=" + thisCollection + "&CISOPTR=" + thisItemId + "&action=2&DMSCALE=100&DMWIDTH="+thisImageInfo.imageinfo.width  +"&DMHEIGHT="+thisImageInfo.imageinfo.height+"&DMX=0&DMY=0&DMTEXT=&DMROTATE=0"+'</url>\n</resources>\n</file>');

Into metalink:

@mems
mems / gist:5169578
Created March 15, 2013 12:33
Function to handle binayr string to write short, long, and array of shorts and longs
<?php
/**
* Decode a binary string (2 bytes only) to a short
* @param $input binary string to decode
* @return short decoded
*/
function str2short($data)
{
//*<- add or remove "/" to toggle comment
@mems
mems / gist:5301297
Last active February 23, 2022 13:12
How to convert a (simple) SWF to PDF

Convert (simple) SWF to PDF

In SWFTools a programs called gfx2gfx is available to do this task, but it's not officially available precompiled.

It can convert SWF, PDF or image to SWF, PDF, ebook or image.

For discard downscaling for rasterized image (default: 72dpi) we use the provided by @m-p-y: add -r attribute to increase maxdpi

Requirements

@mems
mems / gist:5338017
Last active December 15, 2015 23:09
Add support of load an image in http://www.rw-designer.com/online-cursor-editor tool (Make CUR file)
/*
Make CUR file using online editor, with basic support of load an image
http://www.rw-designer.com/online-cursor-editor
Require image file to base64 string convertion tool like:
http://www.motobit.com/util/base64-decoder-encoder.asp
*/
//------------
@mems
mems / folder2od.sh
Last active June 8, 2017 10:16
Create OpenDocument file (odt, ods, etc.) from folder (unzipped OpenDocument file)
#!/bin/sh
# Convert folder (unzipped OpenDocument file) to OpenDocument file (odt, ods, etc.)
usage="usage: $(basename "$0") folder file program to create OpenDocument file (odt, ods, etc.) from folder (unzipped OpenDocument file)"
if [ $# -ne 2 ]; then
echo "$usage"
exit 0
else
@mems
mems / jquery.img-rend.js
Created May 23, 2013 15:32
Image rendering jQuery CSS hook
/**
* Image rendering jQuery CSS hook
* Usage:
* element.css("image-rendering", "crisp-edges");
* element.css("image-rendering", "auto");
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering
*/
(function($) {
if ( !$.cssHooks ) {
throw("jQuery 1.4.3+ is needed for this plugin to work");
@mems
mems / dabblet.css
Last active August 29, 2015 14:01
`background-attachment: local` on div, textarea and iframe
textarea, div, iframe{
width: 300px;
height: 200px;
background: url("https://developer.mozilla.org/samples/cssref/images/cartooncat.png") local;
overflow: auto;
}
<p>Submit programmatically not work correctly. Some browsers send directly the form without trigger submit event and/or execute validation.</p>
<p>Submit the form! If the field is empty, you should see the native validation display an error message (for browsers that support HTML5 form validation). Then a confirm dialog box should ask you if you want to search the given term on Google Search</p>
<form id="form" action="http://google.com" target="_parent">
<p><label for="term">Search on Google:</label> <input type="text" name="q" id="term" value="" required></p>
<fieldset>
<legend>Programmatically form submition</legend>
<p><label for="method">Method:</label> <select id="method">
<option value="method">form.submit()</option>
<option value="event">Trigger submit event</option>
@mems
mems / config.xml
Created September 22, 2014 11:39
JavaScript HTML injection for Intellij
<?xml version="1.0" encoding="UTF-8"?>
<LanguageInjectionConfiguration>
<injection language="HTML" injector-id="js">
<display-name>&quot;&lt;html&gt;&quot;</display-name>
<place><![CDATA[jsLiteralExpression().withText(string().matchesBrics("(\\<\\<\\<)?.*\\</?<anyname>.*>.*"))]]></place>
</injection>
</LanguageInjectionConfiguration>
@mems
mems / har2maff.py
Last active August 29, 2015 14:17 — forked from mdaniel/har2maff.py
Convert HAR to MAFF
#! /usr/bin/env python2.7
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals
from bs4 import BeautifulSoup
import hashlib
import logging
import json
import os
import sys
import re