Skip to content

Instantly share code, notes, and snippets.

@noguxun
noguxun / Containerfile
Created July 24, 2025 01:47
Get cyclictest into the AutoSD QM partition
ARG CONTAINER_BASE="fedora:39"
# Build stage
FROM $CONTAINER_BASE AS builder
RUN dnf -y update
RUN dnf install -y \
gcc \
make \
numactl-devel \
@noguxun
noguxun / Dockerfile
Created February 15, 2022 08:34
Dockerfile
FROM --platform=amd64 python:3
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# un-comment below if needs to run some script
# COPY my_script.py .
# CMD [ "python", "./my_script.py" ]
@noguxun
noguxun / Cargo.toml
Created August 6, 2020 12:02
recipe_apex_to_www
[package]
name = "fastly-template-rust-default"
version = "0.1.0"
authors = []
edition = "2018"
[profile.release]
debug = true
[dependencies]
@noguxun
noguxun / tokio_join_expand.rs
Created May 6, 2020 09:21
tokio join expanded
// Macro expaned from
// let (first, second) = tokio::join!(do_stuff1(), do_stuff2());
let (first, second) = {
use ::tokio::macros::support::{maybe_done, poll_fn, Future, Pin};
use ::tokio::macros::support::Poll::{Ready, Pending};
let mut futures = (maybe_done(do_stuff1()), maybe_done(do_stuff2()));
poll_fn(move |cx| {
let mut is_pending = false;
let (fut, ..) = &mut futures;
@noguxun
noguxun / main.rs
Created February 8, 2020 08:55
Make a post in rust
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let res = client.post("http://httpbin.org/post")
.body("the exact body that is sent")
.header("abc", "def")
.send()
.await?;
@noguxun
noguxun / HandlerExample.kt
Created December 2, 2018 08:04
Communication between a thread and main UI loop
class T4StationService : Service() {
var mLocSer: LocationService? = null
var mHandler: MyHandler? = null
inner class MyHandler(looper: Looper) : Handler(looper) {
override fun handleMessage(msg: Message?) {
super.handleMessage(msg)
// call some function that needs to be called in UI thread
class MainFragment : Fragment() {
//...
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val view: View = inflater.inflate(R.layout.main_fragment, container, false)
class Gu1Fragment : Fragment() {
// ...
// dynamically add a button to the fragment
// beware it is in onViewCreated, should NOT be in onCreateView
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val btn :Button = Button(requireContext())
@noguxun
noguxun / layout_example.xml
Last active November 18, 2018 01:06
Android Line Layout in Constrait Layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/start"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.start.StartFragment">
@noguxun
noguxun / show_nn_mlmodel.py
Last active January 8, 2018 07:16
Print apple's neural network mlmode file layer information
import os
import sys
import Model_pb2
if len(sys.argv) != 2:
print("usage: python3 show_mlmodel.py your_model.mlmodel")
sys.exit(1)
with open(sys.argv[1], "rb") as f: