Skip to content

Instantly share code, notes, and snippets.

View davidbasswwu's full-sized avatar

David Bass davidbasswwu

  • Western Washington University
  • Bellingham, WA
View GitHub Profile
@mikowl
mikowl / oneliners.js
Last active June 29, 2024 17:39
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active June 29, 2024 15:54
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
$map = array(
'jpeg' => 'islandora:sp_basic_image',
'jpe' => 'islandora:sp_basic_image',
'jpeg' => 'islandora:sp_basic_image',
'gif' => 'islandora:sp_basic_image',
'png' => 'islandora:sp_basic_image',
'tif' => 'islandora:sp_large_image_cmodel',
'tiff' => 'islandora:sp_large_image_cmodel',
'jp2' => 'islandora:sp_large_image_cmodel',
'pdf' => 'islandora:sp_pdf',
@karpathy
karpathy / min-char-rnn.py
Last active July 7, 2024 10:14
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@javedulu
javedulu / d3treeAddDynamicChild.js
Created October 1, 2014 11:42
Adding Dynamic content to d3.js tree on click of child node : http://bl.ocks.org/d3noob/8375092
function click(d) {
if (!d.children && !d._children)
{
d3.json("http://xxxx:2222/getChildNodes", function(error,response) {
response.children.forEach(function(child){
if (!tree.nodes(d)[0]._children){
tree.nodes(d)[0]._children = [];
}
child.x = d.x0;
child.y = d.y0;
@robschmuecker
robschmuecker / README.md
Last active May 13, 2024 20:57
D3.js Drag and Drop, Zoomable, Panning, Collapsible Tree with auto-sizing.

This example pulls together various examples of work with trees in D3.js.

The panning functionality can certainly be improved in my opinion and I would be thrilled to see better solutions contributed.

One can do all manner of housekeeping or server related calls on the drop event to manage a remote tree dataset for example.

Dragging can be performed on any node other than root (flare). Dropping can be done on any node.

Panning can either be done by dragging an empty part of the SVG around or dragging a node towards an edge.

@justinkelly
justinkelly / primo-az.js
Last active December 18, 2015 17:29
Make Primo A-Z do rank sorting
/*Make A-Z do rank sorting*/
if($('body').hasClass('EXLAlmaAz'))
{
$input = $("#exlidSearchRibbon input[name='fn']");
if($input.val() =='goAlmaAz')
{
$input.after('<input type="hidden" name="sortField" value="rank">');
}
}
@dpplweb
dpplweb / Google Analytics Event handler for CDM
Created April 16, 2013 15:24
Simple script for attach Google Anatlyics event handler to ContentDM
(function() {
"use strict";
//dynamically add a Google Event tracking event to a CDM download button
//make sure that Google Analytics is loaded
if (_gaq) {
var sizes, p, url, item_id, title_div, item_title, dlb;
//define download buttons for loop below
@saverkamp
saverkamp / sample-cdm2scripto.py
Created February 7, 2013 17:53
Sample script to harvest metadata through CONTENTdm v6 API and format as csv for upload into ui-libraries fork of Omeka/Scripto. See ui-libraries/plugin-Scripto for documentation. Uses pycdm, a python library for working with the CONTENTdm v6 API (saverkamp/pycdm).
import codecs
import csv
import datetime
import pycdm
from HTMLParser import HTMLParser
#get input: alias + items to retrieve
alias = raw_input('collection alias: ')
items = raw_input('item identifiers (separate by commas): ')
@PhilSager
PhilSager / size_image.php
Last active October 12, 2015 06:07
Script to get scaled image URL from CONTENTdm reference URL
<?php
/**
* Script to get scaled image URL from CONTENTdm reference URL
* Phil Sager <psager@ohiohistory.org>.
*
*/
$CDM_WEBSERVICES_HOME = "https://somedomain.contentdm.oclc.org"; // web services
$CONTENTDM_HOME = "http://somedomain.somewhere.org"; // public-facing CONTENTdm domain