Skip to content

Instantly share code, notes, and snippets.

Avatar

Naohisa Murakami tiqwab

View GitHub Profile
View pivot_root_sample.c
#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/syscall.h>
#include <sys/mount.h>
#include <sys/stat.h>
@tiqwab
tiqwab / permutation_iterator.rs
Created Aug 1, 2021
Implement iterator to generate permutations of the given vec in Rust
View permutation_iterator.rs
mod perm {
pub struct PermutationIterator<T: Ord + Clone> {
li: Vec<T>,
is_finished: bool,
}
impl <T: Ord + Clone> PermutationIterator<T> {
pub fn new(mut li: Vec<T>) -> PermutationIterator<T> {
let is_finished = li.is_empty();
li.sort();
@tiqwab
tiqwab / ansible-no-log.md
Last active Feb 23, 2021
Ansible の no_log に未定義の変数を使用したとき
View ansible-no-log.md
$ ansible --version
ansible 2.10.5
  ...
  python version = 3.9.1 (default, Dec 13 2020, 11:55:53) [GCC 10.2.0]

用意した Playbook。

@tiqwab
tiqwab / SSL-certs-OSX.md
Created Feb 13, 2021 — forked from croxton/SSL-certs-OSX.md
Generate ssl certificates with Subject Alt Names
View SSL-certs-OSX.md

Generate ssl certificates with Subject Alt Names on OSX

Open ssl.conf in a text editor.

Edit the domain(s) listed under the [alt_names] section so that they match the local domain name you want to use for your project, e.g.

DNS.1   = my-project.dev

Additional FQDNs can be added if required:

@tiqwab
tiqwab / cmd.sh
Created Jul 11, 2020
How to access symbol and its content by assembly (and with PIE)
View cmd.sh
$ as -o foo.obj foo.S
$ cc -o sample sample.c foo.obj
$ ./sample
0x557727162030 # address of value1
0x1122334455667788 # content of value1
0x55772716203c # address of z
@tiqwab
tiqwab / phantom_data.md
Last active Mar 29, 2020
One usage of PhantomData in Rust.
View phantom_data.md

According to the doc of PhantomData, one usafe of PhantomData is for unused lifetime parameters like:

struct Slice<'a, T: 'a> {
    start: *mut T,
    end: *mut T,
    _invariant: PhantomData<&'a T>,
}

fn foo<T>(v: &mut Vec<T>) -> Slice<'_, T> {
@tiqwab
tiqwab / client_output
Last active Sep 24, 2019
pppd sample working on Ubuntu 18.04
View client_output
using channel 47
Using interface ppp0
Connect: ppp0 <--> /dev/pts/3
sent [LCP ConfReq id=0x1 <magic 0x552f41bf>]
sent [LCP ConfReq id=0x1 <magic 0x552f41bf>]
rcvd [LCP ConfReq id=0x1 <magic 0x82dcfce2>]
sent [LCP ConfAck id=0x1 <magic 0x82dcfce2>]
sent [LCP ConfReq id=0x1 <magic 0x552f41bf>]
rcvd [LCP ConfAck id=0x1 <magic 0x552f41bf>]
sent [LCP EchoReq id=0x0 magic=0x552f41bf]
View tetris.c
#include <stdbool.h>
#include <curses.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#define STAGE_ROW 20
@tiqwab
tiqwab / pinky.md
Last active Sep 6, 2019
Signed division by 2^n
View pinky.md
@tiqwab
tiqwab / openjdk_interpreter.md
Last active Aug 10, 2019
short memo for interpreter implementation of OpenJDK11
View openjdk_interpreter.md

OpenJDK の interpreter とは

  • Java byte code の interpreter
  • (Java) メソッドはまず interpreter で実行される
  • (条件を満たすと) JIT コンパイルで生成されたネイティブコードを実行する

簡単な Java byte code 例

class Example1 {