Skip to content

Instantly share code, notes, and snippets.

View dinhanhthi's full-sized avatar
🔥
I failed my way to success!

Anh-Thi DINH dinhanhthi

🔥
I failed my way to success!
View GitHub Profile
@dinhanhthi
dinhanhthi / .zshrc
Last active June 21, 2022 19:22
.zshrc
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="spaceship"
plugins=(git docker docker-compose npm python emoji)
source $ZSH/oh-my-zsh.sh
# export PATH="/opt/conda/bin:$PATH" # commented out by conda initialize
export PATH="/snap/ngrok/current:$PATH"
@dinhanhthi
dinhanhthi / search-agents-sdk.js
Created October 29, 2021 18:22
Example of using Google Dialogflow SDK APIs
// Obtain JSON first: https://cloud.google.com/docs/authentication/getting-started#creating_a_service_account
// How to use: node search-agents-sdk.js
// SDK reference: https://googleapis.dev/nodejs/dialogflow/latest/v2.AgentsClient.html#searchAgents
"use strict";
require('dotenv').config();
// private_key and client_email are store in .env file
async function main() {
const location = "global";
@dinhanhthi
dinhanhthi / search-agents-json-rest.js
Created October 29, 2021 18:03
Using Google REST API with NodeJS
// Obtain JSON first: https://cloud.google.com/docs/authentication/getting-started#creating_a_service_account
// How to use: node search-agents-json-rest.js
// Search agents API: https://cloud.google.com/dialogflow/es/docs/reference/rest/v2/projects.agent/search
require("dotenv").config();
const { google } = require("googleapis");
const request = require("request");
async function main() {
@dinhanhthi
dinhanhthi / list_starred_repositories.html
Last active January 6, 2021 13:42
List of starred Github repositories
<ol id="lst_repos"></ol>
<script>
function htmlEntities(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
var ul = document.getElementById("lst_repos");
fetch("https://api.github.com/users/dinhanhthi/starred?page=1&per_page=10000")
.then(response => response.json())
.then(data => {
@dinhanhthi
dinhanhthi / toc_scrolling.html
Created December 15, 2020 22:40
Scrolling heading inside TOC
<div class="toc">
<ol>
<li class=""><a href="#heading-1">Heading 1</a></li>
<li class=""><a href="#heading-2">Heading 2</a></li>
</ol>
</div>
@dinhanhthi
dinhanhthi / search_li_trigger.js
Last active December 15, 2020 22:36
Search result with navigation
// Maybe on separated file (where we create DOM of result)
// mouse hover trigger for li
ulRes.querySelectorAll("li").forEach((item) => {
item.addEventListener("mousemove", () => {
addSelected2(ulRes, item);
}, false);
// if <a> focused by a Tab key
item
.getElementsByClassName("item__content")[0]
@dinhanhthi
dinhanhthi / anchor_fixed_header.js
Created December 10, 2020 10:56
Anchor links hidden by fixed navigation
// anchor link fixed navigation from top
function offsetAnchor() {
if (location.hash.length !== 0) {
window.scrollTo(window.scrollX, window.scrollY - 60);
}
}
// Captures click events of all <a> elements with href starting with #
addEventListener('click', function (e) {
// Click events are captured before hashchanges. Timeout
// causes offsetAnchor to be called after the page jump.
@dinhanhthi
dinhanhthi / hover_anchor.html
Last active December 10, 2020 10:54
Heading hover anchor link
<head>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
@dinhanhthi
dinhanhthi / back_to_top.css
Created December 10, 2020 10:51
Back to top button
.cd-top {
display: inline-block;
height: 50px;
width: 50px;
position: fixed;
bottom: 2%;
right: 2%;
border-radius: 40px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
/* image replacement properties */
@dinhanhthi
dinhanhthi / hsbox.html
Created December 10, 2020 10:44
Hide / Show box
<div class="hs__title">Click here</div>
<div class="hs__content">Content</div>