Skip to content

Instantly share code, notes, and snippets.

@nomeaning777
nomeaning777 / list-thread-cpu-affinity.py
Created January 16, 2024 07:30
List up the threads of a specific process and their CPU affinity
#!/usr/bin/python3
import os
import sys
for pid in sys.argv[1:]:
path = '/proc/' + pid + '/task'
if os.path.exists(path):
for tid in sorted(os.listdir(path)):
with open(f"{path}/{tid}/comm", 'r', encoding='utf-8') as r:
@nomeaning777
nomeaning777 / calc.sage
Last active September 21, 2020 13:26
XOR and shift encryptor Solver using Matrix
M = Matrix(GF(2), 64 * 64)
for i in range(64 * 64):
M[i, i] = 1
s0 = list(M[0:64])
s1 = list(M[64:128])
ZERO = [vector(GF(2), [0] * 64 * 64)]
def shift(v, delta):
if delta > 0:
return (ZERO * delta + v[0:-delta])
@nomeaning777
nomeaning777 / index.html
Created September 4, 2020 08:18
JS Bin tspan getBoundingClientRect // source https://jsbin.com/humuroj
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="tspan getBoundingClientRect">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
@nomeaning777
nomeaning777 / remove-old-vagrant-box.rb
Created July 31, 2017 03:43
古いvagrant boxを削除する
#!/usr/bin/ruby
data = `vagrant box list`.gsub(/\(|\)|,/,'').lines.sort.map(&:split)
u = []
data.reverse_each do |name, provider, version|
if u.include?([name, provider])
system 'vagrant', 'box', 'remove', '--provider', provider, '--box-version', version, name
else
u << [name, provider]
end
end
@nomeaning777
nomeaning777 / template.tex
Created April 7, 2017 10:52
My uplatex template
\documentclass[report,11pt,uplatex,a4j]{jsbook}
\usepackage{amsmath,amssymb}
\usepackage{bm}
\usepackage{ascmac}
\usepackage{geometry}
\geometry{left=25mm,right=25mm,top=30mm,bottom=30mm}
\usepackage{url}
\usepackage[linesnumbered,ruled]{algorithm2e}
\SetKwRepeat{Do}{do}{while}
\renewcommand{\baselinestretch}{1.2}
/**********************************************************
AIのサンプル
**********************************************************/
#include "Data.h"
#include <cassert>
#include <queue>
#include "windows.h"
#include <string>
#include <sstream>
@nomeaning777
nomeaning777 / xmonad.hs
Created November 1, 2012 12:46
xmonad memo
import System.Posix.Env (getEnv)
import Data.Maybe (maybe)
import XMonad
import XMonad.Config.Desktop
import XMonad.Config.Gnome
import XMonad.Config.Kde
import XMonad.Config.Xfce
@nomeaning777
nomeaning777 / AOJ1170.cpp
Created October 3, 2012 03:10
AOJ 1170 Time Limit Excceed
#include <iostream>
#include <vector>
#include <cassert>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <tr1/unordered_set>
#include <map>
using namespace std;
@nomeaning777
nomeaning777 / virtual_arena.js
Created September 30, 2012 14:51
UserScript that works with Opera and Firefox
// ==UserScript==
// @name Virtual Arena Link Change
// @namespace http://twitter.com/k_operafan
// @version 1.0.0
// @description Virtual Areena(AOJ)のLiveArchiveのリンクをpdfからhtmlに書きかえる。
// @include http://rhodon.u-aizu.ac.jp:8080/arena/*
// ==/UserScript==
(function(){
function func(){
Module MainModule
Sub Main()
Dim comb(101, 101) As Integer, ans As Integer = 0
comb(0, 0) = 1
For i = 0 To 100
For j = 0 To i
comb(i + 1, j) += comb(i, j)
If comb(i + 1, j) > 1000000 Then
comb(i + 1, j) = 1000000
End If