Skip to content

Instantly share code, notes, and snippets.

View kkharji's full-sized avatar
🚀
building spaceships

kkharji

🚀
building spaceships
View GitHub Profile
import { createSolidTable, flexRender, getCoreRowModel, getPaginationRowModel } from "@tanstack/solid-table";
import type { HeaderGroup, Row, RowData, TableOptions, Table as TanTable } from "@tanstack/solid-table";
import { createMemo, For, Match, type Resource, Show, splitProps, Switch } from "solid-js";
import Paging from "./table/paging";
import ArchiveBox from "~/assets/archiveBox.svg";
import lists from "~/lib/lists";
export type TableProps<T = any> = Omit<TableOptions<T>, "data" | "getCoreRowModel"> & {
data: Resource<T[]>
emptyDataMessage?: string
declare var grecaptcha: {
ready: (callback: () => void) => void;
execute: (siteKey: string, opts: { action: "submit" }) => Promise<string>;
};
export type CodeFunction = () => Promise<string>;
export default function(setter: (fn: CodeFunction) => void) {
const siteKey = import.meta.env.VITE_CAPTCHA_SITE_KEY;
import (
"testing"
"github.com/brianvoe/gofakeit/v6"
"github.com/gofiber/fiber/v2"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
"github.com/kkharji/boonize/database"
"github.com/kkharji/boonize/lib/httpserver"
func (d *DNSResolver) handlePacket(pc net.PacketConn, addr net.Addr, payload []byte) error {
var parser dnsm.Parser
log := d.log.Named("handlePacket")
header, err := parser.Start(payload)
if err != nil {
return fmt.Errorf("start parsing payload: %w", err)
}
question, err := parser.Question()
@kkharji
kkharji / errx.go
Created December 12, 2023 10:54
Errx library
// Package to provide advanced error type with the purpose of making errors
// easy to read and trace, construct and pass, wrap and extend and more.
package errx
import (
"errors"
"fmt"
"github.com/gofiber/fiber/v2"
"go.uber.org/zap/zapcore"
pub fn create_query_table<'lua>(
lua: &'lua Lua,
scope: &str,
socket_path: &str,
) -> LuaResult<LuaTable<'lua>> {
let scope_with_dashes = format!("--{scope}");
let query_all = vec!["query".to_owned(), scope_with_dashes.clone()];
let mut scope_singler = scope_with_dashes;
let mut query_single = query_all.clone();
@kkharji
kkharji / home.link.nix
Created January 28, 2022 19:11
Link to base directory instead of store. Usage: home.link.".config/git/template" = "modules/git/template";
use ignore::{types::Types, Walk, WalkBuilder};
fn get_results(home: &String, paths: &mut Vec<String>) -> Vec<String> {
let mut walker = WalkBuilder::new(paths.pop().unwrap());
for root in paths {
walker.add(root);
}
let mut results = vec![];
@kkharji
kkharji / generate_script.nix
Last active January 27, 2022 22:35
Using nix to generate emoji based commit messages.
{ lib, ... }:
let
inherit (builtins) fromJSON readFile;
inherit (lib) mapAttrsToList strings concatStringsSep replaceStrings;
inherit (strings) stringToCharacters head;
# Read definitions to a list of definitions
defs = let
# Path to definitions
source = ../../config/nvim/snippets/gitcommit.json;