Skip to content

Instantly share code, notes, and snippets.

View ronsc's full-sized avatar

Ronnakorn Jannnalao ronsc

View GitHub Profile
@ronsc
ronsc / card-reader.service.ts
Created May 20, 2024 18:35
Angular Electron - Read Thai ID Card
import { Injectable } from "@angular/core";
import { ElectronService } from "ngx-electron";
@Injectable()
export class CardReaderService {
constructor(private electron: ElectronService) {}
getData() {
return new Promise((resolve, reject) => {
if (!this.electron.isElectronApp) {
@ronsc
ronsc / decimal-only.directive.ts
Created May 23, 2017 16:48
Angular Custom Directive
import { Directive, HostListener, ElementRef } from '@angular/core';
import { DecimalPipe } from '@angular/common';
@Directive({
selector: 'input[type="text"][decimalOnly]'
})
export class DecimalOnlyDirective {
private decimalRegEx = /^\d+\.?(\d{1,2})?$/;
private allowedKeys: Array<string> = [
'Enter', 'Backspace', 'Tab', 'Delete',
@ronsc
ronsc / nginx.conf
Created December 14, 2016 08:32 — forked from cpswan/nginx.conf
Using nginx to proxy to an AWS ELB
daemon off;
worker_processes 1;
events { worker_connections 1024; }
http{
sendfile on;
@ronsc
ronsc / is_installed.sh
Created July 20, 2016 12:12 — forked from JamieMason/is_installed.sh
Check if a program exists from a bash script. Thanks to twitter.com/joshnesbitt and twitter.com/mheap for the help with detecting npm packages.
#!/bin/bash
# Functions ==============================================
# return 1 if global command line program installed, else 0
# example
# echo "node: $(program_is_installed node)"
function program_is_installed {
# set to 1 initially
local return_=1
@ronsc
ronsc / Main.java
Created May 12, 2016 17:43
ArrayList Algorithm
import java.util.*;
class Main {
public static void main(String args[]) {
int arr[] = new int[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14};
fn1(arr, 4);
fn2(arr, 4);
}
{
"presets": ["react", "es2015"]
}
@ronsc
ronsc / java-regex.java
Created October 7, 2015 10:36
ศึกษาการใช้งาน Matcher & Pattern ภาษา Java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Map;
import java.util.HashMap;
public class RegexMatches {
public static void main(String args[]) {
Map<String, String> mapData = new HashMap<String, String>();
mapData.put("NAME", "Ronnakorn");
@ronsc
ronsc / action.java
Created August 28, 2015 07:44
Upload File Ajax FormData with Struts2
public void saveUpload() {
try {
MultiPartRequestWrapper multiWrapper = (MultiPartRequestWrapper) ServletActionContext.getRequest();
String[] fileName = multiWrapper.getFileNames("file");
for(String s : fileName) {
System.out.println(s);
}
// Get a Files[] object for the uploaded File
var test1 = [
{
"id" : 1,
"name" : "test1"
},
{
"id" : 2,
"name" : "test2"
},
{
@ronsc
ronsc / application.properties
Last active August 29, 2015 14:09
Spring Boot : config : application.properties
spring.datasource.driverClassName = com.mysql.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost/ชื่อฐานข้อมูล
spring.datasource.username = root
spring.datasource.password = รหัสผ่าน
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto = create-drop