Skip to content

Instantly share code, notes, and snippets.

View dapangmao's full-sized avatar
🏠
Working from home

Dapangmao dapangmao

🏠
Working from home
View GitHub Profile
from loc.models.index import get_solr_connection
from loc.models.index import solr_safe_value
import json
conn = get_solr_connection()
my_fq = ["original-format:newspaper", "hassegments:true", 'partof_title:"yellowstone monitor. \(glendive, mont.\) 1905-1928"', 'date:[1911-01-01T00:00:00Z TO 1912-12-31T00:00:00Z]']
res = conn.raw_query(fq=my_fq, wt='json', rows=1000)
c = json.loads(res)['response']['docs']
print len(c)
<link href="https://cdn.rawgit.com/dapangmao/a1813e270dec8d1f3383fca7ed0a3e9f/raw/fc2edcd37c839a84fe8ac576ec62b9da5f183870/bs.css" rel="stylesheet">
<script src="https://cdn.rawgit.com/Paul-DS/bootstrap-year-calendar/master/js/bootstrap-year-calendar.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/Paul-DS/bootstrap-year-calendar/master/css/bootstrap-year-calendar.css">
<div class="bootstrap" id="calendar" data-provide="calendar" style="margin-bottom: 30px"></div>
<script>
$(function () {
.bootstrap {
/*!
* Bootstrap v3.3.7 (http://getbootstrap.com)
* Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
/*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */
}
.bootstrap html {
package main
import (
"io/ioutil"
"path/filepath"
"os"
"fmt"
"sync"
"flag"
"time"

Chapter 1 Getting in to Go

  • 1.1 What is Go?
  • 1.2 Noteworthy Aspects of Go
  • 1.2.1 Multiple Return Values
  • 1.2.2 A Modern Standard Library
  • 1.2.3 Concurrency with goroutines and channels
  • 1.2.4 Go the toolchain, more than a language
  • 1.3 Go in the vast language landscape
  • 1.3.1 C and Go
@dapangmao
dapangmao / data.md
Last active September 28, 2023 06:50
Top 10 lessons learned from Dockerized Elasticsearch

Combining Docker and Elasticsearch together will make many things in life easier. Depending on the scales, there are three scenarios for an implementation of Elasticsearch use case -

    1. Single ES instance and single machine
    1. Multiple ES instances and single machine
    1. Multiple ES instances and multiple machines

Docker has three mechanisms corresponding to each of the scenarios above.

    1. Docker commands
    1. Docker Compose
CREATE OR REPLACE FUNCTION public.login(email text, pass text)
RETURNS basic_auth.jwt_token
LANGUAGE plpgsql
AS $function$
declare
_role name;
result basic_auth.jwt_token;
begin
-- check email and password
select basic_auth.user_role(email, pass) into _role;
-- https://postgrest.com/en/v0.4/auth.html#sql-user-management
create schema if not exists basic_auth;
create table if not exists
basic_auth.users (
email text primary key check ( email ~* '^.+@.+\..+$' ),
pass text not null check (length(pass) < 512),
role name not null check (length(role) < 512)
set nocompatible " required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'tmhedberg/SimpylFold'
Plugin 'vim-scripts/indentpython.vim'