Skip to content

Instantly share code, notes, and snippets.

View xinnks's full-sized avatar
👨‍💻
Ephesians 2:1-10 😎

James Sinkala xinnks

👨‍💻
Ephesians 2:1-10 😎
View GitHub Profile
@xinnks
xinnks / notices-md.md
Created February 7, 2024 02:56
Markdown syntax for notices

Note

Highlights information that users should take into account, even when skimming.

Tip

Optional information to help a user be more successful.

Important

Crucial information necessary for users to succeed.

[!WARNING]

@xinnks
xinnks / add-external-repo-as-subdirectory-with-history-intact.md
Last active January 17, 2024 19:24
Add external repo to subdirectory of existing repo while keeping history intact

Add external repo to subdirectory of existing repo while keeping history intact

Navigate to the repo folder where you're merging into

cd path-to-destination-repo

Add a remote that points to the repo you're merging in (replace with the actual URL obviously)

@xinnks
xinnks / my-blog-post-formatted-time-component.astro
Created April 18, 2023 20:52
Astro + Turso blog post date formatting component
export interface Props {
date: number;
}
const { date } = Astro.props;
const dateFormat = (datetime: number) => {
const dateTime = new Date(datetime * 1000);
const date = dateTime.toLocaleDateString([], {
@xinnks
xinnks / my-blog-post-turso-db-statements.sql
Last active May 4, 2023 13:51
Astro + Turso blog post turso client and adapter function code
import { createClient } from "@libsql/client/web";
export const client = createClient({
url: import.meta.env.TURSO_DB_URL,
authToken: import.meta.env.TURSO_DB_AUTH_TOKEN
});
@xinnks
xinnks / my-blog-post-turso-db-statements.sql
Created April 18, 2023 20:26
Astro + Turso blog post database preparation sql statements
-- create an authors table
create table authors(
id integer primary key,
first_name varchar(20) not null,
last_name varchar(20) not null,
slug varchar(50) not null,
email text not null,
avatar text,
twitter text,
website text,
@xinnks
xinnks / my-blog-rss-feed-file.xml.ts
Last active May 4, 2023 15:07
Astro + Turso blog src/pages/post/rss.xml.js file source code
import rss from '@astrojs/rss';
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
import { client } from '../lib/tursoDb';
import type { APIContext } from 'astro';
let posts: any[] = [];
try {
const allPostsResponse = await client.execute({
sql: "select posts.title, posts.description, posts.slug, posts.hero, authors.first_name, authors.last_name, authors.slug as author_slug, authors.avatar, posts.content, posts.created_at from posts left join authors on authors.id = posts.author_id order by posts.created_at desc;",
args: [],
@xinnks
xinnks / my-blog-post-slug-file.astro
Last active May 4, 2023 13:46
Astro + Turso blog src/pages/post/[slug].astro file source code
---
import { Markdown } from "@astropub/md"
import BlogPost from '../../layouts/BlogPost.astro';
import { client } from '../../lib/tursoDb';
import type { Blog } from '../../lib/types';
const { slug } = Astro.params;
let post: Blog | null = null;
if(!slug){
@xinnks
xinnks / my-blog-types-file.ts
Last active April 19, 2023 19:37
Astro + Turso blog src/lib/types.ts file source code
export interface Author {
id?: number;
first_name: string;
last_name: string;
bio?: string;
slug: string;
email?: string;
socials?: Socials;
youtube?: string;
avatar: string;
@xinnks
xinnks / my-blog-index-page.astro
Last active May 4, 2023 15:18
Astro + Turso blog src/pages/index.astro page's source code
---
import BaseHead from '../components/BaseHead.astro';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
import type { Blog } from '../lib/types';
import { client } from '../lib/tursoDb';
import FormattedDate from "../components/FormattedDate.astro";
let posts: Blog[] = [];
@xinnks
xinnks / libsql-client-module-error-on-Qwik.md
Created March 1, 2023 21:16
Error experienced when using the @libsql/client within Qwik projects.
(index):103 Uncaught (in promise) TypeError: promisify is not a function
    at node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/lib/methods/backup.js (backup.js:6:18)
    at __require2 (@libsql_client.js?v=282a651a:10:50)
    at node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/lib/database.js (database.js:72:29)
    at __require2 (@libsql_client.js?v=282a651a:10:50)
    at node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/lib/index.js (index.js:2:18)
    at __require2 (@libsql_client.js?v=282a651a:10:50)
    at node_modules/.pnpm/@[email protected]/node_modules/@libsql/client/lib/lib/driver/SqliteDriver.js (SqliteDriver.js:43:40)
    at __require2 (@libsql_client.js?v=282a651a:10:50)