Skip to content

Instantly share code, notes, and snippets.

'''takes a marc21 dump and adds 999$i fields to it'''
import sys
from pymarc import MARCReader
from pymarc import Field
import json
def main():
stats = {
'records': 0,
@fontanka16
fontanka16 / Scema.xml
Created July 2, 2015 11:52
Stockholm University OPAC Solr Schema.xml
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="example" version="1.5">
<fields>
<field name="_version_" type="long" indexed="true" stored="true"/>
<field name="abstract_display" type="string" indexed="false" stored="true" multiValued="false"/>
<field name="accessible_online" type="boolean" indexed="true" stored="true" />
<field name="allfields" type="text" indexed="true" multiValued="true" stored="false"/>
<field name="availability" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="class_dewey_full" type="string" indexed="true" stored="true" multiValued="true"/>
<field name="class_kssb_full" type="string" indexed="true" stored="true" multiValued="true"/>
@fontanka16
fontanka16 / WebAPiConfig.cs
Created July 2, 2015 11:25
WebAPiConfig.cs add JsonConverer
using System.Web.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Viola.CallSlipFetching;
using ViolaGui.Filters;
namespace ViolaGui
{
public static class WebApiConfig
{
@fontanka16
fontanka16 / CallSlipDeliveryTypeConverter.cs
Created July 2, 2015 10:58
JsonConverter för en Type safe Enum
using System;
using Newtonsoft.Json;
namespace Viola.CallSlipFetching
{
public class CallSlipDeliveryTypeConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var deliveryType = value as CallSlipDeliveryTypes;
@fontanka16
fontanka16 / CallSLipDeliveryTypes.cs
Last active August 29, 2015 14:24
Type Safe Enum example
using System;
using System.Collections.Generic;
namespace Viola.CallSlipFetching
{
public sealed class CallSlipDeliveryTypes
{
private readonly string _name;
private static readonly Dictionary<string, CallSlipDeliveryTypes> Instance = new Dictionary<string, CallSlipDeliveryTypes>();
@fontanka16
fontanka16 / dynamicobjectnamedbad
Created November 23, 2012 09:48
right and wrong way to reference an dynamic object with a reserved word as its name
dynamic activities = null;
//Wrong
var objects = new List<dynamic>(activities.items).Select(a=>a.object);
//Right
var objects = new List<dynamic>(activities.items).Select(a=>a.@object);
@fontanka16
fontanka16 / json.decode
Created November 23, 2012 08:46
example of json.decode
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Web.Helpers;
namespace bibliotekarien.GooglePlus
{
public class ActivitiesFetcher
<?xml version="1.0" encoding="utf-8"?>
<ctx_obj_set>
<ctx_obj identifier="">
<ctx_obj_attributes>&lt;perldata&gt;
&lt;hash&gt;
&lt;item key="@rft.auinit"&gt;
&lt;array&gt;
&lt;item key="0"&gt;D F&lt;/item&gt;
&lt;/array&gt;
&lt;/item&gt;