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 January 21, 2024 02:13
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 / python3-script-template.py
Created January 29, 2019 12:34
Python3 Terminal Script Template
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Template for python3 terminal scripts.
This gist allows you to quickly create a functioning
python3 terminal script using argparse and subprocess.
"""
import argparse
@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`
const TableQuery = () => {
const queryClient = useQueryClient();
const [tableData, setTableData] = useState(null);
const { data: apiResponse, isLoading } = useQuery('discussionGroups', fetchData);
useEffect(() => {
setTableData(apiResponse?.data);
}, [apiResponse])
{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) {