Skip to content

Instantly share code, notes, and snippets.

View quan-na's full-sized avatar

Quan Nguyen quan-na

  • Government Window
  • Saigon
View GitHub Profile
@quan-na
quan-na / jquery_show_error.js
Created July 10, 2019 14:23
Show an error message using jquery
var validator = $( "#myshowErrors" ).validate();
validator.showErrors({
"firstname": "I know that your firstname is Pete, Pete!"
});
@quan-na
quan-na / quanna-power-state.fish
Last active June 11, 2019 13:49
Show power state on Fedora (cpu frequency and battery status)
#!/usr/bin/env fish
set freqs (cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq)
# printf "🔳🔲"
for freq in $freqs
if [ $freq -gt 1000000 ]
printf '🔲%.*f' 2 (math "$freq / 1000000")
else
printf '🔳%.*f' 2 (math "$freq / 1000000")
@quan-na
quan-na / autoscroll.fish
Created May 28, 2019 12:30
Fish script auto scroll
#!/usr/bin/fish
echo Please focus to window to scroll in next 10 seconds...
sleep 10
set stitle (xdotool getwindowfocus getwindowname)
echo now scrolling "$stitle"
while true
set title (xdotool getwindowfocus getwindowname)
if [ "$title" = "$stitle" ]
@quan-na
quan-na / simplifying.py
Created December 31, 2018 01:20
codewars
# https://www.codewars.com/kata/simplifying/train/python
import re
from functools import reduce
def parse(formulaString):
""" Parse a string and return formula as a map var->factor """
def stateFunc(state, token):
if token == "-":
state['sign'] = -state['sign']
elif token == "(":
@quan-na
quan-na / my-node.el
Created October 21, 2018 03:39
trying to hack babel js session
;;; my-node -- Node js development
;;; Commentary:
;;; Code:
;; get indium
;;(get-cabage "yasnippet" "https://github.com/joaotavora/yasnippet.git")
;;(get-cabage "multiple-cursors" "https://github.com/magnars/multiple-cursors.el.git")
;;(get-cabage "js2-refactor" "https://github.com/magnars/js2-refactor.el.git")
;;(get-cabage "indium" "https://github.com/NicolasPetton/Indium.git")
@quan-na
quan-na / Useful quotes.txt
Last active June 14, 2018 07:58
Quotes taken from books
SICP - 1.1 The Elements of Programming
In programming, we deal with two kinds of elements: procedures and data. (Later we will discover that they are really not so
distinct.) Informally, data is ‘‘stuff’’ that we want to manipulate, and procedures are descriptions of the rules for manipulating
the data. Thus, any powerful programming language should be able to describe primitive data and primitive procedures and should
have methods for combining and abstracting procedures and data.
-----------------------------------------------------------------------------------------------------------------------------------
SICP - 1.1.7 Example: Square Roots by Newton’s Method
The contrast between function and procedure is a reflection of the general distinction between describing properties of things
@quan-na
quan-na / userContent.css
Last active May 24, 2018 10:36
Got bored and customize reddit home page in firefox
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain(reddit.com) {
body {
font-family: 'Josefin Slab', sans-serif !important;
/* text-transform: uppercase !important; */
}
#sr-header-area {
background-color: #ffa000 !important;
}
v[^^]v m[..]m o['']b o[**]P o[--]o
+--+--+--+--+--+--+--+--+--+--+
| | | | | |
+ < < < < +
| | | | | |
+--v--+--+--+--+--+--+--+--^--+
| | | | | |
+ + > > + +
| | | | | |
+--v--+--^--+--+--+--v--+--^--+
| | | | | |
@quan-na
quan-na / jvm-args.sh
Created May 16, 2018 10:21
Jvm arguments. to save memory
-XXaltjvm=dcevm -javaagent:D:\RECYCLER\dcevm\hotswap-agent.jar
-server
-Xverify:none
-XX:+UseG1GC
-XX:MinHeapFreeRatio=15
-XX:MaxHeapFreeRatio=25
-Xms8m
-Xmx512m