Skip to content

Instantly share code, notes, and snippets.

View 50kudos's full-sized avatar
🏡
Remote async work

Waranyoo Butsingkorn 50kudos

🏡
Remote async work
  • Thailand
  • 09:06 (UTC +07:00)
  • X @_fifwb
View GitHub Profile
@50kudos
50kudos / ce.css
Last active October 9, 2022 14:09
Custom elements compose nested props (https://jsfiddle.net/2L5ypn9a/2/)
button { margin: .5rem; }
input { display: inline-block; margin: 0 .5rem; }
stack-btns+span {display: block}
@50kudos
50kudos / unlike.js
Created September 7, 2022 00:05
Unlike tweets
// Adjust as your computer see fit. Too fast, resource releasing will lag.
var doit = () => {
let btns = document.querySelectorAll("[data-testid='unlike']")
if (btns.length == 0) document.querySelector("html").scrollTop += 400
else for (let btn of btns) setTimeout(() => btn.click(), 100)
setTimeout(() => doit(), 300)
}
@50kudos
50kudos / json-thick.md
Last active March 13, 2022 06:02
Json with metadata

json-thick is json whose node has metadata attached along with its value.

Purpose

Work with human interaction either directly with json file or as input/output format used by other user interfaces (e.g. GUI), with extra information on each value, suitable for guided processing or data persistence.

Example

Thick

{
  "c": "root comment",
[
"4",
"46",
"lv:phx-FjMP_AdCLJo1JfDi",
"phx_reply",
{
"response": {
"diff": {
"0": {
"6": {
@50kudos
50kudos / flashflush.sh
Last active November 3, 2019 02:03
A Bash script that lists all unused css classes in html/haml/erb files for rails project (or maybe others depending on project structure)
#!/bin/bash
cat $(find app/assets/stylesheets/ -type f) |
grep -Eo '\.[a-z]+[a-z0-9_-]*' | sort | uniq | sed s/.// |
while read CSS; do
if ! grep -Erqi "([^(remove|has)]?class[(:|=|[:space:]*=>[:space:]*)]*[[:space:]\W]*[(\"|')]*[-a-z0-9[:space:]]*$CSS|\\.$CSS\b)" app/views/ vendor/assets/ app/assets/javascripts/; then
echo $CSS >> unused.scss;
fi
done
defmodule FoldlaWeb.DataLive do
use Phoenix.LiveView
def render(assigns) do
FoldlaWeb.DataView.render("edit.html", assigns)
end
def mount(_params, socket) do
{:ok, assign(socket, :thing, 0)}
end
@50kudos
50kudos / linux.md
Last active August 12, 2017 22:07
Arch-KDE/MacOS/Windows scripts

Allow root logon

  1. Swap to console mode (ctrl+alt+F3)
  2. Login as root
  3. In /usr/share/config/kdm/kdmrc, change AllowRootlogon = false to true

Simplest list hidden files only

ls -ld .* OR ls -ld .??*

mkv to mp4

-module(w22list).
-export([take/2, nub/1]).
-spec take(integer(), [T]) -> T.
take(0, _L) -> [];
take(I, L) when I < 0 orelse I > length(L) -> L;
take(I, [H|T]) ->
[H | take(I-1, T)].
nub(L) -> nub(lists:sort(L), []).
-module(w2list).
-export([t_product/1, product/1, t_maximum/1, maximum/1]).
% t_ prefix means tail recursion implementation.
t_product(L) ->
t_product(L, 1).
t_product([], P) ->
P;
t_product([H|T], A) when is_number(H) ->
-module(w21list).
-export([double/1, evens/1, median/1, mode/1]).
double([]) -> [];
double([H|T]) ->
[H * 2 | double(T)].
evens([]) -> [];
evens([H|T]) ->
case H rem 2 of