Skip to content

Instantly share code, notes, and snippets.

View kawakami-o3's full-sized avatar

Hayato Mikami kawakami-o3

  • Japan, Tokyo
View GitHub Profile
@kawakami-o3
kawakami-o3 / script_console.groovy
Created September 29, 2021 02:09
Jenkins credentials.xml decryptor
import static hudson.util.Secret.decrypt
void printEntry(credential, attr) {
def text = credential."${attr.toLowerCase()}".text()
println("${attr}: ${text}")
}
def text = new File('/var/lib/jenkins/credentials.xml').text
def list = new XmlParser().parseText(text).domainCredentialsMap.entry.'java.util.concurrent.CopyOnWriteArrayList'.'*'
import os
def get_size_dir(path='.'):
total_size = 0
for dir_path in os.listdir(path):
full_path = os.path.join(path, dir_path)
if os.path.isfile(full_path):
total_size += os.path.getsize(full_path)
elif os.path.isdir(full_path):
total_size += get_size_dir(full_path)
@kawakami-o3
kawakami-o3 / array_vs_list.c
Last active January 9, 2021 09:29
Array vs List
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define N 10000
#define TRIAL 10000
typedef struct Cell {
int value;
struct Cell *next;
@kawakami-o3
kawakami-o3 / recvmssg_main.rs
Last active March 1, 2023 13:52
recvmmsg and sendmmsg examples in Rust
// https://linuxjm.osdn.jp/html/LDP_man-pages/man2/recvmmsg.2.html in Rust
//
// 1. Run a receiver.
// $ cargo run
// 2. Send test data to a receiver.
// $ while true; do echo $RANDOM > /dev/udp/127.0.0.1/1234; done
use std::mem;
use libc::*;
@kawakami-o3
kawakami-o3 / main.c
Last active July 4, 2019 07:03
print without libc
// Just an example.
#include<unistd.h>
int main() {
write(1, "hello\n", 6);
}
// Sort release blocker issues to the end.
ri := x[i].Issue != nil && x[i].Issue.HasLabel("release-blocker")
rj := x[j].Issue != nil && x[j].Issue.HasLabel("release-blocker")
if ri != rj {
return ri
}
@kawakami-o3
kawakami-o3 / main.rs
Last active March 25, 2019 05:50
Rust Rc RefCell
use std::rc::Rc;
use std::cell::RefCell;
/*
#[derive(Clone, Debug)]
struct Node {
val: i32,
ptr: Option<Rc<Node>>,
}
fn new_node(val: i32, ptr: Option<Rc<Node>>) -> Node {
@kawakami-o3
kawakami-o3 / main.rs
Created February 18, 2019 14:29
vector example in Rust
#[derive(Debug)]
struct Hoge {
a: i32,
b: i32,
}
fn main() {
let mut v = Vec::new();
v.push(Hoge{a: 1, b: 2});
v.push(Hoge{a: 2, b: 4});
@kawakami-o3
kawakami-o3 / git-next-commit.sh
Created November 26, 2018 17:36
checkout next commit
#!/bin/sh
current=`git log --oneline | wc | awk '{print $1}'`
sha1=`git log master --oneline | tail -$((current+1)) | head -1 | awk '{print $1}'`
git checkout $sha1