Skip to content

Instantly share code, notes, and snippets.

@CaptSolo
CaptSolo / gist:5201b51d726b8eae388e105889b6d270
Created March 25, 2024 07:20
Obsidian Templater code for a list of Gmail e-mails from a particular week
<%*
// assuming the current file is titled in the format YYYY-Wxx (where xx is the week number)
date1 = tp.date.weekday("YYYY/MM/DD", 0, tp.file.title, "YYYY-[W]W");
date2 = tp.date.weekday("YYYY/MM/DD", 6, tp.file.title, "YYYY-[W]W");
url = "https://mail.google.com/mail/u/0/#search/" + encodeURIComponent(`after:${date1}+before:${date2}`);
tR += `[E-mails from this week](${url})\n`;
%>
@CaptSolo
CaptSolo / pymarc_robust_test.py
Created November 15, 2019 11:22
How to catch / ignore PyMARC exceptions
#!/bin/python
from pymarc import MARCReader
# Wrapper from https://stackoverflow.com/questions/13653783/how-to-catch-an-exception-in-the-for-loop-iterator
def wrapper(gen):
while True:
try:
yield next(gen)
except StopIteration:
@CaptSolo
CaptSolo / solve_me.py
Created November 1, 2019 11:42
CyberChess CTF task - Central African Republic
# Title:
# capture Central African Republic (flag) - Math is hard
#
# Description:
# You can do this on a paper, or you can let computers solve this for you.
# Python file:
from zlib import crc32
@CaptSolo
CaptSolo / roles-example.rdf
Created May 15, 2018 20:25
RDF data example - contributor roles
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:edm="http://www.europeana.eu/schemas/edm/" xmlns:mods="http://www.loc.gov/mods/modsrdf/v1#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:bibo="http://purl.org/ontology/bibo/" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:ore="http://www.openarchives.org/ore/terms/" xmlns:viaf="http://viaf.org/viaf/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:RdaGr2="http://RDVocab.info/ElementsGr2/" xmlns:nfo="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo/#" xmlns:exif="http://www.w3.org/2003/12/exif/ns#">
<rdf:Description rdf:about="http://dom.lndb.lv/data/obj/60316">
<rdf:type rdf:resource="http://www.openarchives.org/ore/terms/Aggregation" />
<dc:title>Raiņa vēstule Aspazijai Rīgā, 1894. gada 4.februārī : teksts un komentāri</dc:title>
@CaptSolo
CaptSolo / get_app_data.js
Last active August 29, 2017 20:28
Retrieve AppStore app information (command line)
#!/usr/bin/env node
var util = require('util');
var store = require('app-store-scraper');
function print_usage() {
console.log(util.format("\nUsage: %s app_store_id\n\nPrints information about the AppStore application with the given ID.\n", process.argv[1]));
}
function get_app_data(appId) {
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:admin="http://webns.net/mvcb/">
<foaf:PersonalProfileDocument rdf:about="">
<foaf:maker rdf:resource="#me"/>
<foaf:primaryTopic rdf:resource="#me"/>
<admin:generatorAgent rdf:resource="http://www.ldodds.com/foaf/foaf-a-matic"/>
<admin:errorReportsTo rdf:resource="mailto:leigh@ldodds.com"/>
@CaptSolo
CaptSolo / my_postgres_api
Created December 10, 2013 07:17
Code snippet for a discussion
# -*- coding: utf8 -*-
import psycopg2, psycopg2.extensions
import atexit
# no FAQ - lai simbolus atgriež kā python unicode tipu
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
class MyApi(object):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import graph_tool as gt
import numpy
import os
import sys
def get_all_graphs(g, v_prop, prune=False):
@CaptSolo
CaptSolo / gist:1167542
Created August 24, 2011 08:05
Valodas un augstskolu likums

56.pants. Studiju reglamentācija

(3) Valsts dibinātās augstskolās studiju programmas īsteno valsts valodā. Svešvalodu lietošana studiju programmu īstenošanā iespējama tikai šādos gadījumos:

1) Eiropas Savienības oficiālajās valodās var īstenot studiju programmas, kuras ārvalstu studējošie apgūst Latvijā, un studiju programmas, kuras īsteno Eiropas Savienības programmu un starpvalstu līgumos paredzētās sadarbības ietvaros. Ārvalstu studējošajiem studiju kursu obligātajā apjomā iekļaujama valsts valodas apguve, ja studijas Latvijā ir paredzamas ilgāk par sešiem mēnešiem vai pārsniedz 20 kredītpunktus;

2) ne vairāk par vienu piekto daļu no studiju programmas kredītpunktu apjoma var īstenot Eiropas Savienības oficiālajās valodās, ievērojot, ka šajā daļā nevar ietilpt gala un valsts pārbaudījumi, kā arī kvalifikācijas, bakalaura un maģistra darba izstrāde;

#!/usr/bin/env python
"""
bfind.py - Search for references matching given text
in BibTeX files and on BibSonomy.
Author: Uldis Bojars
http://captsolo.net
"""