Skip to content

Instantly share code, notes, and snippets.

View lastday154's full-sized avatar

Steve Hoang lastday154

  • NIT Warangal, India
View GitHub Profile
@lastday154
lastday154 / command
Last active August 2, 2018 09:58
logstash configuration import to elasticsearch
logstash -f ./logstash.config
- AWS Elasticsearch
hosts => "https://search-faq-staging-nwt2m3iq6falf52dhkxc2ia4me.us-east-2.es.amazonaws.com:443"
@lastday154
lastday154 / shorten.html
Created July 18, 2018 09:38
shorten string
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
function shorten(s) {
const len = s.length;
@lastday154
lastday154 / Import.js
Created July 9, 2018 08:01
loading screen
import React, { Component } from "react";
import axios from "axios";
import Loading from "../components/Loading";
class Import extends Component {
constructor(props) {
super(props);
this.file = null;
'use strict';
const { intentsClient, sessionClient } = require('./config');
const { jsonToCsv, mergeIntents } = require('./dialogflowHelper');
const projectId = process.env.DIALOGFLOW_PROJECT_ID;
const detectIntent = (query, languageCode = 'en-Us') => {
// Define session path
const sessionId = Math.random().toString();
@lastday154
lastday154 / Home.js
Created June 12, 2018 08:38
axios testing react
import Autosuggest from "react-autosuggest";
import React, { Component } from "react";
import "./Home.css";
import SuggestionValue from "./SuggestionValue";
import axios from "axios";
import { find } from "lodash";
import config from "../config";
const renderSuggestion = suggestion => suggestion.q;
@lastday154
lastday154 / download-file.js
Created June 10, 2018 06:40 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@lastday154
lastday154 / SearchBar.js
Created June 8, 2018 06:55
Auto complete search
import React, { Component } from "react";
export default class SearchBar extends Component {
constructor(props) {
super(props);
this.handleQueryChange = this.handleQueryChange.bind(this);
}
handleQueryChange = e => {
this.props.onQueryChange(e.target.value);
@lastday154
lastday154 / Component.jsx
Created June 8, 2018 06:52 — forked from krambertech/Component.jsx
ReactJS: Input fire onChange when user stopped typing (or pressed Enter key)
import React, { Component } from 'react';
import TextField from 'components/base/TextField';
const WAIT_INTERVAL = 1000;
const ENTER_KEY = 13;
export default class TextSearch extends Component {
constructor(props) {
super();
@lastday154
lastday154 / .eslintrc
Last active June 8, 2018 12:31 — forked from elijahmanor/.eslintrc
Add Prettier & ESLint to VS Code with a Create React App
{
"extends": ["react-app", "plugin:prettier/recommended"]
}
@lastday154
lastday154 / csv.js
Created June 6, 2018 02:14
busboy parse multi-part form lambda
'use strict';
const csv = require('csvtojson');
const stringToRow = (csvStr) => new Promise((resolve, reject) => {
csv({
noheader: true,
output: 'csv'
})
.fromString(csvStr)