Skip to content

Instantly share code, notes, and snippets.

View davassi's full-sized avatar
🐙
Rust

Gianluigi Davassi davassi

🐙
Rust
View GitHub Profile
/*
* Calculate distance between two points in latitude and longitude taking
* into account height difference. If you are not interested in height
* difference pass 0.0. Uses Haversine method as its base.
*
* lat1, lon1 Start point lat2, lon2 End point el1 Start altitude in meters
* el2 End altitude in meters
*/
public double distanceKm(double lat1, double lat2, double lon1, double lon2,
double el1, double el2) {
@davassi
davassi / bt.java
Last active October 20, 2016 20:34
binary truth table
private static final int not(int a) {
return a^0b1;
}
//https://s16.postimg.org/dthtvw3id/binary_curl.png
private static int rt(int a, int b, int c, int d) {
return ((a ^ d) & (not(b) | c));
}
private static int lt(int a, int b, int c, int d) {
private void findAllUnconfirmedTransactions() {
synchronized (StorageScratchpad.instance().getAnalyzedTransactionsFlags()) {
// get the hash of the last milestone.
final Hash milestone = Milestone.getHashOfLastMilestoneIndex();
if (milestone != null) {
// get the trunk transaction hash
long pointer = StorageTransactions.instance().transactionPointer(milestone.bytes());
final Transaction transaction = StorageTransactions.instance().loadTransaction(pointer);
0x5B25EEb8d63cca4671E191e787fbC837a442D443
@davassi
davassi / keybase.md
Last active November 13, 2020 09:09

Keybase proof

I hereby claim:

  • I am davassi on github.
  • I am exquisitus (https://keybase.io/exquisitus) on keybase.
  • I have a public key ASAT9FWXWTJ0L2lXS61p_tVHhq0wr8F6AyJIY4HBsXPAdwo

To claim this, I am signing this object:

@davassi
davassi / ll.rs
Last active September 24, 2023 14:05
A double linked list
use std::{rc::Rc, cell::RefCell, fmt::Display};
type Pointer<T> = Option<Rc<RefCell<Node<T>>>>;
struct Node<T> {
data: T,
next : Pointer<T>,
prev : Pointer<T>,
}
use std::{rc::Rc, cell::RefCell, fmt::Display};
type Pointer<T> = Option<Rc<RefCell<Node<T>>>>;
struct Node<T> {
data: T,
next : Pointer<T>,
prev : Pointer<T>,
}
@davassi
davassi / rust
Created October 2, 2023 06:44
calc
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
use eframe::egui;
use egui::{Vec2, Rounding, TextEdit, FontId, FontSelection, FontFamily, Separator, Button};
use yarer::session::Session;
use egui::TextStyle::*;
macro_rules! butt {
($t:expr) => {
Button::new($t).min_size(Vec2::new(64.,64.)).rounding(Rounding::same(4.)).frame(false)