Skip to content

Instantly share code, notes, and snippets.

View kobkrit's full-sized avatar

Kobkrit Viriyayudhakorn kobkrit

View GitHub Profile
@kobkrit
kobkrit / app.js
Created November 21, 2012 15:34
LINE 非公式 API を使ってログイン
var LINE = require('./line.js');
var line = new LINE();
var email = 'your email';
var password = 'your password';
line.login(email, password, function(error, result) {
if (error) {
return;
}
var thermal_printer = require(“node-thermal-printer”);
var printer = require(“printer”);
// console.log(printer.getPrinters())
var star = printer.getPrinter(‘Star_TUP992__STR_T_U001_‘);
thermal_printer.init({
type:‘star’
})
thermal_printer.println(“Hello World”);
//https://docs.expo.io/versions/latest/sdk/imagepicker.html
import React from 'react';
import { TouchableOpacity, Image, View, StyleSheet, Text, Modal, Slider } from 'react-native';
import { ImagePicker } from 'expo';
export default class App extends React.Component {
constructor(props){
super(props);
this.state = {
@kobkrit
kobkrit / chat_starter_lecture12.js
Created November 15, 2017 16:10
Starter of Chat App For Lecture 12
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, {Component} from 'react';
import moment from 'moment';
import {
AppRegistry,
firebase.auth().signInWithCredential(credential)
.then((user) => {
console.log('facebook auth:', user);
this.setState({name: user.email, modalVisible: false});
})
.catch((error) => {
// Handle Errors here.
this.setState({name: 'Anonymous', modalVisible: true});
alert("An error occured: " + error.message);
});
@kobkrit
kobkrit / bitcoin-hourly.js
Created February 5, 2018 12:55
Bitcoin Statistic in Hourly extraction
var moment = require('moment');
var histohour = require('./histohour.json');
var stats = require("stats-lite")
var d = histohour.Data;
let h = {};
for (let i=0;i<d.length;i++){
let date = moment(d[i].time*1000);
console.log(date);
let hour = date.hours();
let diff = d[i].close - d[i].open;
var Iconv = require('iconv').Iconv;
var conv = new Iconv('windows-874', 'utf8');
var rq = require('request');
rq({
url: someurl
encoding: 'binary'
}, function (error, resp, body) {
body = new Buffer(body, 'binary');
body = conv.convert(body).toString();
@kobkrit
kobkrit / api.js
Created April 6, 2018 08:38
Api for OMDB
let rootURL = 'https://www.omdbapi.com/';
exports.search = function(q){
let url = `${rootURL}?apikey=3f1288a7&s=${q}`;
console.log(url);
return fetch(url)
.then((resp)=>resp.json())
.then((json)=>{
return json.Search;
});
FROM node:9
MAINTAINER Kobkrit
LABEL "version"="1.0.0"
RUN npm install -g ionic cordova
RUN mkdir -p /var/www/app
WORKDIR /var/www/app
// See https://github.com/dialogflow/dialogflow-fulfillment-nodejs
// for Dialogflow fulfillment library docs, samples, and to report issues
'use strict';
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements