Skip to content

Instantly share code, notes, and snippets.

View SKumarSpace's full-sized avatar
🌆
Working from the sky

Shrey Kumar SKumarSpace

🌆
Working from the sky
View GitHub Profile
@SKumarSpace
SKumarSpace / main.go
Created November 18, 2024 17:03
Unmarshal sql.NullTime (JSON)
package main
import (
"database/sql"
"encoding/json"
"fmt"
"time"
)
// Custom type to wrap sql.NullTime
@SKumarSpace
SKumarSpace / bash.sh
Created May 30, 2024 02:43
Merge Git Repo - Subfolder
git remote add {name} https://[email protected]/org/repo_name/_git/repo_name
git fetch {name}
git subtree add --prefix=my_folder-name {name} master
@SKumarSpace
SKumarSpace / index.html
Last active March 11, 2024 01:03
Fancy Glowing Button - Tailwind
<div class="flex h-screen flex-col items-center justify-center bg-[#141516] relative z-10">
<button class="text-white border-2 relative text=[#F3F3F3] font-grot py-2 px-3 rounded-lg flex justify-center cursor-pointer bg-origin-border bg-clip-padding bg-[length:200%] before:content-[''] before:h-[30%] before:w-[60%] before:absolute before:bottom-[-20%] before:bg-[length:200%] bg-[linear-gradient(#121213,#121213),linear-gradient(#121213_50%,rgba(18,18,19,0.6)_80%,rgba(18,18,19,0)),linear-gradient(90deg,#FF6D1B,#FFEE55,#5BFF89,#4D8AFF,#6B5FFF,#FF64F9,#FF6565)] before:bg-[linear-gradient(90deg,#FF6D1B,#FFEE55,#5BFF89,#4D8AFF,#6B5FFF,#FF64F9,#FF6565)] before:blur-lg animate-razor before:animate-razor hover:animate-razor2 hover:before:animate-razor2 border-transparent before:-z-10" style="background-clip: padding-box, border-box, border-box;">
Get Started
</button>
</div>
@SKumarSpace
SKumarSpace / docker-compose.yml
Created January 12, 2024 00:17
WordPress Docker Compose
services:
db:
image: mysql:5.7
volumes:
- ./wordpress.sql:/docker-entrypoint-initdb.d/init.sql # prepopulate database
- db_data:/var/lib/mysql # persist database data inside docker storage
restart: always
env_file:
- .env
environment:
@SKumarSpace
SKumarSpace / Program.cs
Created October 10, 2023 14:34
Weighted Random Picker C#
for (int i = 0; i < 100; i++) {
var x = RandomPicker<string>.GetRandomChoice("A", 70, "B", 30);
Console.WriteLine(x);
}
public class RandomPicker<T> {
private static Random _random = new Random();
public static T GetRandomChoice(T valueA, int weightA, T valueB, int weightB) {
int totalWeight = weightA + weightB;
@SKumarSpace
SKumarSpace / index.html
Created October 10, 2023 14:34
Intersection Observer - Sticky Class Conditionally Applied
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
body {
margin: 0px;
font-family: Roboto, Tahoma;
@SKumarSpace
SKumarSpace / package.json
Created July 23, 2023 17:20
Typescript Project Init - Basic
{
"main": "dist/index.js",
"scripts": {
"build": "npx tsc && node dist/index.js"
},
"devDependencies": {
"typescript": "^4.9.5"
}
}
@SKumarSpace
SKumarSpace / a.js
Created July 18, 2023 18:07
cool fetch
function myCoolFetch(url: string): Promise<Response> {
// Simulating an asynchronous operation
return new Promise<Response>((resolve, reject) => {
// Simulating a delay before resolving the promise
setTimeout(() => {
// Create a mock response object
const response: Response = {
status: 200,
statusText: "OK",
ok: true,
@SKumarSpace
SKumarSpace / script.sh
Created July 3, 2023 18:33
Github - Commit in the Past
git add .
git commit --date='2020-10-09 00:00:00' -m "initial commit"
git filter-branch --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'
git push -f
@SKumarSpace
SKumarSpace / Program.cs
Created July 3, 2023 16:09
Pass C# Property via LINQ
using System;
using System.Collections.Generic;
using System.Linq;
namespace PassPropertyTests
{
public class BaseObject
{
public string Name { get; set; }
public string Email { get; set; }