Skip to content

Instantly share code, notes, and snippets.

View dr5hn's full-sized avatar
🪄
Turning ☕ into code | Full Stack Magician 🧙‍♂️✨

Darshan Gada dr5hn

🪄
Turning ☕ into code | Full Stack Magician 🧙‍♂️✨
View GitHub Profile
@tolgahanakgun
tolgahanakgun / 403.py
Last active August 5, 2024 16:02
Return a nice-looking "403 Forbidden" for all HTTP requests to web scrapers
#!/usr/bin/env python3
#
# -*- coding: utf-8 -*-
import socket
from email.utils import formatdate
from ipaddress import ip_address
import argparse
import socketserver
@vis97c
vis97c / country-files.js
Last active January 5, 2024 16:09
Separate country data from dr5hn/countries-states-cities-database into smaller files
const fs = require("fs/promises");
const path = require("path");
const _ = require("lodash");
/**
* Write file
* @param {string} filePath
* @param {*} data
*/
async function writeFile(filePath, data) {
@caner-cetin
caner-cetin / go.mod
Created June 25, 2023 11:43
World Data Fix Script on Golang
module cityconv
go 1.20
require github.com/jackc/pgx/v5 v5.4.1
require (
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
golang.org/x/crypto v0.9.0 // indirect
@AshlinRejo
AshlinRejo / discount_table.php
Created October 19, 2022 11:18
Discount rules v2: Show only minimum range with + in discount table
<?php
/**
* Discount table
*
* This template can be overridden by copying it to yourtheme/advanced_woo_discount_rules/discount_table.php.
*
* HOWEVER, on occasion Discount rules will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@fecony
fecony / README.md
Created January 7, 2022 23:29
Generate json data for Prisma countries, state and city seeding 🗄

// Countries, states, cities taken from https://github.com/dr5hn/countries-states-cities-database

// I had the idea of seeding the database with countries, states, and cities. // I tried to generate seed files with data from json files. I created data.json, copied in json of countries, and then used code.js file to parse data as I need.

// But after seeding, I realized that it didn't make sense. // And it's better to generate cities/countries/states as you go, as users add data for that particular location. // Cities SQL file takes 12,6 MB on disk // Just use SQL files...

@tfeuerst
tfeuerst / World countries - ISO Standard 3166-1
Created October 29, 2021 06:30
Data of world country data in multiple languages. Maybe use as source for static_info_tables.
# World countries - ISO Standard 3166-1 - states and capital cities
## World countries
- [ ] https://github.com/umpirsky/country-list (all counties in all languages | many formates)
- [ ] https://github.com/mledoze/countries (SVG geo shapes | country list in some languages)
- [ ] https://www.geodatasource.com/world-cities-database/free (worldwide cities)
@cassidoo
cassidoo / copilot-suggestions.js
Last active December 11, 2021 19:05
A gist of all of the functions that Copilot wrote for me
/**
As seen on twitch.tv/cassidoo
*/
// A function that validates an email address
function validateEmail(email) {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
@chimit
chimit / bitbucket-pipelines.yml
Created August 7, 2020 02:35
Bitbucket Pipelines config for Laravel 7 with PHP 7.4, GD and EXIF
# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: php:7.4-fpm
definitions:
services:
mysql:
@llagerlof
llagerlof / print_r_reverse.php
Last active May 28, 2024 03:19
Convert the output string of print_r to array again.
<?php
// original author: https://www.php.net/manual/en/function.print-r.php#93529
// another dev said it was fixed for null values, but I don't encountered errors with null values for Matt's: https://www.php.net/manual/en/function.print-r.php#121259
// Matt
function print_r_reverse($in) {
$lines = explode("\n", trim($in));
if (trim($lines[0]) != 'Array') {
// bottomed out to something that isn't an array
return $in;