Skip to content

Instantly share code, notes, and snippets.

View typelogic's full-sized avatar
🏹

typelogic typelogic

🏹
View GitHub Profile
@typelogic
typelogic / LocateMe.swift
Created May 16, 2022 04:38 — forked from cmittendorf/LocateMe.swift
A command line tool for Mac OS X written in Swift that uses CoreLocation for reverse geocoding a location from latitude and longitude. The geocoding part of this script will work on OS X as well as iOS.
#!/usr/bin/env swift
// Run this command line tool as a dynamic script or compile a binary
// using the following command:
// swiftc -sdk `xcrun --show-sdk-path` LocateMe.swift
import Cocoa
import CoreLocation
extension String {
@typelogic
typelogic / purging-old-artifacts-with-github-api.md
Created February 1, 2022 13:56 — forked from lelegard/purging-old-artifacts-with-github-api.md
Purging old artifacts with GitHub Actions API

With GitHub Actions, a workflow can publish artifacts, typically logs or binaries. As of early 2020, the life time of an artifact is hard-coded to 90 days (this may change in the future). After 90 days, an artifact is automatically deleted. But, in the meantime, artifacts for a repository may accumulate and generate mega-bytes or even giga-bytes of data files.

It is unclear if there is a size limit for the total accumulated size of artifacts for a public repository. But GitHub cannot reasonably let multi-giga-bytes of artifacts data accumulate without doing anything. So, if your workflows regularly produce large artifacts (such as "nightly build" procedures for instance), it is wise to cleanup and delete older artifacts without waiting for the 90 days limit.

Using the Web page for the "Actions" of a repository, it is possible to browse old workflow runs and manually delete artifacts. But the procedure is slow and tedious. It is fine to delete one selected artifact. It is not for a regular cleanup. We need

@typelogic
typelogic / verify.safetynet.webauthn.js
Created November 24, 2021 15:29 — forked from yackermann/verify.safetynet.webauthn.js
WebAuthn Android SafetyNet attestation verification sample in NodeJS
const crypto = require('crypto');
const base64url = require('base64url');
const cbor = require('cbor');
const jsrsasign = require('jsrsasign');
let gsr2 = 'MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozps6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjNS7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CLTfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6CygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9iYWxzaWduLm5ldC9yb290LXI
@typelogic
typelogic / android_permisions.xml
Created November 23, 2021 08:27 — forked from ali5h/android_permisions.xml
Android permisions list for a non-system app
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
<uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE"/>
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
@typelogic
typelogic / 01-createObservableFromDeviceEventEmitter.js
Created November 15, 2021 14:20 — forked from sectore/01-createObservableFromDeviceEventEmitter.js
[React Native + RxJS] Create an Observable from DeviceEventEmitter - An example to handle 'locationUpdated' event
import React, {DeviceEventEmitter} from 'react-native';
import {Observable} from 'rx-lite'
/**
* Creates an Observable to listen to any event of DeviceEventEmitter
* @param type {string} Event type
*/
export default createObservableFromDeviceEventEmitter$ = type => {
let subscription;
return Observable.fromEventPattern(
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJoIjoiMjczNTY1MDAwMDAwMDk2MDM4IiwibSI6IjI3MzU2NTAwMDAwMDA5NjA1NCIsImEiOjAsImlhdCI6MTYzMDkwNzc3NiwiZXhwIjoxNjMwOTA4Mzc2fQ.WxsZaMMXMkNR6WVF9oHyYeVvIrfdJEBJU85vicG9hmDHUg3tEa7CS35rF64O7h7OMfqiRY4B34T-O9dm4E8LhmduIbUHtu4jz-tj0TvFmbV5mgIoPyq7p1ZCeU5pxJ5jmICOatcC-uSXhVqsuaOluZpOOCRWlnF5qozFvuFWm4dscNgPjT6GT87zxhcmZy3REbZwvbAnQaxJ_2u4xyu9TpeY1M-TLuOoOnUvAYQ62tcp7z1FpoVVHGyL-Z1WHijONzZ8l1xcD2ep9Oa57Pycw4u_zb7sehS9zJO6h_o9-VW4JG9aIaAANHxASTmou9Akpub9oVcxk9QccKlY884Jog
# Replace lat/lon values. Replace observation IDs. Replace from-to date range.

wget 'https://power.larc.nasa.gov/cgi-bin/v1/DataAccess.py?&request=execute&identifier=SinglePoint&parameters=KT,CLRSKY_SFC_SW_DWN,ALLSKY_SFC_SW_DWN,ALLSKY_SFC_LW_DWN,TS,T2M,PRECTOT,WS10M&startDate=20150101&endDate=20210803&userCommunity=SSE&tempAverage=DAILY&outputList=CSV&lat=10.3633&lon=123.953' -O result.csv
<?xml version="1.0"?>
<Weather3Hours Version="2.0">
<Header>
<Title>Weather3Hours</Title>
<Description>Weather Observation for every 3 hour (1:00, 4:00, 7:00, 10:00, 13:00, 16:00, 19:00, 22:00) </Description>
<Uri>http://data.tmd.go.th/api/Weather3Hours/V2/index.php</Uri>
<LastBuildDate>2021-08-02 16:32:04</LastBuildDate>
<CopyRight>Thai Meteorological Department:2016</CopyRight>
<Generator>TMDData_API Services</Generator>
<status>200 OK</status>
<Weather3Hours Version="2.0">
<Header>
<Title>Weather3Hours</Title>
<Description>Weather Observation for every 3 hour (1:00, 4:00, 7:00, 10:00, 13:00, 16:00, 19:00, 22:00) </Description>
<Uri>http://data.tmd.go.th/api/Weather3Hours/V2/index.php</Uri>
<LastBuildDate>2021-08-02 16:32:04</LastBuildDate>
<CopyRight>Thai Meteorological Department:2016</CopyRight>
<Generator>TMDData_API Services</Generator>
<status>200 OK</status>
</Header>
{
"raintype": "PPT",
"raindef": "",
"rainunit": "mm",
"datab": "",
"datae": "",
"tempb": "",
"tempe": "",
"rdayb": "",
"rdaye": "",