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 / 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 / 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 / HashPerformance.scala
Created January 11, 2019 03:29
MD5 and SHA-256 with Scala
package example
trait HashPerformance {
def hash(str: String): String
def doCheck(count: Int): Unit = {
val key = "something"
val hashed = hash(key)
println(hashed)
@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 / 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。

# window の操作
bind -n S-down new-window
bind -n S-left prev
bind -n S-right next
#
#
# # C-bのキーバインドを解除する
set-option -g prefix C-t
unbind-key C-b
@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