Skip to content

Instantly share code, notes, and snippets.

@lukacat10
lukacat10 / LocationUtils.java
Created October 26, 2018 13:25
How to calculate distance between coordinates (based on android's implementation, which is based on nasa's inverse formula: http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf)
class LocationUtils{
public static float computeDistance(double lat1, double lon1,
double lat2, double lon2) {
// Based on http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf
// using the "Inverse Formula" (section 4)
int MAXITERS = 20;
// Convert lat/long to radians
lat1 *= Math.PI / 180.0;
lat2 *= Math.PI / 180.0;
DROP TABLE IF EXISTS `messages`;
CREATE TABLE `messages` (
`_id` INTEGER PRIMARY KEY AUTOINCREMENT,
`key_remote_jid` TEXT NOT NULL,
`key_from_me` INTEGER,
`key_id` TEXT NOT NULL,
`status` INTEGER,
`needs_push` INTEGER,
`data` TEXT,
`timestamp` INTEGER,
@lukacat10
lukacat10 / 99farm.lua
Last active September 15, 2021 13:53
fuel managment + support for canola, rice, beetroot
--os.loadAPI(shell.resolve(".").."/gameutils")
local fuels = {
["minecraft:coal"] = true
}
local mat_to_color = {
["minecraft:wheat"] = "1",
["minecraft:carrots"] = "2",
["simplefarming:carrot_crop"] = "2",
@lukacat10
lukacat10 / rce.lua
Last active September 16, 2021 13:11
package.preload["argparse"] = function(...)
local function errorf(msg, ...)
error(msg:format(...), 0)
end
local function setter(arg, result, value)
result[arg.name] = value or true
end
local parser = { __name = "ArgParser" }
parser.__index = parser
function parser:add(names, arg)
term.clear()
function fluid_transfer(config)
local width, height = term.getSize()
local resIndex = -1
for k,v in pairs(config) do
resIndex = resIndex + 1
term.setCursorPos(1, height - (4 + 4 * resIndex))
print("Fluid storage of '"..k.."'")
for kk,vv in pairs(v["storage"]) do
@lukacat10
lukacat10 / scratch_2.py
Created January 15, 2022 10:31
A set of scripts for generating good or bad israeli phone numbers and ids
import random
import csv
def generate_random_israeli_phone_number():
prefix = random.choice(["050", "052", "053", "054", "055", "058"])
main = random.randint(0, 9999999)
mainstr = str(main)
mainstr = "0" * (7 - len(mainstr)) + mainstr
complete = prefix + mainstr
@lukacat10
lukacat10 / main.go
Last active March 1, 2022 10:06
Validate israeli IDs in go
package validate_israeli_id_module
import (
"regexp"
"strconv"
"strings"
)
var(
IDSanitizer = regexp.MustCompile(`^[0-9]{1,9}$`)
@lukacat10
lukacat10 / scratch_6.py
Last active October 8, 2022 21:05
Auto create variadic method overloads for extended unity events
import re
count = 4
thing_to_replace = "<T0>"
input = """public static bool HasPersistentListenerMethod<T0>(this UnityEvent<T0> uEvent, UnityAction<T0> action)
{
var methodName = action.Method.Name;
for (int i = 0; i < uEvent.GetPersistentEventCount(); i++)
{
@lukacat10
lukacat10 / isr_ids.js
Created October 14, 2022 22:11
A set of scripts for generating good or bad israeli phone numbers and ids (JS)
function sum(arr) {
return arr.reduce((partialSum, a) => partialSum + a, 0);
}
Array.prototype.repeat = function(n){
var a = [];
for (var i=0;i<n;[i++].push.apply(a,this));
return a;
@lukacat10
lukacat10 / README.md
Last active January 1, 2023 11:00
Group azure spot instances by region

Instructions:

  1. Visit: https://azure.microsoft.com/en-us/pricing/spot-advisor/#pricing
  2. Open the console via F12
  3. Paste the script
  4. Move between the different regions in the dropdown menu (click the dropdown and use the arrow keys to move between the regions quickly).
  5. Run getPlans(), or getPlansFromCheapestToMostExpensive(), or getRegionsFromCheapestToMostExpensive(), or getPlansFilteredByPlanTypeFromCheapestToMostExpensive(), or getRegionsFilteredByPlanTypeFromCheapestToMostExpensive().
  6. There is a better way to do that, I'm sure and ashamed of myself.