Skip to content

Instantly share code, notes, and snippets.

View thieung's full-sized avatar
🎯

Thieu Nguyen thieung

🎯
View GitHub Profile
@thieung
thieung / lru_cache.rb
Created April 16, 2024 16:52 — forked from ralbt/lru_cache.rb
Ruby: LRU Cache Implementation
class LRUCache
attr_reader :dll, :hash, :count, :capacity
def initialize(capacity)
@dll = DLL.new
@hash = Hash.new
@count = 0
@capacity = capacity
end
def read(key)
@thieung
thieung / rails-jsonb-queries
Created February 8, 2023 14:41 — forked from mankind/rails-jsonb-queries
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
copy/delete word under cursor in Vim
yw / byw
Assuming that the cursor is at the first character of the word simply do this in command mode:
yw
y is for yank and w is for word.
Other ways of doing the same thing which are not as efficient:
vey
the v starts visual select mode. e tells vim to move to end of word. y yanks or copies the word. to delete replace y with x.
brew tap homebrew/cask-fonts
brew install --cask font-cascadia-code
brew install --cask font-cascadia-code-pl
brew install --cask font-cascadia-mono
brew install --cask font-cascadia-mono-pl
@thieung
thieung / update_neovim.zsh
Created December 21, 2022 08:16 — forked from joelpalmer/update_neovim.zsh
Update, Build and Install Neovim
# Update Neovim to latest from master
# https://github.com/neovim/neovim/commits/master
# You should have the Neovim repo cloned
upnvim() {
cd ~/vim-dev/sources/neovim # change to your local repo
git pull
make distclean
make CMAKE_BUILD_TYPE=RelWithDebInfo -j4 # Fast with Debug info. Not quite Release fast.
sleep 10 # You don't need this but I have my reasons :-)
sudo make install
PostgreSQL Type PostgreSQL Size Description Range Diesel Type Rust Type
Nullable Types nullable Nullable``
@thieung
thieung / osx-pdf-from-markdown.markdown
Created May 14, 2022 01:11 — forked from georgiana-gligor/osx-pdf-from-markdown.markdown
Markdown source for the "Create PDF files from Markdown sources in OSX" article

Create PDF files from Markdown sources in OSX

When [Markdown][markdown] appeared more than 10 years ago, it aimed to make it easier to express ideas in an easy-to-write plain text format. It offers a simple syntax that takes the writer focus away from the formatting, thus giving her time to focus on the actual content.

The market abunds of editors to be used for help with markdown. After a few attempts, I settled to Sublime and its browser preview plugin, which work great for me and have a small memory footprint to accomplish that. To pass the results around to other people, less technical, a markdown file and a bunch of images is not the best approach, so converting it to a more robust format like PDF seems like a much better choice.

[Pandoc][pandoc] is the swiss-army knife of converting documents between various formats. While being able to deal with heavy-weight formats like docx and epub, we will need it for the more lightweight markdown. To be able to generate PDF files, we need LaTeX. On OSX, the s

function GregToHijri(arg) {
console.log ( 'arg' );
console.log (arg);
if(arg == ""){
return "";
}
//declare a date format year,month,day sequence
var arabic_date = new Array(0,0,0);