Skip to content

Instantly share code, notes, and snippets.

View am2222's full-sized avatar
:octocat:
Busy

Majid Hojati am2222

:octocat:
Busy
View GitHub Profile
@am2222
am2222 / postgistogeojson.js
Created July 15, 2016 15:07 — forked from samgiles/postgistogeojson.js
A function that converts a PostGIS query into a GeoJSON object.
/*
* A function that converts a PostGIS query into a GeoJSON object.
* Copyright (C) 2012 Samuel Giles <sam@sam-giles.co.uk>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@am2222
am2222 / include_list_viewpager.xml
Created September 30, 2016 08:12 — forked from iPaulPro/include_list_viewpager.xml
CollapsingToolbarLayout with TabLayout
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
@am2222
am2222 / BeaconResearch.md
Created October 6, 2016 21:42
iBeacon / Beacon Research
@am2222
am2222 / EndlessRecyclerOnScrollListener.java
Created October 11, 2016 17:54 — forked from ssinss/EndlessRecyclerOnScrollListener.java
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@am2222
am2222 / gist:9bf17d29120f7dbc377e4fff3541d45c
Created December 4, 2016 21:08
JavaScript Trilateration
// Created by Derrick Cohodas (dav-)
// Based on the Python example by StackExchange user wwnick from http://gis.stackexchange.com/a/415/41129
// Requires the Mathjs library - http://mathjs.org/
var math = require('mathjs')
/**
* Represents a coordinate with a distance
* @param {Number} lat Latitude
@am2222
am2222 / gist:d4157ebd446592b4f29ff1fae4033e58
Created April 19, 2017 06:04 — forked from quommit/gist:4633786
C# routing application for calculating a set of shortest paths from a series of predefined start and end locations. Each start node can be assigned an integer load value which accumulates on its corresponding end node. In order to compile this code, download and reference NetTopologySuite, an open source spatial analysis library, and QuickGraph,…
using System;
using System.Collections.Generic;
using System.IO;
using GeoAPI.Geometries;
using NetTopologySuite.Features;
using NetTopologySuite.Geometries;
using NetTopologySuite.IO;
using System.Globalization;
namespace ShortestPath
@am2222
am2222 / App.java
Created April 10, 2018 12:28 — forked from dwins/App.java
is this the minimal code to render a shapefile with geotools?
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.net.URL;
import javax.imageio.ImageIO;
import org.geotools.data.FeatureSource;
import org.geotools.data.shapefile.ShapefileDataStore;
import org.geotools.factory.CommonFactoryFinder;
import org.geotools.geometry.jts.ReferencedEnvelope;
@am2222
am2222 / shp2spatialite.py
Created May 10, 2018 18:10 — forked from kylefelipe/shp2spatialite.py
importing a SHP to a Spatialite
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Python 2
import os
from sqlite3 import dbapi2 as db
db_folder = "/"
db_name = "test"
@am2222
am2222 / gist:1f521f34eb520a4b881ed7d290f7b248
Created April 3, 2020 16:41 — forked from singhabhinav/gist:132b8196abac026b43fa
Install SSL certificate in Nginx (Using .crt & .ca-bundle certificate files)
Step 1 - Create .crt file
cat domainname.crt domainname.ca-bundle > domainname-ssl-bundle.crt
Step 2-
Add lines for ssl_certificate in nginx configuration
server {
listen 80 default_server;