Skip to content

Instantly share code, notes, and snippets.

View peerax's full-sized avatar

peerathai puapan peerax

View GitHub Profile
@peerax
peerax / AprConfiguration.java
Created December 8, 2017 23:34 — forked from andreldm/AprConfiguration.java
APR on Spring Boot
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.core.AprLifecycleListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* NOTE: You also need to install APR on your system, on Arch Linux the package is called `tomcat-native`.
@peerax
peerax / index.html
Last active July 7, 2022 08:50
fill color area map
<meta charset="utf-8">
<body onload='myInit()'>
<canvas id='myCanvas'></canvas>
<map name="Map" id="Map">
<area shape="rect" onmouseover='myHover(this);' onmouseout='myLeave();' coords="50,50,70,80" href="#" alt="circle" />
</map>
<img id="img" src="index.jpeg" width="100%" usemap="#Map" />
<script>
@peerax
peerax / Yii_Ar_to_json.php
Created February 20, 2017 09:16
Yii Active record to json
$models=Bla::model()->findAll();
$data=array_map(create_function('$m','return $m->getAttributes(array(\'id\',\'name\'));'),$models);
echo json_encode($data);
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
if application.respondsToSelector("registerUserNotificationSettings:") {
let types:UIUserNotificationType = (.Alert | .Badge | .Sound)
let settings:UIUserNotificationSettings = UIUserNotificationSettings(forTypes: types, categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()
@peerax
peerax / kmtoday.js
Created April 27, 2015 08:34
request today in js
// Today.init(); เรียกวันนี้
// Today.prevDate(2); เรียกอีกสองวันข้างหน้า
var Today = function(){
return{
init: function () {
var today = new Date();
return getDBformat(today);
},
@peerax
peerax / index.html
Created April 4, 2015 09:27
nodejs+express+ejs .html
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<% include ../partials/head %>
<title></title>
</head>
<body>
<%= title.date %>
</body>
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="httpreq.js"></script>
<script>
function chkTxt(){
var str = $("#txt").val();
var b = str.replace(/[^a-z0-9_-]/gi,'');
$("#txt").val(b);
<html>
<head>
<script type="text/javascript">
function validateMyForm()
{
if(1 == 6)
{
alert("validation failed false");
returnToPreviousPage();
return false;
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'http://testcURL.com/?item1=value&item2=value2',
CURLOPT_USERAGENT => 'Codular Sample cURL Request'
));
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
class ViewController: UIViewController,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 2
}