Skip to content

Instantly share code, notes, and snippets.

View bhongy's full-sized avatar

Thanik Bhongbhibhat bhongy

View GitHub Profile
@bhongy
bhongy / unconditional-stack.js
Created July 12, 2018 03:00
Anti-if Stack Implementation
// idea from: https://www.youtube.com/watch?v=APUCMSPiNh4
class IllegalStateError extends Error {
constructor(...args) {
super(...args);
}
}
class Empty {
size() {
.hide-text {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
/* Scott Kellum Technique - Reference: http://www.zeldman.com/2012/03/01/replacing-the-9999px-hack-new-image-replacement/ */
Use this for SEO/Accessability Friendly
@bhongy
bhongy / create-tls.sh
Last active October 18, 2021 12:35
Creating TLS Certificate
openssl genrsa -out tls.key 4096
openssl req -new -x509 -key tls.key -out tls.cert -days 360 -subj
@bhongy
bhongy / node-fs-write-from-stdin.js
Last active January 4, 2022 12:07
[nodejs] A simple example how to write to a file from stdin using stream.
// from: http://book.mixu.net/node/ch9.html
'use strict';
const fs = require('fs');
const file = fs.createWriteStream('./output.txt');
process.stdin.pipe(file);
// stdin is paused by default
@bhongy
bhongy / Wordpress: Do if the_content is not empty
Last active September 15, 2023 03:36
Wordpress: Check if the_content is empty / do something only when the_content is empty
<?php if ( get_the_content() ) { ?>
// do or output something
<?php } ?> // break php tag for HTML block
@bhongy
bhongy / node-proxy-server.js
Created August 7, 2018 17:33
[nodejs] A simple example how to write a proxy server piping server request to client request / client response back to server response.
// from: http://book.mixu.net/node/ch10.html
'use strict';
const http = require('http');
const url = require('url');
const server = http.createServer((sreq, sres) => {
const { pathname } = url.parse(sreq.url);
const opts = {