Skip to content

Instantly share code, notes, and snippets.

View jlei523's full-sized avatar

jlei523

  • San Francisco
View GitHub Profile
Crypto/ICO Silicon Valley
What's used to raise money White paper with a lot of promises that sound good on... paper... An MVP already built through sweat equity and proven user adoption.
@jlei523
jlei523 / data.json
Last active February 27, 2019 11:45
[
{
"buildingaddress": "8 LEUNG TAK STREET",
"Name": "EIGHT REGENCY (Tuen Mun)",
"type": "building"
},
{
"buildingaddress": "8 LEUNG TAK STREET",
"Name": "31/F FLAT N - NA EIGHT REGENCY (Tuen Mun)",
"type": "unit"
@jlei523
jlei523 / Search.js
Last active November 17, 2019 05:13
import React from "react";
import Autosuggest from "react-autosuggest";
import "../../style.css";
import BuildingsSVG from "../../static/buildings.svg";
import UnitsSVG from "../../static/units.svg";
import match from "autosuggest-highlight/match";
import parse from "autosuggest-highlight/parse";
import axios from "axios";
import slugify from "slugify";
import Router from "next/router";
server.get("/autocomplete/:searchString", async (req, res) => {
let cloudSearchEndpoint = 'your endpoint here'
let data = await axios.get(
` ${endpoint}/2013-01-01/search?q=~${
req.params.searchString
}&return=_all_fields%2C_score&highlight.label=%7B%22max_phrases%22%3A3%2C%22format%22%3A%22text%22%2C%22pre_tag%22%3A%22*%23*%22%2C%22post_tag%22%3A%22*%25*%22%7D&highlight.unitcode=%7B%22max_phrases%22%3A3%2C%22format%22%3A%22text%22%2C%22pre_tag%22%3A%22*%23*%22%2C%22post_tag%22%3A%22*%25*%22%7D&sort=_score+desc`
);
res.send(JSON.stringify(data));
select * from posts where url = '/post/i-love-nextjs'
function createPageContext() {
return {
theme,
sheetsManager: new Map(),
sheetsRegistry: new SheetsRegistry(),
//add this to fix broken css in prod
generateClassName: createGenerateClassName({
productionPrefix: "prod"
@jlei523
jlei523 / url.js
Last active February 25, 2019 09:36
server.get('/post/:slug', async (req, res) => {
const actualPage = "/post";
//get the data using '/post/i-love-nextjs' as the id
let data = await fetchDataWithURL(req.params.slug)
const postContent = { data: data };
app.render(req, res, actualPage, postContent);
});
@jlei523
jlei523 / data.csv
Last active February 22, 2019 17:04
id title content url
245 i love next.js because... /post/i-love-nextjs
class App extends React.Component {
static async getInitialProps({ req, query, asPath, pathname }) {
let baseUrl = req ? `${req.protocol}://${req.get("Host")}` : "";
let data = await fetch(baseUrl + 'relativeURL')
return {
data: data