Skip to content

Instantly share code, notes, and snippets.

View komkanit's full-sized avatar
🍔
code for food

komkanit komkanit

🍔
code for food
View GitHub Profile
/*
TinyMCE
1. Create a JavaScript file that defines your plugin's functionality. This file should contain a single function that takes a TinyMCE editor instance as an argument and registers your plugin's behavior with the editor.
2. In your TinyMCE configuration, include the path to your plugin's JavaScript file in the plugins array.
*/
tinymce.PluginManager.add('myplugin', function(editor, url) {
editor.addButton('mybutton', {
text: 'My Button',
icon: false,
onclick: function() {
@komkanit
komkanit / machine.js
Last active July 9, 2020 07:26
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
export async function getStaticPaths() {
// ตรงนี้สามารถ List Content ทั้งหมดผ่าน API ได้
// และใส่เป็น params
return {
paths: [
{
params: {
title: 'some-content-title',
},
},
-----------------------------
2c.รายได้ทุกปีแต่ละจังหวัด
-----------------------------
Bangkok
median: 5
mean: 37416.7
mode: 26054
sd: 8509.53
per 90: 48951
per 95: 49071
import { HttpLink } from 'apollo-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { onError } from 'apollo-link-error'; //add apollo error link
import { ApolloLink } from 'apollo-link'; // add apollo link
const httpLink = new HttpLink({
uri: 'http://localhost:8080/graphql',
});
const errorLink = onError(({ graphQLErrors, networkError }) => {
@komkanit
komkanit / remove-avenger-spoiler.js
Last active April 24, 2019 05:09
REMOVE AVENGER SPOILER. copy this code and paste in console on your browser
var banList = ['avenger', 'infinity'];
setInterval(function() {
var a = document.querySelectorAll('[role="article"]')
a.forEach((d) => {
banList.map((text) => {
if (d.innerText.toLocaleLowerCase().indexOf(text) >= 0) {
console.log('removed');
d.remove()
}
})
// read.js
const data = requre('./entity')
data()
.then((list) => {
console.log(list)
})
--------------------------
// entity.js
<?php
$SITE_ROOT = "https://www.example.com";
$jsonData = getData($SITE_ROOT);
makePage($jsonData, $SITE_ROOT);
function getData($siteRoot) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
import ApolloClient from 'apollo-client';
import { getOperationAST } from 'graphql';
import { ApolloLink } from 'apollo-link';
import { HttpLink } from 'apollo-link-http';
import { WebSocketLink } from 'apollo-link-ws';
import { InMemoryCache } from 'apollo-cache-inmemory';
import fetch from 'isomorphic-fetch';
import WebSocket from 'ws';
let apolloClient = null;