Skip to content

Instantly share code, notes, and snippets.

@jampajeen
jampajeen / gist:9ce8876ae829efd69aaa
Last active October 27, 2016 21:14
Hibernate non-entity mapping
Query query = session.createSQLQuery(sql);
query.setResultTransformer( Transformers.aliasToBean( Test.class) );
List<Test> result = query.list();
/bin/dd if=/dev/zero of=out.tmp bs=1M count=2048
@jampajeen
jampajeen / jira-behing-nginx-ssl
Created November 15, 2015 18:06 — forked from alertor/jira-behing-nginx-ssl
Atlassian JIRA behind nginx + SSL
# force HTTP to HTTPS - /etc/nginx/conf.d/nonssl.conf
server {
listen 80;
server_name jira.example.com;
access_log off;
return 301 https://$server_name$request_uri;
}
# /etc/nginx/conf.d/jira.conf
server {
@jampajeen
jampajeen / LC_CTYPE.txt
Created November 21, 2015 13:02
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
@jampajeen
jampajeen / InternalAuthTokenGenerator.java
Created February 20, 2016 04:00
Generate oauth token
/*
* Copyright 2016 Thitipong Jampajeen <jampajeen@gmail.com>.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@jampajeen
jampajeen / hikaricp-sqlserver-datasource
Created March 27, 2016 11:37
Create spring datasource for SQL Server & HikariCP
jdbc.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=test
jdbc.username=myuser
jdbc.password=mypass
hikariCP.dataSourceClassName=com.microsoft.sqlserver.jdbc.SQLServerDataSource
@Bean
public DataSource dataSource(@Value("${hikariCP.dataSourceClassName}") String dataSourceClassName,
@Value("${jdbc.url}") String url,
@jampajeen
jampajeen / console-progress.c
Created October 27, 2016 21:10
console progress bar
#include <stdio.h>
#include <cstdlib>
#define PROGRESS_BAR_STR "================================="
#define PROGRESS_BAR_WIDTH sizeof(PROGRESS_BAR_STR)
void print_progress_bar(size_t completed, size_t total) {
const char operation[] = "Downloaded";
const char prefix[] = " kMGT";
@jampajeen
jampajeen / console-app-args.c
Created November 2, 2016 17:51
console app option in C
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define OPT1 "Operation1"
#define OPT2 "Operation2"
struct global_args_t {
const char *program_name;
@jampajeen
jampajeen / console-color.c
Created November 4, 2016 17:18
console text color
#include <stdio.h>
#include <cstdlib>
#define CLEAR "\x1b[2J" // clear
#define RESET "\x1b[0m" // reset color style
#define BLACK "\x1b[30m" /* Black */
#define RED "\x1b[31m" /* Red */
#define GREEN "\x1b[32m" /* Green */
#define YELLOW "\x1b[33m" /* Yellow */
@jampajeen
jampajeen / cron-desc.txt
Created November 16, 2016 12:12
cron description
+---------------- minute (0 - 59)
| +------------- hour (0 - 23)
| | +---------- day of month (1 - 31)
| | | +------- month (1 - 12)
| | | | +---- day of week (0 - 6) (Sunday=0 or 7)
| | | | |
* * * * * command to be executed