Skip to content

Instantly share code, notes, and snippets.

View huytrongnguyen's full-sized avatar

Huy Trong Nguyen huytrongnguyen

View GitHub Profile
@python273
python273 / app.py
Last active November 16, 2024 20:35
Flask Streaming Langchain Example
import os
os.environ["OPENAI_API_KEY"] = ""
from flask import Flask, Response, request
import threading
import queue
from langchain.chat_models import ChatOpenAI
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from langchain.schema import AIMessage, HumanMessage, SystemMessage
@sindresorhus
sindresorhus / esm-package.md
Last active November 17, 2024 22:07
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@hui-zheng
hui-zheng / SQL non-null greatest for multiple columns
Last active February 7, 2024 04:01
[BigQuery Advanced SQL] find greatest/largest/max non-null values among multiple columns
-- Below is a fancy version of non-null-greatest() for multi-columns.
-- it is more extensible for more two columns.
WITH base AS (
SELECT
(SELECT ARRAY_AGG (x IGNORE NULLS) AS Y FROM UNNEST ([col_1, col_2, col_3, col_4]) AS x)
AS array,
FROM source_table AS nl
)
SELECT
(SELECT MAX(y) FROM UNNEST(array) AS Y
@SalahAdDin
SalahAdDin / DockerFile
Created September 17, 2016 23:56
Django + Docker + Postgres + ElasticSearch + Redis recipe
FROM python:3.5.2
RUN apt-get update \
&& apt-get install -y gettext curl sudo \
&& curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - \
&& apt-get install -y nodejs \
&& apt-get install -y libpng-dev libtiff5-dev libjpeg62-turbo-dev zlib1g-dev \
libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk \
libopenjpeg-dev pngquant libmagickwand-dev imagemagick \
&& apt-get autoremove -y --purge \
@tegansnyder
tegansnyder / disable mcafee endpoint protection.md
Last active October 29, 2024 13:49
Disable McAffee Endpoint Protection OSX

method 1

sudo /usr/local/McAfee/AntiMalware/VSControl stopoas

alternatively

sudo defaults write /Library/Preferences/com.mcafee.ssm.antimalware.plist OAS_Enable -bool False
sudo /usr/local/McAfee/AntiMalware/VSControl stop
sudo /usr/local/McAfee/AntiMalware/VSControl reload

Folder Structure

Please note

While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.

Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.

@staltz
staltz / introrx.md
Last active November 19, 2024 09:32
The introduction to Reactive Programming you've been missing
@jfsiii
jfsiii / index.html
Last active January 4, 2021 18:11
Full-Screen Layout using Flexbox
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Holy Grail</title>
<style>
/* some basic styles. nothing to do with flexbox */
header, footer,
nav, article, aside {
border: 1px solid black;
@johnschimmel
johnschimmel / server_simple.js
Created February 7, 2012 12:28
Simple NodeJS web server example
/************************************************
FILENAME
server_simple.js
DESCRIPTION
creates a simple web server that
display "Hello Dynamic World Wide Web"
HOW TO START SERVER:
1) from terminal run 'node simple_server.js'