Skip to content

Instantly share code, notes, and snippets.

View tiqwab's full-sized avatar

Naohisa Murakami tiqwab

View GitHub Profile
@tiqwab
tiqwab / rsa.py
Last active October 9, 2023 03:08
RSA encryption and decryption
import base64
import hashlib
import os
import secrets
import sys
from typing import Tuple
from Crypto.Util.asn1 import DerBitString, DerOctetString, DerSequence
@tiqwab
tiqwab / build-git.md
Created May 28, 2022 05:09 — forked from egorsmkv/build-git.md
Build git from source code on CentOS 7

Build git from source code

1) Go to https://git-scm.com/ and check out the latest version of Git

Currently, the latest version is 2.18.0. Download and extract it and go to the folder of the source code:

wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.18.0.tar.gz
tar xf git-2.18.0.tar.gz
cd git-2.18.0/
@tiqwab
tiqwab / custom_enum.rs
Last active March 18, 2022 09:36
serde まわりのノウハウをまとめたい
// enum の Serialize, Deserialize with tag
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
pub struct Novel {
author: String,
pages: u32,
}
#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 August 1, 2021 03:35
Implement iterator to generate permutations of the given vec in Rust
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 February 23, 2021 03:21
Ansible の no_log に未定義の変数を使用したとき
$ 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 February 13, 2021 01:46 — forked from croxton/SSL-certs-OSX.md
Generate ssl certificates with Subject Alt Names

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 July 11, 2020 04:00
How to access symbol and its content by assembly (and with PIE)
$ 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 March 29, 2020 03:39
One usage of PhantomData in Rust.

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 September 24, 2019 05:30
pppd sample working on Ubuntu 18.04
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]