Skip to content

Instantly share code, notes, and snippets.

View nhatnx's full-sized avatar

Nhat Nguyen nhatnx

  • Ho Chi Minh city, Vietnam
View GitHub Profile
import * as React from "react";
import { useMousePosition } from "~/hooks/useMousePosition";
/** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */
export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) {
const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {};
const [mouseX, mouseY] = useMousePosition();
const positions = { x, y, h, w, mouseX, mouseY };
return (
<div
@nhatnx
nhatnx / README.md
Created April 10, 2018 04:45 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet
@nhatnx
nhatnx / dabblet.css
Created December 4, 2017 04:46 — forked from bhargav2785/dabblet.css
Pure CSS wave effect *
/** Pure CSS wave effect **/
div.wave{
position: relative;
width: 100%;
}
div.wave > span{
float: left;
width: 10%;
height: 200px;
animation: animate 1.5s ease-in-out alternate infinite;
@nhatnx
nhatnx / embedded-file-viewer.md
Created October 13, 2017 08:14 — forked from tzmartin/embedded-file-viewer.md
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

@nhatnx
nhatnx / pmg-rewrite.php
Created October 11, 2017 05:37 — forked from chrisguitarguy/pmg-rewrite.php
WordPress rewrite tutorial
<?php
/*
Plugin Name: Rewrite Rule Tutorials
*/
add_action( 'init', 'pmg_rewrite_add_rewrites' );
function pmg_rewrite_add_rewrites()
{
add_rewrite_endpoint( 'json', EP_PERMALINK );
add_rewrite_rule(
@nhatnx
nhatnx / Run in LOCAL terminal...
Created January 20, 2016 05:06 — forked from jswartwood/Run in LOCAL terminal...
Automatic Git deploys on Dreamhost
# Replace any brackets with real values
# Try to ssh in to DREAMHOST (ensure it no longer asks for a PW); you may want to restart Terminal
ssh [user]@[host]
cd ~
mkdir [mydomain_com].git
cd [mydomain_com].git
git init --bare
vi hooks/post-receive
# Enter the code from the "post-receive" file (in this gist); save + quit
@nhatnx
nhatnx / gist:eff8e47b29f4a1463b19
Created November 5, 2015 11:24 — forked from molotovbliss/gist:2562551
Magento Snippets

Magento Snippets

Set all categories to is_anchor 1

Find attribute_id

SELECT * FROM eav_attribute where attribute_code = 'is_anchor'

Update all of them with anchor_id from above (usually is ID 51)

UPDATE `catalog_category_entity_int` set value = 1 where attribute_id = 51
@nhatnx
nhatnx / 0_reuse_code.js
Created October 20, 2015 05:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console