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
  • 02:39 (UTC +07:00)
  • X @_fifwb
View GitHub Profile
@50kudos
50kudos / ah.erl
Last active February 21, 2017 01:48
-module(third).
-export([maxThree/3,howManyEqual/3,eXOR/2]).
eXOR(X,Y) when is_boolean(X) andalso is_boolean(Y) ->
case {X,Y} of
{Y,X} -> false;
_ -> true
end.
maxThree(A,B,C) when is_integer(A) andalso is_integer(B) andalso is_integer(C) ->
@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
;.MODEL SMALL
IMAGESG SEGMENT
AREA DB 0FFFFH DUP(99) ;BMP INTO
IMAGESG ENDS
DATASG SEGMENT
IMG DB "N1.BMP",0 ;PIC0
DB "N2.BMP",0 ;PIC1
DB "N3.BMP",0 ;PIC2
DB "N4.BMP",0 ;PIC3
@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

@50kudos
50kudos / agent.conf
Created October 14, 2013 04:03
Text processing (Only Ubuntu)
#161.246.34.191:-:161.246.34.195:-:sID.123456789012196:-:9999
!interval::1
!treshold::userCPU=51=89=180=180=300=999:-:usedMem=71=79=180=180=999=999:-:pUsedHdd=51=79=180=180=999=999:-:load5=1.50=1.79=180=180=200=999:-:load15=1.50=1.79=180=200=300=600
#treshold::key,threshold1,threshold2,t1(time to warning),t2(time to critical),t3(special time for migrate),t4(extra time for migrate) ,remark load5 t3 and t2 must be different 20+
$userCPU::sar -u 1 1 | sed -n 4,4p | awk '{print $4}'
$sysCPU::sar -u 1 1 | sed -n 4,4p | awk '{print $6}'
$load1::w | sed -n 1,1p |sed 's/.*: \(\)/\1/g' | cut -d, -f1
$load5::w | sed -n 1,1p |sed 's/.*: \(\)/\1/g' | cut -d, -f2 | sed s/' '//
$load15::w | sed -n 1,1p |sed 's/.*: \(\)/\1/g' | cut -d, -f3 | sed s/' '//
$pUsedHdd::df | grep '\/$' | awk '{if($1~/sda/)$4=$5};END{print $4}' | sed s/%//
@50kudos
50kudos / Rspec_note
Created October 9, 2013 19:27
Rspec behaviour
Ruby will interprete variable inside "it block" before calling let.
So don't use the same varible name as let in the block.
@50kudos
50kudos / Pending_jobs_counting.md
Last active December 21, 2015 09:19
redis-cli

http://redis.io/commands/lrange

Key: 'resque:queue:immediate' (list by KEYS *)

redis-cli LRANGE 'resque:queue:immediate' 0 -1 | grep 'InferFeedUrl' | wc -l

(grep ruby job's class defined at hash key.)