Skip to content

Instantly share code, notes, and snippets.

@shuaibiyy
shuaibiyy / read-localities.clj
Created March 1, 2018 11:35
Read localities from a WOF ES index
(ns read-localities
(:require [cheshire.core :refer [parse-string]]
[clojure.pprint :refer [pprint]]
[clojure.walk :refer [keywordize-keys]]
[clojurewerkz.elastisch.rest :as rest]
[clojurewerkz.elastisch.rest.document :as doc]
[clojurewerkz.elastisch.rest.response :refer [hits-from]]))
(def ^:const mapping "locality")
@shuaibiyy
shuaibiyy / geohash.js
Last active April 14, 2017 17:08
Integer geohash implementation that outputs the same hash as Redis Geo.
const Long = require('long');
/* Limits from EPSG:900913 / EPSG:3785 / OSGEO:41001 */
const GEO_LAT_MIN = -85.05112878;
const GEO_LAT_MAX = 85.05112878;
const GEO_LONG_MIN = -180;
const GEO_LONG_MAX = 180;
/**
* Encode coordinates to a geohash integer.

Keybase proof

I hereby claim:

  • I am shuaibiyy on github.
  • I am shuaibiyy (https://keybase.io/shuaibiyy) on keybase.
  • I have a public key ASCK9eXnjeizqoEqF2BhU_DCJuou0NacflGo-m_RJj1O9Ao

To claim this, I am signing this object:

import com.typesafe.config.ConfigFactory;
private boolean isOriginAllowed(String origin) {
List<String> origins = ConfigFactory.load().getStringList("origins");
return origins.contains(origin);
}
public void checkOrigin(String origin) {
if (!isOriginAllowed(origin)) {
throw new ForbiddenException(Messages.originNotAllowed(origin));
#!/bin/bash
#
# Bash script to setup headless Selenium (uses Xvfb and Chrome)
# (Tested on Ubuntu 12.04) trying on ubuntu server 14.04
# Add Google Chrome's repo to sources.list
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list
# Install Google's public key used for signing packages (e.g. Chrome)
# (Source: http://www.google.com/linuxrepositories/)
import groovy.io.FileType
def editionProp = "edition"
def resourcesDir = "${basedir}/src/main/resources/"
def currentEdition = project.properties[editionProp]
File mappingsFile = new File("${resourcesDir}classMappings.properties")
Properties mappings = new Properties()
if (mappingsFile.exists()) {
mappingsFile.withInputStream { stream ->