Skip to content

Instantly share code, notes, and snippets.

View nafeu's full-sized avatar
🕶️
In Virtual Reality

Nafeu Nasir nafeu

🕶️
In Virtual Reality
View GitHub Profile
@nafeu
nafeu / setup-ollama-minimal-elearning.memd
Last active January 24, 2024 18:27
Presentation on running setting up Ollama - nafeu.com/minimal-elearning
---
title: "Setting up a local LLM with Ollama"
author: "Nafeu Nasir"
description: "Getting up and running with Ollama and integrating it into your workflow."
date: 2024-01-24
---
# What is a local large language model? (LLM)
You've heard of LLMs, you've heard of ChatGPT, or Bard or Grok. Well a local LLM is one you can run on your computer. This means that you don't need to rely on a cloud service to use them (better data privacy and security).
@nafeu
nafeu / jsonbin-html-js-functions.js
Last active October 17, 2024 20:55
Simple Template for JSONBIN in HTML Page
const JSONBIN_BIN_ID = '...';
const JSONBIN_URL = `https://api.jsonbin.io/v3/b/${JSONBIN_BIN_ID}`;
const JSONBIN_MASTER_KEY = '...';
const JSONBIN_ACCESS_KEY = '...';
function fetchData({ onSuccess, onFail }) {
const url = JSONBIN_URL;
const headers = new Headers();
headers.append('X-Master-Key', JSONBIN_MASTER_KEY);
@nafeu
nafeu / timezone-message.js
Last active October 27, 2022 17:53
Timezone Message Script
/*
Usage:
1. Make sure you have node installed on your machine (https://github.com/Schniz/fnm)
2. Run `npm install --global moment-timezone`
3. Replace ROOT_TIMEZONE with your local timezone
ie. const ROOT_TIMEZONE = 'America/Toronto'
4. Use `node timezone-message.js [MESSAGE] [TIME] [AM/PM]`
ie. `node timezone-message.js 'next pomodoro starting at:' 3:00 PM`
{headerGroups.map(headerGroup => (
<tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map(column => (
<th {...column.getHeaderProps(column.getSortByToggleProps())}>
{column.render('Header')}
<span>
{column.isSorted
? column.isSortedDesc
? ' ⬇️'
: ' ⬆️'
const TableLayout = ({
getTableProps,
getTableBodyProps,
headerGroups,
rows,
prepareRow,
state: { globalFilter },
visibleColumns,
preGlobalFilteredRows,
setGlobalFilter
const TWO_HUNDRED_MS = 200;
function GlobalFilter({
preGlobalFilteredRows,
globalFilter,
setGlobalFilter,
}) {
const [value, setValue] = useState(globalFilter);
const onChange = useAsyncDebounce(value => {
setGlobalFilter(value || undefined)
{
Header: () => null,
id: 'expander',
Cell: ({ row, isLoading, isExpanded }) => {
const toggleRowExpandedProps = row.getToggleRowExpandedProps();
const onClick = async event => {
if (!isLoading) {
if (!isExpanded) {
await onClickRow(row);
const [isRowLoading, setIsRowLoading] = useState({});
const handleClickRow = async ({ id }) => {
setIsRowLoading({ [id]: true });
const { data: childData } = await fetchChildData();
setIsRowLoading({ [id]: false })
if (tableData) {
return existingRows.map((row, index) => {
const isMatchedRowWithSubRows = index === Number(id) && row.subRows;
if (isMatchedRowWithSubRows) {
const [, ...updatedPath] = path;
return {
...row,
subRows: insertIntoTable({
existingRows: row.subRows,
const isBaseCase = path.length === 1;
if (isBaseCase) {
return existingRows.map((row, index) => {
const isMatchedRowWithoutSubRows = index === Number(id) && !row.subRows;
if (isMatchedRowWithoutSubRows) {
return {
...row,
subRows: subRowsToInsert