This is just stuff that I have put down that I find I use a lot of the time for my own reference.
$ git pull| // Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf | |
| // Remove any duplicates from an array of primitives. | |
| const unique = [...new Set(arr)] | |
| // Sleep in async functions. Use: await sleep(2000). | |
| const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms))); | |
| // or | |
| const sleep = util.promisify(setTimeout); |
| #!/usr/bin/env python | |
| import subprocess | |
| print("Finding packages conda says are installed by pip...") | |
| conda_raw = subprocess.run( | |
| ['conda', 'list'], | |
| stdout=subprocess.PIPE, | |
| stderr=subprocess.PIPE, | |
| ).stdout.decode('utf-8') |
| board = [ | |
| [1,2,3,4,5,6,7,8,9], | |
| [5,7,8,1,3,9,6,2,4], | |
| [4,9,6,8,7,2,1,5,3], | |
| [9,5,2,3,8,1,4,6,7], | |
| [6,4,1,2,9,7,8,3,5], | |
| [3,8,7,5,6,4,2,9,1], | |
| [7,1,9,6,2,3,5,4,8], | |
| [8,6,4,9,1,5,3,7,2], | |
| [2,3,5,7,4,8,9,1,6] |
| // MIT License | |
| // | |
| // Copyright (c) 2019 xarantolus | |
| // | |
| // Permission is hereby granted, free of charge, to any person obtaining a copy | |
| // of this software and associated documentation files (the "Software"), to deal | |
| // in the Software without restriction, including without limitation the rights | |
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| // copies of the Software, and to permit persons to whom the Software is | |
| // furnished to do so, subject to the following conditions: |
| import uuid | |
| import random | |
| from afase.models.meta import Base | |
| from sqlalchemy import ( | |
| Column, | |
| Text, | |
| Date, | |
| ForeignKey, |
| # -*- coding: utf-8 -*- | |
| import click | |
| import os | |
| import pandas as pd | |
| def file_split(file): | |
| s = file.split('.') | |
| name = '.'.join(s[:-1]) # get directory name |
| import arcpy | |
| import pandas as pd | |
| def arcgis_table_to_df(in_fc, input_fields=None, query=""): | |
| """Function will convert an arcgis table into a pandas dataframe with an object ID index, and the selected | |
| input fields using an arcpy.da.SearchCursor. | |
| :param - in_fc - input feature class or table to convert | |
| :param - input_fields - fields to input to a da search cursor for retrieval | |
| :param - query - sql query to grab appropriate values | |
| :returns - pandas.DataFrame""" |