Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

German SkymanOne

🎯
Focusing
View GitHub Profile
@SkymanOne
SkymanOne / sig.rs
Last active Aug 2, 2022
working signature
View sig.rs
use std::fmt::format;
use parity_scale_codec::{ Encode, Decode};
use sp_core::{H256, H512, Pair};
use sp_core::sr25519::{Signature};
fn main() {
let print_string = generate("//Alice", Vote::Yes);
println!("Alice - Yes - {}", fm(print_string));
@SkymanOne
SkymanOne / merkle_tree.rs
Last active Jul 28, 2022
Simple Merkle Tree
View merkle_tree.rs
//! This is minimal Merkle tree implementation with proof checking
use std::{
collections::hash_map::DefaultHasher,
hash::{Hash, Hasher},
};
fn main() {
let s = "";
let h = calculate_merkle_root("Trust me, bro!");
View create_signed_tx.rs
use parity_scale_codec::{ Encode, Decode};
use sp_core::{H256, H512, Pair};
type Salt = u8;
const SALT: Salt = 5u8;
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone)]
pub struct BasicExtrinsic {
operation: Operation,
@SkymanOne
SkymanOne / aes-modes.rs
Last active Jul 17, 2022
Solution to Polkadot Academy extra challenge on Sunday
View aes-modes.rs
//! In Module 1, we discussed Block ciphers like AES. Block ciphers have a fixed length input.
//! Real wold data that we wish to encrypt _may_ be exactly the right length, but is probably not.
//! When your data is too short, you can simply pad it up to the correct length.
//! When your data is too long, you have some options.
//!
//! In this exercise, we will explore a few of the common ways that large pieces of data can be broken
//! up and combined in order to encrypt it with a fixed-length block cipher.
//!
//! WARNING: ECB MODE IS NOT SECURE.
//! Seriously, ECB is NOT secure. Don't use it irl. We are implementing it here to understand _why_ it
@SkymanOne
SkymanOne / b_tree.rs
Last active Feb 20, 2022
Basic binary tree in rust
View b_tree.rs
//alias a complex type for cleaner code
pub type Link = Option<Box<Node>>;
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Node {
value: i8,
left_node: Link,
right_node: Link,
}
impl Node {
View keybase.md

Keybase proof

I hereby claim:

  • I am skymanone on github.
  • I am skymanone (https://keybase.io/skymanone) on keybase.
  • I have a public key ASDDIDF6BZHdJ3MtWXs88tZXGGSyrJXaGG4X1qwA86Y3Wgo

To claim this, I am signing this object:

@SkymanOne
SkymanOne / MultithreadExample.cs
Created Aug 26, 2021
Mini multithread application example
View MultithreadExample.cs
using System;
using System.Threading;
namespace threadTest
{
class Program
{
static void Main(string[] args)
{
//Let's create a dedicated thread to demmonstarte that the whole process can be done inside another thread
@SkymanOne
SkymanOne / Launch Xamarin.iOS app
Last active Sep 18, 2020
VS Code Task config to launch iOS app in Xamarin.Forms project
View Launch Xamarin.iOS app
{
//just copy paste in .vscode/tasks.json
//run by pressing cmd+shift+p
"version": "2.0.0",
"tasks": [
{
"label": "build",
"group": "build",
"command": "msbuild",
"type": "process",
View tableview.swift
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let task: Task = tasks[indexPath.row]
let action: UIContextualAction = UIContextualAction(style: .destructive, title: "Finish", handler: {
(action, view, completionHandler) in
self.tasks.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .fade)
completionHandler(true)
})
View ValidatingShipField.cs
using System;
namespace codewars10._06
{
class Program
{
static void Main(string[] args)
{
//set up the field as an array from the example test case
int[,] field = new int[10, 10]