Skip to content

Instantly share code, notes, and snippets.

View KHN190's full-sized avatar
🦀
Crafting in Rust

Lingxiao Yu KHN190

🦀
Crafting in Rust
View GitHub Profile
@KHN190
KHN190 / loader.rs
Last active April 2, 2021 04:16
Create singleton instance in Rust
use std::sync::atomic::{AtomicBool, Ordering};
pub trait Loader {
fn load(&self, name: &str);
}
struct ResourceLoader;
impl Loader for ResourceLoader {
fn load(&self, name: &str) {
println!("load {}", name);
@KHN190
KHN190 / crt.html
Last active March 4, 2023 04:40
PICO-8 webgl CRT effect.
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>PICO-8 Cartridge</title>
<meta name="description" content="">
<STYLE TYPE="text/css">
<!--
@KHN190
KHN190 / ChangTiles.cs
Last active July 10, 2023 00:33
Change Unity Tilemap's Tile sprite during runtime
using UnityEngine;
using UnityEngine.Tilemaps;
public class ChangeTiles : MonoBehaviour
{
private Tilemap tilemap;
void Start()
{
// @fixme
import aiohttp
import asyncio
import logging
from tqdm import tqdm
USERNAME = ""
PASSWORD = ""
LOGIN_URL = ""
@KHN190
KHN190 / backpack.py
Created January 18, 2019 11:29
Solution for complete knapsack problem.
costs = [3,5,9]
value = [5,9,16]
volume = 1303
# solutions
opts = set()
opts.add(tuple([0]))
# calc total value

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger