Skip to content

Instantly share code, notes, and snippets.

View jinahadam's full-sized avatar

Jinah Adam jinahadam

View GitHub Profile
@jinahadam
jinahadam / setup-ssl.md
Created November 28, 2022 11:11 — forked from pedrouid/setup-ssl.md
Setup SSL with NGINX reverse proxy

Get a Free SSL Certificate With Let’s Encrypt

Let’s Encrypt is a free, automated, and open Certificate Authority.

  1. Install tools for using the Let's Encrypt certificates using Certbot
  sudo apt-get update \
  sudo apt-get install software-properties-common
@jinahadam
jinahadam / Firecloud Nearby GeoQuery
Created November 28, 2018 14:41 — forked from zirinisp/Firecloud Nearby GeoQuery
Firecloud Nearby GeoQuery
import CoreLocation
extension CLLocationCoordinate2D {
func boundingBox(radius: CLLocationDistance) -> (max: CLLocationCoordinate2D, min: CLLocationCoordinate2D) {
// 0.0000089982311916 ~= 1m
let offset = 0.0000089982311916 * radius
let latMax = self.latitude + offset
let latMin = self.latitude - offset
// 1 degree of longitude = 111km only at equator
//
// Reachability.swift
// Etcetera
//
// Copyright © 2018 Nice Boy LLC. All rights reserved.
//
import Foundation
import SystemConfiguration
@jinahadam
jinahadam / array.swift
Created March 7, 2018 12:45
#swift #array #collections
let names = ["Paul", "Elena", "Zoe"]
extension Sequence {
func last(where predicate: (Iterator.Element) -> Bool) -> Iterator.Element? {
for element in reversed() where predicate(element) {
return element
}
return nil
}
@jinahadam
jinahadam / XCTWaiter.swift
Last active March 1, 2018 10:31
#swift #testing
func testInfoLoading() {
let url = "https://raw.githubusercontent.com/FahimF/Test/master/DogYears-Info.rtf"
HTTPClient.shared.get(url: url) {
(data, error) in
self.resData = data
}
let pred = NSPredicate(format: "resData != nil")
let exp = expectation(for: pred, evaluatedWith: self, handler: nil)
@jinahadam
jinahadam / perfect_routing.swift
Last active March 1, 2018 10:22
#swift #perfect
let server = HTTPServer()
server.serverPort = 8080
server.documentRoot = "webroot"
var routes = Routes()
routes.add(method: .get, uri: "/", handler: {
request, response in
response.setBody(string: "Hello, Perfect").completed()
})
require "Prime"
def largest_prime_factor(n)
return n if n.prime?
Prime.each do |p|
if n % p == 0
k = n.to_f/p.to_f
if k.to_i.prime?
return k.to_i
else
def fib(n)
if n <= 2
return (1..n).to_a
else
k = n - 2
arr = [1,2]
k.downto(2).each do |j|
i = arr[-2]+arr[-1]
arr = arr.push(i) if i < 4000000
end
@jinahadam
jinahadam / BinParser.cs
Last active August 29, 2015 14:06
BinParser
using uint8_t = System.Byte;
class BinParser
{
public struct GPS_LINE
{
public DateTime datetime;
public string type;
public float lat;
public float lon;
@jinahadam
jinahadam / distance.js
Created October 8, 2013 05:50
Distance betweeen two gps points Haversine a = sin²(Δφ/2) + cos(φ1).cos(φ2).sin²(Δλ/2)
var R = 6371; // km
var dLat = (lat2-lat1).toRad();
var dLon = (lon2-lon1).toRad();
var lat1 = lat1.toRad();
var lat2 = lat2.toRad();
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;