Skip to content

Instantly share code, notes, and snippets.

View roychri's full-sized avatar

Christian Roy roychri

View GitHub Profile
@roychri
roychri / README.md
Created May 2, 2024 17:50
Stream Ollama (openai) chat completion API on CLI with HTTPie and jq

Stream Ollama (openai) chat completion API on CLI with HTTPie and jq

Explanation

This command sends a request to the Chat Completion API to generate high-level documentation for the file @src/arch.js. The API is configured to use the llama3-gradient model and to respond in Markdown format.

The messages array contains two elements:

  • The first element is a system message that provides the prompt for the API.
  • The second element is a user message that specifies the file for which to generate documentation.
@roychri
roychri / alpine_date_loop.sh
Created October 26, 2023 19:34
How to loop with unix timestamp modifier in busybox date (alpine)
#!/bin/sh
# Go back 1 hour for 1000 loops to add data to redis.
# Inspired by:
# * https://unix.stackexchange.com/questions/339938/busybox-date-command-set-time-with-unix-timestamp
# * https://unix.stackexchange.com/questions/22600/how-to-get-3-minutes-future-date
# * https://unix.stackexchange.com/questions/494581/date-command-in-busybox-not-accepting-formatted-input-date
for H in $(seq 1 1000); do
@roychri
roychri / package-lock.json
Created October 1, 2021 21:20
Sample Package for hello world
{
"name": "azure-hello-world",
"version": "1.0.0",
"lockfileVersion": 1
}
@roychri
roychri / async_test.js
Created August 21, 2020 14:20
How async function react to Throw
function otherFunctionResolve() {
return Promise.resolve();
}
function otherFunctionReject() {
return Promise.reject();
}
function otherFunctionThrow() {
throw new Error("oops");
@roychri
roychri / bull_arena_bulk_delete.sh
Created July 30, 2020 14:44
Script that delete large amount of bull jobs using arena's API
# Script that delete large amount of bull jobs using arena's API
#
# Requirements:
# * pup (https://github.com/ericchiang/pup)
# * sed
# * tr
# * curl
#
# This was tested with BASH
@roychri
roychri / 01-Dockerfile
Created April 7, 2018 12:17
Output of Dockerfile build and run
FROM node:9.9.0-alpine
ARG tag=latest
LABEL image=jaumard/test:${tag} \
maintainer="Jaumard" \
base=node:9.9.0-alpine
RUN set -ex
@roychri
roychri / README.md
Created February 13, 2018 03:34
Promise based repeater that wont start the loop unless the callback completed

This is an implementation similar to setInternal() but will not start the delay/loop again until the callback has finished (presuming it returned a promise). Im interested to know if there's a better way to do this. I choose this rather than using setInterval() because I wanted to make sure it would not start over if the callback took longer than the interval time.

The callback function will only be called once an initial delay has passed. It would be simple to add a call to cb() before calling the loop.

Let me know what you think!

@roychri
roychri / README.md
Last active December 2, 2016 03:51
Temporary after_destroy rails3 callback using Observers

WARNING

Heavy metaprogramming ahead...

Summary

This is an attempt/experiment at being able to temporarily observe an active record through callbacks.

To Do

+------------+-------------+------------+-------------+------------+
| date | video_views | clip_views | video_plays | clip_plays |
+------------+-------------+------------+-------------+------------+
| 2016-09-21 | 9166 | 2237 | 2342 | 1622 |
| 2016-09-22 | 63967 | 20235 | 23900 | 15616 |
| 2016-09-23 | 184224 | 69347 | 103441 | 51579 |
| 2016-09-24 | 62307 | 17288 | 25074 | 12300 |
| 2016-09-25 | 27367 | 7250 | 6499 | 5060 |
| 2016-09-26 | 51912 | 13901 | 12038 | 10471 |
| 2016-09-27 | 61551 | 19965 | 18761 | 15030 |
# While on master which is up to date.
git checkout -b feature9
# <work>, <commit>, <work>, <commit>, ...
git fetch origin/master
git rebase master
git checkout master
git pull
git rebase feature9
# Oopps, I wanted to do -i
git reglog