Skip to content

Instantly share code, notes, and snippets.

View thangman22's full-sized avatar

Warat Wongmaneekit thangman22

View GitHub Profile
@thangman22
thangman22 / curl.php
Created June 11, 2014 07:41
curl-snipet
$url = 'http://www.website.com/file.json';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, '{}');
$response = curl_exec($curl);
$resultStatus = curl_getinfo($curl);
<?php
function _getPlayerFromElastic($field, $keywords) {
$returnItem = array();
$keywordImplode = implode(" OR ", $keywords);
$query = '{"query":{"bool":{"must":[{"query_string":{"default_field":"' . $field . '","query":"' . $keywordImplode . '"}}],"must_not":[],"should":[]}},"from":0,"size":10,"sort":[],"facets":{}}';
$url = 'http://162.222.178.137:9200/message/_search';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $query);
$response = curl_exec($curl);
@thangman22
thangman22 / cron_functions.php
Last active August 29, 2015 14:03
Insert to Elastic
function insert_to_es($collection, $type, $id, $data, $ip = "localhost")
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://' . $ip . ':9200/' . $collection . '/' . $type . '/' . $id);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
@thangman22
thangman22 / elastic_functions.php
Created September 19, 2014 06:59
elasticsearch_function
function insert_to_es($collection, $type, $id, $data, $ip = "localhost")
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://' . $ip . ':9200/' . $collection . '/' . $type . '/' . $id);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
@thangman22
thangman22 / designer.html
Created November 4, 2014 04:36
designer
<link rel="import" href="../topeka-elements/category-images.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icons/av-icons.html">
<link rel="import" href="../paper-fab/paper-fab.html">
<polymer-element name="my-element">
<template>
<style>
<script type="text/javascript">
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('sw.js');
}
</script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
importScripts('node_modules/sw-toolbox/sw-toolbox.js');
self.addEventListener('install', (event) => {
self.skipWaiting();
});
self.addEventListener('activate', (event) => {
event.waitUntil(self.clients.claim());
});
function onBuyClicked() {
var supportedInstruments = [{
supportedMethods: ['amex', 'diners', 'discover', 'jcb', 'mastercard',
'unionpay', 'visa']
}];
var details = {
total: {label: 'Donation', amount: {currency: 'USD', value: '55.00'}},
displayItems: [
{
function onBuy() {
// Define supported credit card
var supportedInstruments = [{
supportedMethods: ['amex', 'diners', 'discover', 'jcb', 'mastercard',
'unionpay', 'visa']
}];
//Order detail
var details = {
total: {label: 'Product', amount: {currency: 'THB', value: '10.00'}},
displayItems: [