Skip to content

Instantly share code, notes, and snippets.

View HariantoAtWork's full-sized avatar

Harianto van Insulinde HariantoAtWork

View GitHub Profile

Input field validation without javascript

input field with RegExp pattern validation and LESS styling. Using extra sibling div element with Font Awesome font to indicate if an input field is validated. Using extra sibling div element for error messages. No background image has been used. No Javascript

On Example 2, there is no parent-parent selector, which is not possible to select other errormsg elements

A Pen by Harianto van Insulinde on CodePen.

Input fields validation w/out JavaScript

Input field with RegExp pattern validation and LESS styling. Using extra sibling div element with Font Awesome font to indicate if an input field is validated. No background image has been used.

A Pen by Harianto van Insulinde on CodePen.

License.

@HariantoAtWork
HariantoAtWork / check.sh
Last active October 10, 2022 10:58 — forked from jusopi/check.sh
Set node version per project using .nvmrc file
#!/bin/sh
enter_directory(){
if [ "$PWD" != "$PREV_PWD" ]; then
PREV_PWD="$PWD";
if [ -e ".nvmrc" ]; then
nvm use;
fi
fi
}
@HariantoAtWork
HariantoAtWork / index.js
Last active July 12, 2016 08:11
Run your node app as different user:group as www-data. Suitable when you use daemon (init.d/myghostapp)
if(process.env.NODE_ENV === 'production') {
try {
console.log('Old User ID: ' + process.getuid() + ', Old Group ID: ' + process.getgid());
process.setgroups(['www-data']);
process.setgid('www-data');
process.setuid('www-data');
console.log('New User ID: ' + process.getuid() + ', New Group ID: ' + process.getgid());
} catch (err) {
console.log('Cowardly refusing to keep the process alive as root. Please run as: www-data:www-data');
@HariantoAtWork
HariantoAtWork / Dockerfile
Created July 18, 2016 17:57
Dockerfile - Alpine (latest) - MySQL (latest)
FROM alpine
MAINTAINER Harianto van Insulinde<hariantoatwork@gmail.com>
EXPOSE 3306
RUN apk add --update mysql && \
mkdir -p /var/lib/mysql && \
mkdir -p /etc/mysql/conf.d && \
{ \
@HariantoAtWork
HariantoAtWork / Dockerfile
Last active July 18, 2016 19:24
Docker Alpine Node:4 NPM:3.7.5
FROM mhart/alpine-node:4
RUN apk update && apk upgrade
RUN apk add bash
RUN addgroup node &&\
adduser -h /home/node -s /bin/false -G node -D node &&\
npm install --global npm@3.7.5
ENV HOME=/home/node
@HariantoAtWork
HariantoAtWork / Makefile
Created July 19, 2016 11:15
Easier building and testing Docker files
DOCKER_REPO = phpmyadmin/phpmyadmin
.PHONY: all build build_nc run logs clean stop rm prune
all: build run logs
build:
docker build -t ${DOCKER_REPO}:testing .
build_nc:
@HariantoAtWork
HariantoAtWork / mixins.less
Created July 28, 2016 20:51
Flex Box Less Mixins
/* mixins */
.flex() {
display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */
display: -ms-flexbox; /* TWEENER - IE 10 */
display: -webkit-flex; /* NEW - Chrome */
display: flex; /* NEW, Spec - Opera 12.1, Firefox 20+ */
}
.flex--column() {
@HariantoAtWork
HariantoAtWork / LokiSaveReload.js
Created August 4, 2016 22:20 — forked from techfort/LokiSaveReload.js
LokiJS - save to disk and reload
var loki = require('lokijs'),
db = new loki('test.json'),
db2 = new loki('test.json');
var users = db.addCollection('users');
users.insert({
name: 'joe'
});
users.insert({
name: 'john'
@HariantoAtWork
HariantoAtWork / memory.js
Created August 5, 2016 19:35
Memory Manager with LokiJS
// Memory Manager use of LokiJS
var loki = require('lokijs');
var db = new loki('memory');
// converts
var toBase64 = function(string) { return new Buffer(string).toString('base64') };
var toString = function(base64) { return new Buffer(base64, 'base64').toString('utf8') };
// database collection: memory