Skip to content

Instantly share code, notes, and snippets.

View lianyi's full-sized avatar

lianyi lianyi

  • Bethesda MD
View GitHub Profile
@lianyi
lianyi / Jetty IP restriction.md
Last active August 29, 2015 14:27
Jetty(SOLR) Configuration for IP restrictions

Usage

java -jar start.jar etc/jetty.xml etc/iprestriction.xml

Notes

The idea is to use mixin to isolate ip configurations without touching the main configuration file.

#Versions tested:

@lianyi
lianyi / geo_usstates.js
Last active April 11, 2016 18:32 — forked from mshafrir/states_hash.json
US states in JSON and JS format
var geo_usstates = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": "01",
"properties": {
"name": "AL"
},
"geometry": {
@delip
delip / EmbeddedSolrExample.java
Last active April 20, 2016 07:25
Solr 4.4.0 EmbeddedSolrServer example: Indexing and Querying
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.TrueFileFilter;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.core.CoreContainer;

Simplest way to add pan/zoom to a d3js visualisation

@smithkyle
smithkyle / Install passport-ldapauth
Created May 8, 2015 18:21
MEAN.js passport-ldapauth integration
npm install -S passport-ldapauth
@rewonc
rewonc / app.js
Last active January 23, 2017 19:59
Authenticate a user with angularfire, save to firebase, and make available to controllers with promise
/*
This file is a brief example of how to use angularfire to authenticate a user, save that user's public profile to firebase, then
ensure that both the authenticated and public user are available in your controllers.
The route configuration uses angular-ui-router: https://github.com/angular-ui/ui-router
*/
// CREATE COLLECTION
solr create_collection -c my_collection -shards 2 -d path-to-my-conf
// CHECK COLLECTION SCHEMA
curl http://solr-host.dev:8983/solr/my_collection/schema?wt=schema.xml
// SCHEMA ITS GOOD
// UPDATE SCHEMA
@lianyi
lianyi / test.sh
Created June 12, 2017 19:02
solr testing Transfer-Encoding: chunked
export SOLRUPDATE='http://localhost:8983/solr/testingCore/update?wt=json&commit=true'
export SOLRQUERY='http://localhost:8983/solr/testingCore/select?wt=json&q=*:*'
curl $SOLRUPDATE --data-binary '[{"id": "1"},{"id": "2"}]' -H 'Content-Type: application/json' -X POST -H "Transfer-Encoding: chunked"
#>> response {"responseHeader":{"status":0,"QTime":295}}
curl $SOLRQUERY
#>> {"responseHeader":{"status":0,"QTime":15,"params":{"q":"*:*","wt":"json"}},"response":{"numFound":2,"start":0,"maxScore":1.0,"docs":[{"id":"1","_version_":1570026155898044416},{"id":"2","_version_":1570026155878121472}]}}
@lianyi
lianyi / analog.py
Created February 28, 2019 01:40
The following code can be downloaded directly to your Raspberry Pi. It will read the trimpot value, translate the reading to a volume range and modify the OS output volume level on your Raspberry Pi. The remap_range() method is being used to convert the 16-bit analog in range 0 - 65,535 to volume 0-100%.
import os
import time
import busio
import digitalio
import board
import adafruit_mcp3xxx.mcp3008 as MCP
from adafruit_mcp3xxx.analog_in import AnalogIn
# create the spi bus
spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)
@lianyi
lianyi / vtk2vtp.py
Created March 4, 2019 17:14 — forked from thomasballinger/vtk2vtp.py
vtk2vtp.py
#!/usr/bin/env python
"""File format conversion
category: vtk, file conversion, tomb"""
import os, sys
import vtk
def vtk2vtp(invtkfile, outvtpfile, binary=False):
"""What it says on the label"""
reader = vtk.vtkPolyDataReader()