Skip to content

Instantly share code, notes, and snippets.

@ervinne13
ervinne13 / clip
Created July 31, 2023 02:05
New Machine Setup
#!/bin/bash
xclip -sel c < $@
@ervinne13
ervinne13 / sail
Last active August 27, 2023 13:24
Sail Everywhere
#!/bin/bash
$PWD/vendor/bin/sail $@
@ervinne13
ervinne13 / ssh-config
Last active August 14, 2023 10:35
Supporting multiple github ssh
# Personal GitHub account
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_personal
# Work GitHub account
Host github.com-work
HostName github.com
User git
@ervinne13
ervinne13 / list-element-generator.js
Last active April 22, 2023 13:41
A simple function that generates an unordered list based on a tree of nodes.
/**
Instructions:
You may just copy the whole code and execute this on the browser console or include this to a node
project that has [JSDOM](https://github.com/jsdom/jsdom) to run it in the terminal.
Requirements:
A node is either a string, or a JS object of the form {"name": "a name", "nodes": [more, nodes]}
Write a function in javascript that converts an array of nodes into an unordered list in HTML
function mySample(arrayOfNodes) {...; return html}
@ervinne13
ervinne13 / gnome-terminal-profiles.conf
Last active August 11, 2023 02:37
Personal Ubuntu Terminal Profile
[/]
default='eba4372c-5679-447c-a555-209467495819'
list=['eba4372c-5679-447c-a555-209467495819']
[:eba4372c-5679-447c-a555-209467495819]
background-color='rgb(34,34,34)'
background-transparency-percent=2
foreground-color='rgb(236,236,236)'
palette=['rgb(46,52,54)', 'rgb(186,20,20)', 'rgb(78,154,6)', 'rgb(196,160,0)', 'rgb(52,101,164)', 'rgb(117,80,123)', 'rgb(6,152,154)', 'rgb(211,215,207)', 'rgb(85,87,83)', 'rgb(226,87,87)', 'rgb(138,226,52)', 'rgb(252,233,79)', 'rgb(114,159,207)', 'rgb(173,127,168)', 'rgb(52,226,226)', 'rgb(238,238,236)']
use-theme-colors=false
@ervinne13
ervinne13 / your-app.conf
Created October 18, 2022 06:33
Blocking 413 errors in NGINX: What I usually see is that developers tend to increase the max upload size limit of nginx to absurd levels and handle the validation in the application. Why not block it here in NGINX right away?
server {
listen 80;
server_name dev.your-app.com;
server_tokens off;
location / {
return 301 https://$host$request_uri;
}
@ervinne13
ervinne13 / date_range_overlap.py
Created September 21, 2022 02:24
Get # of days that overlap between two ranges. Usually use this to check if a date range falls within another, larger date range but might as well check for any overlap.
from datetime import datetime
from collections import namedtuple
Range = namedtuple('Range', ['start', 'end'])
# Returns a positive number of days overlapping, otherwise, returns 0
def get_days_overlap(r1: Range, r2: Range) -> int:
latest_start = max(r1.start, r2.start)
earliest_end = min(r1.end, r2.end)
@ervinne13
ervinne13 / csv_to_parquet.py
Last active April 19, 2022 10:05
A quick and easy CSV to Parquet converter from one bucket to another. This may be attached to a lambda function that can be triggered whenever a new s3:PutObject is executed.
from io import BytesIO
import boto3
import pandas as pd
from os import environ
def convert(bucket, key):
s3_client = boto3.client('s3', region_name=environ['REGION'])
s3_object = s3_client.get_object(Bucket=bucket, Key=key)
@ervinne13
ervinne13 / lambda_function.py
Last active April 16, 2021 14:03
Sample Lambda Function for Processing CSVs from an S3 Bucket
from os import environ
import boto3
from mongodb import initialize_connection
from pandas import read_csv
from operations_writer import OperationsWriter
from worklogs_operations_generator import WorklogsOperationsGenerator
from worklogs_repository import WorklogsRepository
def lambda_handler(event, context):
fastcgi_param APP_NAME "xxx my app";
fastcgi_param APP_ENV "production";
fastcgi_param APP_KEY "base64:gibberish";
fastcgi_param APP_DEBUG false;
fastcgi_param APP_URL "https://yourwebsite.com";
fastcgi_param ELASTICSEARCH_ENABLED true;
fastcgi_param ELASTICSEARCH_HOSTS "localhost:9200";
fastcgi_param LOG_CHANNEL "stack";