Skip to content

Instantly share code, notes, and snippets.

View herudi's full-sized avatar
💭
I may be slow to respond.

herudi herudi

💭
I may be slow to respond.
  • Enigma
  • Majalengka - Indonesia
View GitHub Profile
@herudi
herudi / tinex.js
Last active January 13, 2021 07:14
Native nodejs http server like express
const http = require('http');
const pathnode = require('path');
const { parse: parseqs } = require('querystring');
const { parse: parsenodeurl } = require('url');
const METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS', 'ALL'];
const PRE_METHOD = 'GET,POST';
const PUSH = Array.prototype.push;
const TYPE = 'Content-Type';
const JSON_TYPE = 'application/json';
@herudi
herudi / button-more-type-antd.less
Last active July 9, 2022 00:38
Simple Button more type Ant Design. success, info, warning (LESS). for css version => https://gist.github.com/herudi/4c608737ae0816c45ba0c3b185556acf
@success-color: #28a745;
@warning-color: #eca52b;
@info-color: #17a2b8;
@buttons: success @success-color, warning @warning-color, info @info-color;
.getButtons(@index:1) when(@index <= length(@buttons)) {
@name: extract(extract(@buttons, @index),1);
@color: extract(extract(@buttons, @index),2);
@colorHoverFocus: lighten(@color, 10%);
@colorActive: darken(@color, 10%);
.ant-btn-@{name}{
@herudi
herudi / button-more-type-antd.css
Last active April 28, 2024 16:56
Simple Button more type Ant Design. success, info, warning (CSS). for less version => https://gist.github.com/herudi/143f5d6ee12129251ae661d4f1f73f47
.ant-btn-success {
color: #fff !important;
background-color: #28a745 !important;
border-color: #28a745 !important;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.12);
-webkit-box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);
box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);
}
.ant-btn-success-disabled,
.ant-btn-success.disabled,
@herudi
herudi / router.js
Last active February 26, 2019 00:09
var express = require('express');
var router = express.Router();
var person = require('./../controller/person');
router.get('/person', person.all);
router.post('/person', person.create);
router.get('/person/:person_id', person.byId);
router.get('/person/search/:name', person.search);
router.put('/person/:person_id', person.update);
router.delete('/person/:person_id', person.delete);
@herudi
herudi / person.js
Last active February 26, 2019 00:07
var db_connect = require('./../common/connection');
var person = {};
//get all person
person.all = async function (req, res) {
try {
var query = `select * from person`;
var persons = await db_connect.query(query);
res.send(persons);
var mysql = require('mysql');
var util = require('util');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '',
database : 'expressmysql',
dateStrings: 'date'
});
CREATE DATABASE IF NOT EXISTS `expressmysql`;
CREATE TABLE `person` (
`person_id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NULL DEFAULT NULL,
`address` VARCHAR(50) NULL DEFAULT NULL,
`phone` VARCHAR(15) NULL DEFAULT NULL,
`created_at` TIMESTAMP NULL DEFAULT NULL,
`updated_at` TIMESTAMP NULL DEFAULT NULL,
PRIMARY KEY (`person_id`))
var express = require('express');
var router = require('./routes/router');
var app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use('/', router);
app.listen(3000, function(){
console.log('port 3000')
});