Skip to content

Instantly share code, notes, and snippets.

View sohang3112's full-sized avatar
:octocat:

Sohang Chopra sohang3112

:octocat:
View GitHub Profile
@wiseaidev
wiseaidev / install_ipc_proxy_kernel.py
Last active June 16, 2024 08:33 — forked from SpencerPark/install_ipc_proxy_kernel.py
A little proxy kernel (and installer) that manages a wrapped kernel connected with tcp. It was designed to support the case where the server starts kernels with ipc transport but only tcp is supported (like Rust).
import argparse
import json
import os
import os.path
import shutil
import sys
from jupyter_client.kernelspec import (KernelSpec, KernelSpecManager,
NoSuchKernel)
@hwayne
hwayne / rainbow-sort.js
Created December 4, 2023 17:54
Rainbow sort
// put in https://editor.p5js.org/
// generated (mostly) with GPT4
let cols, rows;
let w = 2;
let colors = [];
let i = 0;
let j = 0;
let sorted = false;
@Hirrolot
Hirrolot / CoC.ml
Last active May 24, 2024 23:57
How to implement dependent types in 80 lines of code
type term =
| Lam of (term -> term)
| Pi of term * (term -> term)
| Appl of term * term
| Ann of term * term
| FreeVar of int
| Star
| Box
let unfurl lvl f = f (FreeVar lvl)
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
public class MyDictionary<T, V>: Dictionary<(string, T), V>
{
private IEnumerable<(string Name, T Value)> GetMembers(object obj)
{
var properties = obj.GetType().GetProperties(BindingFlags.Public).Select(o => (o.Name, Value: (T)o.GetValue(obj)));
@mufidu
mufidu / download_imgs.py
Last active April 28, 2024 06:18
Download all images in markdown files and rename the links to point to the local files
# Download all images from all FOLDER_NAME in FOLDER_NAME folder
# and save them to FOLDER_NAME/_attachments folder.
# Then replace remote image paths with local paths.
# Usage: python download_imgs.py
import os
import urllib
import urllib.parse
import urllib.request
import re
@ShrykeWindgrace
ShrykeWindgrace / _stack.ps1
Created April 22, 2022 08:16
Powershell tab-completion script for stack
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
Register-ArgumentCompleter -Native -CommandName 'stack' -ScriptBlock {
param($wordToComplete, $commandAst)
[string[]]$localCommand = @('"--bash-completion-enriched"')
$hay = [System.Collections.Generic.List[string]]::new()
foreach ($item in $commandAst.CommandElements) {
$localCommand += '"--bash-completion-word"'
$localCommand += """$item"""
$hay.Add($item.ToString())
@Widdershin
Widdershin / ssr.md
Last active May 1, 2024 17:36
The absurd complexity of server-side rendering

In the olden days, HTML was prepared by the server, and JavaScript was little more than a garnish, considered by some to have a soapy taste.

After a fashion, it was decided that sometimes our HTML is best rendered by JavaScript, running in a user's browser. While some would decry this new-found intimacy, the age of interactivity had begun.

But all was not right in the world. Somewhere along the way, we had slipped. Our pages went uncrawled by Bing, time to first meaningful paint grew faster than npm, and it became clear: something must be done.

And so it was decided that the applications first forged for the browser would also run on the server. We would render our HTML using the same logic on the server and the browser, and reap the advantages of both worlds. In a confusing series of events a name for this approach was agreed upon: Server-side rendering. What could go wrong?

In dark rooms, in hushed tones, we speak of colours.

@didibus
didibus / clojure-right-tool.md
Last active June 1, 2024 14:06
When is Clojure "the right tool for the job"?

My answer to: https://www.reddit.com/r/Clojure/comments/pcwypb/us_engineers_love_to_say_the_right_tool_for_the/ which asked to know when and at what is Clojure "the right tool for the job"?

My take is that in general, the right tool for the job actually doesn't matter that much when it comes to programming language.

There are only a few cases where the options of tools that can do a sufficiently good job at the task become limited.

That's why they are called: General-purpose programming languages, because they can be used generally for most use cases without issues.

Let's look at some of the dimensions that make a difference and what I think of Clojure for them: