Skip to content

Instantly share code, notes, and snippets.

@seungjin
seungjin / bash
Last active April 29, 2024 04:05
remove duplicated eml in thunderbird maildir
for file in $(ls | egrep '^.+-[0-9].eml$'); do
mv -- "$file" "`echo $file | sed "s/-[0-9].eml$/.eml/"`";
done;
autosave = "!f () { \
origin=$(git remote) ; \
project_name=$(git remote get-url $origin | xargs basename -s .git) ; \
current_branch=$(git rev-parse --abbrev-ref HEAD) ; \
gsm=$(git status) ; \
ntc=$(echo $gsm | grep \"nothing to commit, working tree clean\" | wc -l) ; \
ybi=$(echo $gsm | grep \"Your branch is ahead of '$origin/$current_branch' by\" | wc -l) ; \
ybi2=$(echo $gsm | grep \"Your branch is ahead of '$origin/main' by\" | wc -l) ; \
if [ $ntc -ne 1 ] || ([ $ybi -ne 1 ] && [ $ybi2 -ne 0 ]); then\
echo \"💾 Autosaving...\" ; \
use base64::{engine::general_purpose, Engine as _};
use chrono::Utc;
use http::HeaderMap;
use openssl::hash::MessageDigest;
use openssl::pkey::{PKey, Private};
use openssl::sha::Sha256;
use openssl::sign::Signer;
use std::collections::HashMap;
use std::fs;
require 'http'
require 'openssl'
document = File.read('create-hello-world.json')
date = Time.now.utc.httpdate
sha256 = OpenSSL::Digest::SHA256.new
digest = sha256.digest(document)
ed = 'SHA-256='+Base64.encode64(digest).strip
@seungjin
seungjin / Disable how using the scrollwheel on the switches to the next Desktop.txt
Created May 27, 2019 21:51
LXQT, Disable how using the scrollwheel on the switches to the next Desktop
Disable how using the scrollwheel on the switches to the next Desktop
Source: https://help.ubuntu.com/community/Lubuntu/Mouse#Disable_how_using_the_scrollwheel_on_the_switches_to_the_next_Desktop
Before restarting openbox with this command: openbox --reconfigure
Edit ~/.config/openbox/lubuntu-rc.xml and remove these lines:
<mousebind button="Up" action="Click">
<action name="GoToDesktop">
<to>previous</to>
</action>
defmodule DurationFormatter do
def format_duration(0), do: "now"
def format_duration(s) do
year = div(s, 31536000)
day = div(s - year * 31536000, 86400)
hour = div(s - year * 31536000 - day * 86400,3600)
min = div(s - year * 31536000 - day * 86400 - hour * 3600,60)
sec = rem(s,60)
defmodule Wallpaper do
@spec wallpaper(number, number, number) :: String.t
def wallpaper(l, w, h) do
case (( ( l * h ) + (w * h) )* 2 * 1.15 ) / 5.2 |> Float.ceil do
0.0 -> "zero"
1.0 -> "one"
2.0 -> "two"
3.0 -> "three"
defmodule Datemizer do
def shorten_to_date(datetime) do
datetime |> String.split(",") |> hd
end
end
#!/usr/bin/env python2
import sys
from operator import itemgetter
from collections import defaultdict
def main():
count = defaultdict(int)
for line in sys.stdin:
for word in line.split():
count[word] += 1
#!/usr/bin/env julia
count = Dict()
for line in eachline(stdin)
for word in split(line)
if haskey(count,word)
count[word] += 1
else
count[word] = 1