Skip to content

Instantly share code, notes, and snippets.

View bay007's full-sized avatar
🏠
Working from home

egalicia bay007

🏠
Working from home
View GitHub Profile
@bay007
bay007 / app.module.ts
Created January 22, 2024 09:55 — forked from mafalt/app.module.ts
NestJS + TypeORM configuration
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { getTypeOrmModuleOptions } from './config/orm.config';
import { CoreModule } from './core/core.module';
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
@bay007
bay007 / bootstrap-sail.sh
Created June 15, 2023 11:10 — forked from njbair/bootstrap-sail.sh
Install Laravel Sail into an existing project without PHP & Composer
#!/bin/sh
# Installs Laravel Sail into an existing project
# The official Laravel Sail docs[1] provide instructions for installing Sail
# into an existing PHP application. But the official method requires invoking
# Composer locally. Part of Sail's appeal is that it removes the need to
# install PHP on your host machine.
# This script is lifted from laravel.build[2], and thus uses the same method
@bay007
bay007 / gist:ed7e35e3e70f2f1f33ade15ad35ac2c6
Created August 22, 2020 16:20 — forked from simonw/gist:7000493
How to use custom Python JSON serializers and deserializers to automatically roundtrip complex types.
import json, datetime
class RoundTripEncoder(json.JSONEncoder):
DATE_FORMAT = "%Y-%m-%d"
TIME_FORMAT = "%H:%M:%S"
def default(self, obj):
if isinstance(obj, datetime.datetime):
return {
"_type": "datetime",
"value": obj.strftime("%s %s" % (
@bay007
bay007 / get_next_primary_key.py
Created August 16, 2020 06:31 — forked from kissgyorgy/get_next_primary_key.py
Django: Get next primary key for object.
from djangobb_forum.models import Post
from django.db.models import Max
# id__max is None if there are no Posts in the database
id_max = Post.objects.all().aggregate(Max('id'))['id__max']
id_next = id_max + 1 if id_max else 1

Intro to Advanced Python

By Adam Anderson

adam.b.anderson.96@gmail.com

These notes are mostly just summaries of the provided references. The purpose of this document is to centralize the resources I found useful so they would be easy to find. Most definitions and explanations are paraphrased or quoted directly from the sources.

Table of Contents

@bay007
bay007 / killgunicorn.sh
Created January 7, 2020 01:36 — forked from jvorcak/killgunicorn.sh
Kill gunicorn with all of the workers
alias killgunicorn="ps aux | grep gunicorn | awk '{print $2;}' | xargs kill -9 2>/dev/null"
@bay007
bay007 / blog.md
Created January 4, 2019 07:36 — forked from JacobBennett/blog.md
Clean up your Vue modules with ES6 Arrow Functions

Recently when refactoring a Vue 1.0 application, I utilized ES6 arrow functions to clean up the code and make things a bit more consistent before updating to Vue 2.0. Along the way I made a few mistakes and wanted to share the lessons I learned as well as offer a few conventions that I will be using in my Vue applications moving forward.

The best way to explain this is with an example so lets start there. I'm going to throw a rather large block of code at you here, but stick with me and we will move through it a piece at a time.

<script>

// require vue-resource...

new Vue({
@bay007
bay007 / appspec.yml
Created July 8, 2018 03:31 — forked from erickeno/appspec.yml
Node.js Project on AWS CodeDeploy CentOS
version: 0.0
os: linux
files:
- source: /
destination: /home/ec2-user/node
permissions:
- object: /home/ec2-user
owner: ec2-user
group: ec2-user
type:
@bay007
bay007 / appspec.yml
Created June 30, 2018 20:02 — forked from moshest/appspec.yml
Node.js Project on AWS CodeDeploy CentOS
version: 0.0
os: linux
files:
- source: /
destination: /home/ec2-user/node
permissions:
- object: /home/ec2-user
owner: ec2-user
group: ec2-user
type:
@bay007
bay007 / strategy-pattern.js
Last active May 19, 2017 05:31 — forked from glcheetham/strategy-pattern.js
Strategy Pattern JS example
// Example. Let's sort the apples, pears, and oranges into the right baskets.
const fruits = ["apple", "pear", "apple", "apple", "orange", "pear", "orange", "pear", "apple"]
let appleBasket = []
let pearBasket = []
let orangeBasket = []
let strategies = []
const appleSortStrategy = (fruit) => {