Skip to content

Instantly share code, notes, and snippets.

View ansarizafar's full-sized avatar

Zafar Ansari ansarizafar

View GitHub Profile
@ansarizafar
ansarizafar / README.md
Created January 7, 2023 05:24 — forked from yogthos/README.md
command line util for grabbing current weather for a city using OpenWeather API

usage

Create an account at https://openweathermap.org and get an API key. Note that it can take up to a couple of hours for the key to become active. Add an environment variable OPEN_WEATHER_API_KEY with the value of the key.

run the script:

./weather.clj Toronto,CA
@ansarizafar
ansarizafar / deploy.md
Created October 2, 2022 14:51 — forked from intabulas/deploy.md
Deploying SurrealDB to Fly.io

These are the rough steps for getting a surrealdb instance running on fly.io and connecting to it. This is heavily based off of steps posted in the surrealdb discord by rvdende. View Origional Post.

These steps work just fine for the hobby (pay as you go) plan.

HEADS UP By default this will create an instance on a single shared cpu with 256m memory. This is pretty darn small to do anything but experiment, but its free. You can scale your instance to something more useable by visiting the https://fly.io/apps/<appname>/scale. Obviously scaling to larger instances will incur higher costs, please refer to fly.io pricing

Installing fly.io client

source: fly.io docs

import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => {
return c.html('Hello Bun!')
})
export default {
port: 3000,
@ansarizafar
ansarizafar / linear_regression.sql
Created March 16, 2022 11:12 — forked from patrickpissurno/linear_regression.sql
Simple linear regression and prediction in PL/pgSQL (PostgreSQL)
-- This code is based on my other Gist "Simple linear regression in Javascript" (https://gist.github.com/patrickpissurno/ea0dc4039f075fbaf398619761bd9044)
-- There might be a more efficient way to do this in SQL
-- This function is resposible for computing the weights for the ax + b equation
CREATE OR REPLACE FUNCTION linear_regression(x_array decimal(15,2)[], y_array decimal(15,2)[]) RETURNS decimal(15,2)[] AS $$
DECLARE
slope decimal(15,2);
intercept decimal(15,2);
n integer;
import { create, Header, Payload } from "https://deno.land/x/djwt@v2.4/mod.ts";
// License: MIT
// How to get an access token from Google Cloud using Deno
//
// Usage:
// const token = await getAccessToken(config)
type Config = {
privateKey: string; // Private base64 encoded RSA key, starts with -----BEGIN PRIVATE KEY-----
@ansarizafar
ansarizafar / README.md
Created January 13, 2022 05:33 — forked from josephg/README.md
Getting Zig compiling to WASM

In case anyone else wants to play with Zig on webassembly, here's what you need to do to make it work on a mac today.

1. Get LLVM 7 compiled with webassembly support.

You'll need LLVM to output to the WASM target. This has just been added by default in trunk, so if LLVM >7 is available, you might be able to just brew install llvm.

If you have wasm support already you should see:

$ llc --version
SQL Server 2017
----------------
Enterprise Core - 6GPYM-VHN83-PHDM2-Q9T2R-KBV83
Developer - 22222-00000-00000-00000-00000
Enterprise - TDKQD-PKV44-PJT4N-TCJG2-3YJ6B
Standard - PHDV4-3VJWD-N7JVP-FGPKY-XBV89
Web - WV79P-7K6YG-T7QFN-M3WHF-37BXC
https://www.teamos-hkrg.com/index.php?threads/microsoft-sql-server-english-2017-rtm-teamos.42103/
@ansarizafar
ansarizafar / gun-service.sh
Created July 27, 2021 17:03 — forked from bioshazard/gun-service.sh
Automation for installing GunDB as a service (tested on Pi)
#!/bin/bash
## Usage: GUN_USER=gun GUN_ROOT=~gun/gun-pi-custom GUN_BRACH=master gun-service.sh
# Should be run as root (with sudo or directly)
[[ "$(whoami)" == "root" ]] || { echo "Must be run as root"; exit 1; }
# Setup default environment
[ -z "${GUN_USER}" ] && GUN_USER="pi"
GUN_DETECTED_USER_HOME=$(getent passwd ${GUN_USER} | cut -d: -f6)
@ansarizafar
ansarizafar / Event-stream based GraphQL subscriptions.md
Created July 4, 2021 05:35 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@ansarizafar
ansarizafar / Accordian.svelte
Created November 20, 2020 15:00 — forked from matryer/Accordian.svelte
Simple Accordian component for Svelte (from https://firesearch.dev)
<script lang='ts'>
import { slide } from 'svelte/transition'
export let open: boolean = false
export function toggle() {
open = !open
}
</script>
<a
href='#open'
on:click|preventDefault={ toggle }