Skip to content

Instantly share code, notes, and snippets.

DELIMITER $$
CREATE FUNCTION `fnHaversine`(point1 point, point2 point) RETURNS double
DETERMINISTIC
begin
declare lon1, lon2 double;
declare lat1, lat2 double;
declare r_lat1, r_lat2 double;
declare d_lat double;
declare d_lon double;
declare a, c, R double;
@Qwerios
Qwerios / gist:11371459
Last active January 22, 2018 17:01
Setting up private NPM repository

Official npm mirror

The main idea is to make an official NPM mirror as detailed here: https://github.com/npm/npm-registry-couchapp

Unfortunately the above instructions appear to be flawed and didn't working for me. Thankfully someone has taken the time to create an updated set of installation instructions: https://github.com/rvagg/npmjs.org/tree/new-install-docs

Bug with updated instructions

Only one problem remains with the above instructions and that is the credentials for the copy script. In copy.sh you need to fix the credentials for curl. Change this (line 46):

@Qwerios
Qwerios / cloudbuild.yaml
Last active October 23, 2018 10:24
Google Cloud Builder setup to auto-deploy to a kuberneter engine cluster
# We can use this cloudbuild.yaml setup with a trigger type tag
# on Google Cloud Build using default variable substitution.
#
# Use environment substitution in the trigger to add the additional parameters:
#
# _CLUSTER = kubernetes engine cluster. Ex. my-test-cluster
# _DEPLOYMENT = deployment name Ex. my-project
# _CONTAINER = container name within deployment. Ex. my-project-api
# _GCS_ZONE = compute engine zone. Ex. europe-west-1c
#
@Qwerios
Qwerios / gist:ae0bcd32dc1c5c871d06
Last active May 9, 2019 14:11
My Jenkins for Appcelerator mobile CI

Hardware & OS

Running on Apple Mac mini Dualcore i5 2.8GHz (MGEQ2FN/A) OSX Yosemite: 10.10.1

UPDATE Nov 3rd 2015: Upgraded to El Capitan caused my Jenkins to stop working. I had to apply the file permission fix for the log folder again (see known issues at the end of this gist). I also had to reinstall legacy java support and load the jenkins daemon again with launchctl. I took the time to update all the components mentioned in this gist when I did the upgrade. So the Android sdk/ndk, nodejs (0.10 -> 0.12), Titanium and Java. Beware that there is a new command-line tool for titanium (appc from the 'appcelerator' package).

User account setup

I installed and setup the new Mac with 1 main administrative account. In the scripts below it is assumed you are logged in as this administrative user. Changing to the jenkins user is done using sudo su - jenkins.

Required accounts

@Qwerios
Qwerios / nats-streaming-statefulset.yaml
Last active July 8, 2019 09:54
NATS Streaming Kubernetes Statefulset
apiVersion: v1
kind: ConfigMap
metadata:
name: nats-config
namespace: default
data:
# Used to set cluster id in deployment
# Look for $(NATS_CLUSTER) usage below
NATS_CLUSTER: nats-streaming
# This is the NATS hostname to connect to
import { createHash, randomBytes } from 'crypto';
import * as request from 'request';
/**
* The configuration object
*
* @export
* @interface IAuthServiceConfig
*/
export interface IAuthServiceConfig {