Skip to content

Instantly share code, notes, and snippets.

@Dzejkop
Dzejkop / part1.md
Last active January 12, 2018 07:24
Felep-workwork

Workwork

Ogarnij string formatting i operacje na stringach

String formatting

https://pyformat.info/

Tu masz stronę która to fajnie wyjaśnia, zaprezentowane są 2 style old i new. Obu stylów się wciąż używa, wybierz sobie który chcesz - jak już zrozumiesz idee to opanowanie drugiego stylu nie będzie problematyczne.

https://www.learnpython.org/en/String_Formatting

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@Dzejkop
Dzejkop / texture_issues.rs
Created April 2, 2019 10:56
winapi.rs texture issues
// Texture creation
let mut texture: *mut ID3D11Texture2D = null_mut();
let mut texture_desc: D3D11_TEXTURE2D_DESC = std::mem::zeroed();
texture_desc.Width = width; // usually 1280
texture_desc.Height = height; // usually 720
texture_desc.MipLevels = 1;
texture_desc.ArraySize = 1;
texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
texture_desc.SampleDesc.Count = 1;
texture_desc.Usage = D3D11_USAGE_DYNAMIC;
pub fn levenshtein_distance(a: &str, b: &str) -> usize {
let a: Vec<char> = a.chars().collect();
let b: Vec<char> = b.chars().collect();
levenshtein_distance_inner(&a, &b)
}
fn levenshtein_distance_inner(a: &[char], b: &[char]) -> usize {
if a.len() == 0 {
return b.len();
@Dzejkop
Dzejkop / rust-toolchain.toml
Last active September 30, 2022 19:54
Rust Snippets
‎‎​
@Dzejkop
Dzejkop / Cargo.toml
Last active September 12, 2021 12:16
Converting clap apps to StructOpt style
# In your dependencies add the following
syn = "1.0"
quote = "1.0"
proc_macro2 = "1.0"
heck = "0.3"
@Dzejkop
Dzejkop / main.rs
Last active October 19, 2022 20:00
Serde By Example 2 - Final
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
struct Response {
pub elements: Vec<Element>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@Dzejkop
Dzejkop / Cargo.toml
Created February 24, 2023 20:04
Weird Bevy perf thing
[package]
name = "canvas_time_test"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy = "0.9.1"
@Dzejkop
Dzejkop / modRsMigrate.nu
Created March 11, 2023 12:45
Nu Scripts
def findMod [path: path] {
ls -a $path | where type == 'file' | where name =~ 'mod.rs' | select name | each {|e| handleModFile $e.name }
if ($path | path exists) {
ls -a $path | where type == 'dir' | select name | each {|e| findMod ($path | path join $e.name) }
}
}
def handleModFile [path: path] {
let d = ($path | path dirname)
let f = ([$d ".rs"] | str join)
{
{
"inputs": [
{
"internalType": "contract IBridge",
"name": "newStateBridge",
"type": "address"
}
],
"name": "setStateBridge",