Skip to content

Instantly share code, notes, and snippets.

@khoahuynhdev
khoahuynhdev / heart.css
Last active February 5, 2019 13:35
Draw a little pink heart using html and css
style>
.heart {
position: absolute;
margin: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: pink;
height: 50px;
@khoahuynhdev
khoahuynhdev / HttpListenerDemo.cs
Last active July 20, 2022 11:28
simple HttpListener in C#
using System;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace HttpListenerExample
{
class Program
{
public static HttpListener listener;
@khoahuynhdev
khoahuynhdev / QSetup.js
Last active April 3, 2019 04:29
Quick and easy to use
// Pseudo Jquery
const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);
// convert a number in decimal to binary
8..toString('2') // '1000'
@khoahuynhdev
khoahuynhdev / util.txt
Last active May 6, 2019 06:06
useful methods to handle some situations
// If you’ve accidentally checked in node_modules before, that’s okay. You can remove it like this:
echo 'node_modules' >> .gitignore
git rm -r --cached node_modules
git commit -am 'ignore node_modules'
// create dump data for mysql
// SET PATH FIRST
mysqldump -u YourUser -p YourDatabaseName > wantedsqlfile.sql
// Use utf8 in CMD Windows
@khoahuynhdev
khoahuynhdev / database.js
Created April 20, 2019 06:58 — forked from hagemann/database.js
Promisified MySQL middleware for Node.js
const util = require('util')
const mysql = require('mysql')
const pool = mysql.createPool({
connectionLimit: 10,
host: 'localhost',
user: 'root',
password: 'password',
database: 'my_database'
})
var fs = require('fs');
var https = require('https');
var express = require('express');
var app = express();
var options = {
key: fs.readFileSync('./file.pem'),
cert: fs.readFileSync('./file.crt')
};
var serverPort = 443;
@khoahuynhdev
khoahuynhdev / download.js
Last active May 25, 2019 12:34
download file with axios
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@khoahuynhdev
khoahuynhdev / rm_mysql.md
Created June 12, 2019 04:32 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

brew remove mysql

@khoahuynhdev
khoahuynhdev / corona.vim
Last active March 30, 2020 13:17
Check corona update in Vim
function! s:corona_stats() abort
let l:lines = []
let l:keys = [
\ ['country', 'Quốc gia'],
\ ['cases', 'Số ca'],
\ ['todayCases', 'Số ca (hôm nay)'],
\ ['deaths', 'Tử vong'],
\ ['todayDeaths', 'Tử vong (hôm nay)'],
\ ['recovered', 'Hồi phục'],
\]