Skip to content

Instantly share code, notes, and snippets.

View georgeck's full-sized avatar
🏠
Working from home

George Chiramattel georgeck

🏠
Working from home
View GitHub Profile
@georgeck
georgeck / open-api-sse-streaming.js
Created March 13, 2023 16:36
Invoking OpenAPI ChatGPT Chat completions model (gpt-3.5-turbo) with SSE streaming
// Uses the eventsource-parser library to parse the stream from OpenAI's chat completion API
// Make sure to set the OPENAI_API_KEY environment variable to your OpenAI API key
import {createParser} from 'eventsource-parser'
function generatePrompt(prompt) {
return [
{"role": "system", "content": "The following is a conversation with an AI assistant. The assistant is helpful, creative, clever, and very friendly."},
{"role": "user", "content": "Hello, who are you?"},
{"role": "system", "content": `I am an AI created by OpenAI. How can I help you today?`},
@georgeck
georgeck / promise.js
Created July 6, 2019 02:28
Javascript promise example
// Creating a promise
let promise = new Promise (
(resolve, reject) => {
// Some function that takes time - in this case, retuen afer 1 sec
setTimeout( () => {
if ( Math.random() > .5) {
resolve('😀');
} else {
reject('😡');
}
@georgeck
georgeck / Ubuntu.md
Last active December 17, 2018 03:53
Ubuntu.md

conjure-up

conjure-up -> Lists the available "spell" conjure-up lets you summon up a big-software stack as a "spell"

snap

A universal app store for Linux

  • snap list
  • sudo snap install hello
  • sudo snap refresh hello
  • udo snap remove hello
@georgeck
georgeck / DateTime.md
Last active October 18, 2018 17:53
Notes on Java DateTime

Java Data Time

In modern Java (after Java 8), we use the pacakage java.time.* to represent DataTime. This is much better than the java.util classes. For interoperability, we have methods in the java.util.* package, that can convert from the older java.util.Date to the newer types.

Instant

An instantaneous point on the time-line (with a precision of nano seconds). It models a single instantaneous point on the time-line. This might be used to record event time-stamps in the application. The epoch-seconds are measured from the standard Java epoch of 1970-01-01T00:00:00Z where instants after the epoch have positive values, and earlier instants have negative values.

Duration

This models a quantity or amount of time in terms of seconds and nanoseconds. It can be accessed using other duration-based units, such as minutes and hours. In addition, the DAYS unit can be used and is treated as exactly equal to 24 hours, thus ignoring daylight savings effects. Durations can also be negative.

apiVersion: v1
kind: ReplicationController
metadata:
name: hello-rc
spec:
replicas: 10
selector:
app: hello-world
template:
metadata:
apiVersion: v1
kind: Pod
metadata:
name: hello-pod
spec:
containers:
- name: hello-ctr
image: nigelpoulton/pluralsight-docker-ci:latest
ports:
- containerPort: 8080
@georgeck
georgeck / git-cheat-list.md
Created February 18, 2017 19:24
Git cheat list

Git cheat list

  • name of the current banch and nothing else (for automation)

    git rev-parse --abbrev-ref HEAD
    
  • all commits that your branch have that are not yet in master

    git log master..<HERE_COMES_YOUR_BRANCH_NAME>
    
@georgeck
georgeck / .gitconfig
Last active March 10, 2017 18:30
Defaults for Git Config
[core]
editor = 'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
dc = diff --cached
lg = log -p
@georgeck
georgeck / .gitattributes
Created October 29, 2012 06:07
.gitignore file for Visual studio project
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain