Skip to content

Instantly share code, notes, and snippets.

@romancitodev
romancitodev / gen-env-types.ts
Created April 19, 2024 22:43
this is a script to generate the types (only interpreted as strings) from a .env file and save it into a file `types/env.d.ts`
import fs from 'node:fs';
const ENV_FILE_PATH = '.env';
const ENV_TYPES_PATH = 'types/env.d.ts';
// Function to parse the env file
function parsefile(path: string): string[] {
const buffer = fs.readFileSync(path);
const content = buffer.toString('utf8');
const env = [];
@NikolayIT
NikolayIT / LinearRegression.cs
Created March 17, 2017 13:43
Linear regression implementation in pure C# with example of Bulgarian population prediction
namespace LinearRegression
{
using System;
using System.Diagnostics;
public static class Program
{
public static void Main()
{
var xValues = new double[]
@kingspp
kingspp / logging.py
Created April 22, 2017 07:14
Python Comprehensive Logging using YAML Configuration
import os
import yaml
import logging.config
import logging
import coloredlogs
def setup_logging(default_path='logging.yaml', default_level=logging.INFO, env_key='LOG_CFG'):
"""
| **@author:** Prathyush SP
| Logging Setup
@revilowaldow
revilowaldow / pdf-extract-images.py
Last active April 19, 2024 22:38 — forked from XBigTK13X/pdf-extract-images.py
A 5etools focused script to automate pdf image extraction and masking. Also generates a cover thumbnail
#! /usr/bin/python3
# This script requires pdfimage, pdftoppm (poppler-utils), convert (imagemagick), and alive_bar (alive-progress)
# If your pdf file contains jp2 images, you can either (un)comment lines 84 & 85 for a significant performance hit, or you can also install opj_decompress (libopenjp2-tools)
# Example usage: python3 pdf-extract-images.py "Players Handbook.pdf" "PHB"
# Raw images will be written to <OUTPUT_DIR>/15-organized
# Attempts at merging masks and images will be output in webp to <OUTPUT_DIR/30-masked>
# Images without corresponding masks will be written in webp to <OUTPUT_DIR>/40-standalone
@karljuhlpep
karljuhlpep / dspy_codegen.py
Last active April 19, 2024 22:35
DSPy Module - CodeGen + Debugging
import subprocess
import dspy
### Note this code is not tested, and likely includes errors that need to be refined.
class IterativeCodeRefinement(dspy.Module):
def __init__(self):
super().__init__()
self.generate_pseudocode = dspy.ChainOfThought("task -> pseudocode")
@qrtt1
qrtt1 / build.gradle
Created May 23, 2016 04:27
Gradle files(), fileTree()
//
// Demo Structure
//
// qty:lab qrtt1$ tree
// .
// ├── build.gradle
// └── libs
// ├── a.jar
// └── vendorA
@R1j1t
R1j1t / pre-commit
Last active April 19, 2024 22:32
Pre-commit hook for python repo: Instead of getting to know whether any lint checks failed in CI, I created this pre-commit hook in git for my python repo. Git Hooks is a powerful utility. You read from the official documentation: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks. Please ⭑ this Gist if you find it useful! Feel free to co…
#!/bin/sh
# This is a pre-commit hook for python. It checks if black is passed and then if flake8 is passed.
# Feel free to share your updates. It will help use these git feature!
if black . --check; then
echo "Everything is all right in black"
else
echo ""
@onlurking
onlurking / programming-as-theory-building.md
Last active April 19, 2024 22:31
Programming as Theory Building - Peter Naur

Programming as Theory Building

Peter Naur

Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct

@kettanaito
kettanaito / App.jsx
Created May 27, 2020 06:33
CSS Variables in Styled Components
import { createGlobalStyle, css } from 'styled-components'
const GlobalStyle = createGlobalStyle`
html {
/* Maps all colors from the `theme` to CSS variables: */
${({ theme }) => Object.entries(theme.colors).map(([name, value]) => css`
--${camelCaseToKebabCase(name)}: ${value};
`)}
}
`
@brockelmore
brockelmore / bedrock_deploy.sol
Last active April 19, 2024 22:28
Optimism-Bedrock deployment with foundry
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.15;
import "forge-std/Script.sol";
// L1
import { L1CrossDomainMessenger } from "../L1/L1CrossDomainMessenger.sol";
import { L1ERC721Bridge } from "../L1/L1ERC721Bridge.sol";
import { L1StandardBridge } from "../L1/L1StandardBridge.sol";
import { L2OutputOracle } from "../L1/L2OutputOracle.sol";