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
@samgiles
samgiles / postgistogeojson.js
Created April 4, 2012 07:38
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,
@ssinss
ssinss / EndlessRecyclerOnScrollListener.java
Last active January 19, 2024 08:52
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;
@marchold
marchold / Android SwitchPlusClickPreference
Last active November 20, 2022 09:38
extension of SwitchPreference that allows you to add a click handler to the preference area as well as the switch. For making switch preferences that work like Android WiFi settings.
import android.content.Context;
import android.preference.SwitchPreference;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Switch;
/**
* Custom preference for handling a switch with a clickable preference area as well
@singhabhinav
singhabhinav / gist:132b8196abac026b43fa
Last active July 13, 2024 03:32
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;
@iPaulPro
iPaulPro / include_list_viewpager.xml
Last active March 7, 2024 11:13
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
@cyhsutw
cyhsutw / MathJax.ipynb
Last active July 21, 2024 20:16
Grabbed from https://github.com/odewahn/ipynb-examples, converted to v3 for GitHub to render.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@davidfurlong
davidfurlong / Bookshelf-postgis.md
Last active February 28, 2022 05:47
Use Bookshelf with postgis and knex-postgis without the hassle

How to use Bookshelf with postgis and knex-postgis without the hassle

Using Bookshelf.js with postgis and knex-postgis is a huge pain in the ass.

TLDR - Override Bookshelf methods to parse postgis formats in JS, not in SQL to avoid having to do awkward Bookshelf modifications anywhere you make a bookshelf insert/update/delete on Geo data (middleware like approach)

class Event extends Bookshelf.Model {
  get tableName() { return 'event'; }
@kylefelipe
kylefelipe / shp2spatialite.py
Created April 6, 2018 16:33
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"