Skip to content

Instantly share code, notes, and snippets.

View ryuichiueda's full-sized avatar

Ryuichi Ueda ryuichiueda

View GitHub Profile
@ryuichiueda
ryuichiueda / .sushrc_ubuntu26
Last active November 1, 2026 02:26
.sushrc for Ubuntu 26.04 20261025 (Put this file in your home directory, rename it to .sushrc, and remove unnecessary lines for using)
case $- in
*i*) ;;
*) return ;;
esac
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\b\[\033[00m\]\[\033[01;35m\]\w\[\033[00m\]🍣 '
PS1="\[\033]2;\u@\h: \w\007\]$PS1"
PS2='> '
PS4='+ '
@ryuichiueda
ryuichiueda / .my_sushrc_mac
Last active October 31, 2026 01:13
.sushrc for macOS 20261025 (Put this file in your home directory, rename it to .sushrc, and remove unnecessary lines for using)
case $- in
*i*) ;;
*) return;;
esac
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
build_profile=$([[ "$BASH_VERSION" == *-release ]] || echo "(${BASH_VERSION##*-})")
@ryuichiueda
ryuichiueda / sample1.py
Created October 20, 2026 07:36
sample program (ROS2 face detection using OpenCV)
import rclpy, random
from rclpy.node import Node
from std_msgs.msg import Float64
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
import cv2
class ImageProc(Node):
def __init__(self):
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char const *argv[]) {
int n = atoi(argv[1]);
for(int i=0;i<n;i++) {
char *p = malloc(1024*1024); //1MiBメモリ確保
for(int i=0;i<1024*1024;i+=4096)
p[i] = 111;
}
#include <stdlib.h>
#include <unistd.h>
int main() {
char *p = malloc(1024*1024*1024); //1GiBメモリ確保
for(int i=0;i<1024*1024*1024/4096;i++)
p[i] = 111;
exit(0);
}
#include <stdlib.h>
#include <unistd.h>
int main() {
char *p = malloc(1024*1024*1024); //1GiBメモリ確保
for(int i=0;i<1024*1024*1024;i+=4096)
p[i] = 111;
exit(0);
}
@ryuichiueda
ryuichiueda / malloc_1gib.c
Last active February 9, 2026 08:30
仮想メモリと確保された物理メモリの容量の違いの調査
#include <stdlib.h>
#include <unistd.h>
int main() {
char *p = malloc(1024*1024*1024); //1GiBメモリ確保
for(int i=0;i<1024*1024;i++) //最初の1MiBにデータ書き込み
p[i] = 111;
sleep(10000); //観察用にプログラムを止める
exit(0);
}
@ryuichiueda
ryuichiueda / result.txt
Last active December 13, 2023 10:21
thread-fork test result
$ cargo run
・・・
1秒後 Child: ""
2秒後 Child: ""
3秒後 Child: ""
4秒後 Child: ""
5秒後 Parent { child: Pid(50794) }: "written"
5秒後 Child: ""
6秒後 Parent { child: Pid(50794) }: "written"
6秒後 Child: ""
@ryuichiueda
ryuichiueda / main.rs
Last active December 13, 2023 10:28
thread-fork test
use std::{time, thread};
use std::sync::{Arc, Mutex};
use std::time::Instant;
use nix::unistd;
use nix::unistd::ForkResult; //懺悔:これいらなかったです(cargo buildするとワーニング出ます。削ってください。)
fn main() {
let s = Arc::new(Mutex::new(String::new())); //Arcの中のMutexの中の文字列がデータ本体です。
let s1 = s.clone();
@ryuichiueda
ryuichiueda / .bash_profile
Created January 8, 2019 04:30
minimum bash_profile for Mac
export CLICOLOR=1
export LSCOLORS=DxGxcxdxCxegedabagacad
alias 'ls=ls -G'