Skip to content

Instantly share code, notes, and snippets.

View severalsed.sh
#1 add multiple lines into specific match
cat << EOF | sed '/somematch/ r /dev/stdin' filename.txt
line1
line2
line3
EOF
# delete nth lines last
tac filename.txt | sed '1,3 d' | tac > filename.txt
View DecompileDataClassKotlin.java
import kotlin.Metadata;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@Metadata(
mv = {1, 4, 0},
bv = {1, 0, 3},
k = 1,
View MyPerlSettings.json
# .vscode/settings.json
{
"perlcritic.executable": "perlcritic",
"perlcritic.additionalArguments": ["--profile", "---"],
"[perl]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "sfodje.perltidy"
},
"perltidy.executable": "perltidy",
"perltidy.profile": "---",
@ulwlu
ulwlu / ManacherRust.rs
Last active Mar 2, 2021
Implement Manacher algorithm in Rust. Article -> https://zenn.dev/ulwlu/articles/1387c9b44137ac
View ManacherRust.rs
pub fn longest_palindrome(s: String) -> String {
let l = s.len();
if l <= 1 {
return s;
}
// MEMO: We need to detect odd palindrome as well,
// therefore, inserting dummy string so that
// we can find a pair with dummy center character.
let mut chars: Vec<char> = Vec::with_capacity(s.len() * 2 + 1);
View partialsum.py
def solve(inputlist: list[int], N: int):
"""
1:
You can add or substruct => by switching any numbers' sign.
It means you can separate positive_group and negative_group.
2:
if abs(sum(positive_group)) - abs(sum(negative_group)) == TargetSum,
It achieves to sum up added/substructed all numbers to TargetSum.
View graham.py
from enum import Enum
from sys import maxsize
from math import atan2, degrees
from collections import deque
def graham_scan(points):
if len(points) <= 2:
# There is no convex hull
return -1
if len(points) == 3:
return points
View githublinks.md
View myjira.css
body {
will-change: transform;
color: #494949;
}
.wiki-content {
counter-reset: nth2;
}
.wiki-content h2 {
View mynedtreeairlineconfig.vim
Plug 'vim-airline/vim-airline'
Plug 'preservim/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
let g:airline_theme='elly'
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#show_close_button = 0
let g:airline#extensions#tabline#show_tab_nr = 0
map <Space>ner <plug>NERDTreeTabsToggle<CR>