Skip to content

Instantly share code, notes, and snippets.

View mumin91's full-sized avatar
🎯
Focusing

Muminur Rahman mumin91

🎯
Focusing
View GitHub Profile
@scott-cognizant
scott-cognizant / pydantic_from_marshmallow.py
Last active December 14, 2024 18:01 — forked from kmatarese/pydantic_from_marshmallow.py
Hack to convert marshmallow schemas to pydantic models
"""
From:
https://gist.github.com/kmatarese/a5492f4a02449e13ea85ace8801b8dfb
Customized by Bright Wolf to improve in various ways including recursion and
support data_key for field name
WARNING: not thoroughly tested and does not support full translation
between the two libraries.
@chestercharles
chestercharles / te-map-and-chain.ts
Last active July 19, 2023 09:43
Chain vs. Map with TaskEither
import * as TE from 'fp-ts/lib/TaskEither';
import * as E from 'fp-ts/lib/Either';
import { pipe } from 'fp-ts/lib/function';
// Let's start with a value of 4 wrapped up in a TaskEither
const teFour = TE.right(4);
// The type of teFour is TE.TaskEither<never, number> because TE.right knows there will _never_ be a left value (as of yet)
// We can use TE.map to create a function that will accept a TE and operate on it's value
import useFetch from "useFetch";
const { response, isLoading } = useFetch({
api: identityApi,
url: AUTH_MEMBER_TRANSACTIONS(requestOptions),
config: JSON.stringify({ requireAuthentication: true }),
});
@kmatarese
kmatarese / pydantic_from_marshmallow.py
Last active January 23, 2024 06:48
Hack to convert marshmallow schemas to pydantic models
"""WARNING: not thoroughly tested and does not support full translation
between the two libraries.
Uses a pydantic root_validator to init the marshmallow schema. It attempts
to map marshmallow field types to pydantic field types as well, but not all
field types are supported.
You can either use the pydantic_from_marshmallow function that does all of
the above or just subclass MarshmallowModel and manually define your pydantic
fields/types/etc.
@coltenkrauter
coltenkrauter / fix-wsl2-dns-resolution.md
Last active March 14, 2026 13:41
Fix DNS resolution in WSL2

Permanent WSL DNS Fix (WSL 2.2.1+)

If you're encountering ping github.com failing inside WSL with a Temporary failure in name resolution, you're not alone — this has been a long-standing issue, especially when using VPNs or corporate networks.

This issue is now fixed robustly with DNS tunneling, which preserves dynamic DNS behavior and avoids limitations like WSL’s former hard cap of 3 DNS servers in /etc/resolv.conf.

DNS tunneling is enabled by default in WSL version 2.2.1 and later, meaning that if you're still seeing DNS resolution issues, the first and most effective fix is simply to upgrade WSL. Upgrading WSL updates the WSL platform itself, but does not affect your installed Linux distributions, apps, or files.

To upgrade WSL, follow these steps,

@MilosSimic
MilosSimic / clientbin.go
Last active November 26, 2024 09:11
tcp server/client in golang using binary data
package main
import (
"bytes"
"encoding/gob"
"fmt"
"net"
// "time"
)
@vubon
vubon / models.py
Last active January 29, 2022 06:01
Django BRIN index in PostgreSQL Database
from django.contrib.postgres.indexes import BrinIndex
from django.db import models
class SampleData(models.Model):
created_at = models.DateTimeField()
class Meta:
"""
You must need to use PostgreSQL DB unless you can't use BrinIndex
"""
@tashirka1
tashirka1 / admin.py
Created December 10, 2018 16:39 — forked from gauravvjn/admin.py
Use JSONField properties in Django admin filter Raw
# You have a model something like this
from django.contrib.postgres.fields import JSONField
class MyModel(models.Model):
jsonfield = JSONField() # {"name": "Gaurav", "age": "25", "address": {"country": "India", "city": "Jaipur"}}
# few more fields...
# And in admin you want to create filter for jsonfield properties/keys
# for e.g. in above case we want to show filter for age and country
@bradtraversy
bradtraversy / django_deploy.md
Last active March 2, 2026 18:03
Django Deployment - Digital Ocean

Django Deployment to Ubuntu 18.04

In this guide I will go through all the steps to create a VPS, secure it and deploy a Django application. This is a summarized document from this digital ocean doc

Any commands with "$" at the beginning run on your local machine and any "#" run when logged into the server

Create A Digital Ocean Droplet

Use this link and get $10 free. Just select the $5 plan unless this a production app.

@oranges13
oranges13 / RegistrationController.php
Created April 23, 2018 16:21
Populate external drop downs for datatable filtering
/**
* Process datatables ajax request.
*
* @return \Illuminate\Http\JsonResponse
*/
public function allData(Request $request)
{
$registrations = Registration::with('product')->with('reg_type')->select('registrations.*');
$datatable = Datatables::of($registrations);