Skip to content

Instantly share code, notes, and snippets.

@rsimon
rsimon / annotorious-opencv-find-contours.js
Last active March 1, 2024 08:00
Sample code for AnnotoriousOSD that automates polygon selection by tracing contours in the selected image section.
import OpenSeadragon from 'openseadragon';
import * as Annotorious from '@recogito/annotorious-openseadragon';
import '@recogito/annotorious-openseadragon/dist/annotorious.min.css';
/*************************************************************************
*
* Basic concept for this is from the official OpenCV docs:
* https://docs.opencv.org/3.4/dc/dcf/tutorial_js_contour_features.html
*
class Membership < ActiveRecord::Base
belongs_to :user
belongs_to :memberable, polymorphic: true
end
module Memberable
extend ActiveSupport::Concern
included do
has_many :memberships, as: :memberable, dependent: :destroy
has_many :users, through: :memberships
@CliffordAnderson
CliffordAnderson / convert-plays-json-to-xml.xqy
Last active December 11, 2015 16:05
Comédie Française API
xquery version "3.1";
declare namespace xpf = "http://www.w3.org/2005/xpath-functions";
(: Connects to the Comédie Française registers, converts JSON data to XML, and (optionally) persists documents to BaseX database :)
declare function local:convert-play($map as element()) as element()
{
element play {
attribute id {$map/xpf:number[@key="id"]/text()},
@jprante
jprante / harvard-marc21-to-elasticsearch.md
Last active August 23, 2022 09:47
Ingest Harvard Library Bibliographic Dataset into Elasticsearch (as raw unmapped MARC21 fields)

HOWTO

Ingest Harvard Library Bibliographic Dataset into Elasticsearch (as raw unmapped MARC21 fields)

This HOWTO is for Linux systems (Windows is very similar)

  • install Java 8 into /usr/java/jdk1.8.0
  • install Elasticsearch 1.1.0
@antoviaque
antoviaque / gist:8423488
Created January 14, 2014 18:45
Granting superuser privileges to an existing user in edX
edxapp@edx:~/edx-platform$ ./manage.py lms shell --settings=devstack
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
@theycallmeswift
theycallmeswift / api_dev_tools.md
Created October 24, 2013 21:18
The list of awesome API Developer Tools from John Sheehan's (https://twitter.com/johnsheehan) talk at API Strategy SF (http://www.apistrategyconference.com/2013SF/)
@cjbell
cjbell / Gemfile
Created October 21, 2013 21:45
Sir Trevor Image Uploader (Rails + Carrierwave)
# Upload gems
gem "carrierwave"
gem "mini_magick", "~> 3.3"
gem "fog", "~> 1.3.1"
@markbates
markbates / gist:4240848
Created December 8, 2012 16:06
Getting Started with Rack

If you're writing web applications with Ruby there comes a time when you might need something a lot simpler, or even faster, than Ruby on Rails or the Sinatra micro-framework. Enter Rack.

Rack describes itself as follows:

Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks.

Before Rack came along Ruby web frameworks all implemented their own interfaces, which made it incredibly difficult to write web servers for them, or to share code between two different frameworks. Now almost all Ruby web frameworks implement Rack, including Rails and Sinatra, meaning that these applications can now behave in a similar fashion to one another.

At it's core Rack provides a great set of tools to allow you to build the most simple web application or interface you can. Rack applications can be written in a single line of code. But we're getting ahead of ourselves a bit.

@TimFletcher
TimFletcher / 20120625030355_add_deleted_at_to_user.rb
Created November 7, 2012 17:05
Trashable 'concern' for Rails models
# db/migrate/20120625030355_add_deleted_at_to_user.rb
class AddDeletedAtToUser < ActiveRecord::Migration
def change
add_column :users, :deleted_at, :time
end
end
@Kub-AT
Kub-AT / admin.py
Created September 8, 2012 15:36
Django flatpages and Redactorjs (WYSIWYG editor)
"""
Redactorjs: http://redactorjs.com/
django-redactorjs: https://github.com/TigorC/django-redactorjs
"""
from django.contrib import admin
from django.contrib.flatpages.models import FlatPage
from django.contrib.flatpages.admin import FlatPageAdmin as OldFlatPageAdmin
from django.contrib.flatpages.admin import FlatpageForm as OldFlatpageForm