Skip to content

Instantly share code, notes, and snippets.

View nhatkha1407's full-sized avatar
🚀

Whoosh nhatkha1407

🚀
View GitHub Profile
/**
* A bookmarklet for viewing the largest contentful paint in a page.
* Will show each LCP after the bookmarklet is clicked.
*
* To install:
* 1. Copy the code starting from the line beginning `javascript:`
* 2. Add a new bookmark in Chrome, and paste the code in as the URL.
**/
javascript:(function(){
try {
@MichaelCurrin
MichaelCurrin / README.md
Last active March 5, 2024 22:06
GitHub GraphQL - Get files in a repository

Get GitHub Files

Get the metadata and content of all files in a given GitHub repo using the GraphQL API

You might want to get a tree summary of files in a repo without downloading the repo, or maybe you want to lookup the contents of a file again without download the whole repo.

The approach here is to query data from GitHub using the Github V4 GraphQL API.

About the query

@laocoi
laocoi / vietnamese-slug.js
Last active May 28, 2024 14:54
Create Vietnamese slug from string - Javascript
function slugify(string){
const a = 'àáäâãåăæąçćčđďèéěėëêęğǵḧìíïîįłḿǹńňñòóöôœøṕŕřßşśšșťțùúüûǘůűūųẃẍÿýźžż·/_,:;'
const b = 'aaaaaaaaacccddeeeeeeegghiiiiilmnnnnooooooprrsssssttuuuuuuuuuwxyyzzz------'
const p = new RegExp(a.split('').join('|'), 'g')
return string.toString().toLowerCase()
.replace(/á|à|ả|ạ|ã|ă|ắ|ằ|ẳ|ẵ|ặ|â|ấ|ầ|ẩ|ẫ|ậ/gi, 'a')
.replace(/é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ/gi, 'e')
.replace(/i|í|ì|ỉ|ĩ|ị/gi, 'i')
.replace(/ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ/gi, 'o')
.replace(/ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự/gi, 'u')
@bill-mfv
bill-mfv / install.md
Last active July 14, 2022 06:29
Install RoR env

HomeBrew is a package manager for OSX. Brew install missing stuff so easy…

  • Install Homebrew:
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Change permission for zsh

  • Change the ownership of these directories to your user:
    sudo chown -R $(whoami) /usr/local/share/zsh /usr/local/share/zsh/site-functions
  • And make sure that your user has write permission:
    chmod u+w /usr/local/share/zsh /usr/local/share/zsh/site-functions

https://github.com/reireias/dotseeker

grep -r -E -v -h '^\s*#' files | grep --color=none -E "^\s*alias " | sed -e 's/#.*//g' -e 's/^\s*//g' -e 's/\s*$//g' | sort | uniq -c | sort -nr
 90 alias ls='ls --color=auto'
 87 alias grep='grep --color=auto'
 59 alias fgrep='fgrep --color=auto'

59 alias egrep='egrep --color=auto'

@4iTeam
4iTeam / remove_unavailable_accounts.js
Last active April 26, 2019 02:04
Remove unavailable facebook account from group
(function (group_id) {
var MemberRemover={
init:function(){
this.members=[];
this.dtsg=this.getDtsg();
this.user_id=this.getUserId();
return this;
},
run:function(){
@zaydek-old
zaydek-old / bookmark.min.js
Last active May 28, 2024 19:18
A *simple* CSS debugger. To use, bookmark "Debug CSS" at https://zaydek.github.io/debug.css. Learn more here https://medium.freecodecamp.org/88529aa5a6a3 and https://youtu.be/2QdzahteCCs?t=1m25s (starts at 1:25)
/* debug.css | MIT License | zaydek.github.com/debug.css */ if (!("is_debugging" in window)) { is_debugging = false; var debug_el = document.createElement("style"); debug_el.append(document.createTextNode(`*:not(g):not(path) { color: hsla(210, 100%, 100%, 0.9) !important; background: hsla(210, 100%, 50%, 0.5) !important; outline: solid 0.25rem hsla(210, 100%, 100%, 0.5) !important; box-shadow: none !important; filter: none !important; }`)); } function enable_debugger() { if (!is_debugging) { document.head.appendChild(debug_el); is_debugging = true; } } function disable_debugger() { if (is_debugging) { document.head.removeChild(debug_el); is_debugging = false; } } !is_debugging ? enable_debugger() : disable_debugger();
@harrietty
harrietty / RAILS_5_CHEATSHEET.md
Last active August 13, 2023 00:36 — forked from mdang/RAILS_CHEATSHEET.md
Ruby on Rails 5 Cheatsheet

Ruby on Rails Cheatsheet (5.1)

Architecture

RVM

$ rvm list - show currently installed Rubies

@TheNodi
TheNodi / HashidsRoutable.php
Last active June 15, 2023 23:18
Laravel Model Bindings with Hashids
<?php
namespace App;
use Vinkla\Hashids\HashidsManager;
/**
* Bind a model to a route based on the hash of
* its id (or other specified key).
*