sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.utils.timezone import pytz | |
def formatted_date(naive_date): | |
aware_date = naive_date.astimezone(pytz.timezone(settings.TIME_ZONE)) | |
return aware_date.strftime("%d-%m-%Y, %H:%M:%S") | |
df['date'] = df['date'].apply(formatted_date) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db.models import Count, Max | |
unique_fields = ['field_1', 'field_2'] | |
duplicates = ( | |
MyModel.objects.values(*unique_fields) | |
.order_by() | |
.annotate(max_id=Max('id'), count_id=Count('id')) | |
.filter(count_id__gt=1) | |
) |
- Connect to your EC2 instance
- Install zsh :
sudo apt-get update && sudo apt-get install zsh -y
- Edit your passwd configuration file to tell which shell to use for user
ubuntu
:sudo vim /etc/passwd
- Look for
ubuntu
user, and replacebin/bash
bybin/zsh
- Install OhMyZsh :
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
- Disconnect from your instance and reconnect it.
- Optional - Set hostname in .zshrc
export PROMPT="%{$fg_bold[white]%} %{$bg[red]%}%{$reset_color%} ${PROMPT}"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const moment = require('moment') | |
const path = require('path'); | |
const createStrapiApp = async projectPath => { | |
if (!projectPath) { | |
throw new Error(` | |
-> Path to strapi project is missing. | |
-> Usage: node migrate-3.4.0.js [path]`); | |
} |
- Connect to your EC2 instance
- Install zsh :
sudo apt-get update && sudo apt-get install zsh
- Install OhMyZsh :
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
4.sudo chsh -s /bin/zsh ubuntu
to change the user ubuntu's default shell. Replace 'ubuntu' with your username. - Disconnect from your instance and reconnect it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DB_NAME=$1 | |
DB_USER=$2 | |
DB_PASS=$3 | |
BUCKET_NAME='bucket-name' | |
TIMESTAMP=$(date +%F_%T | tr ':' '-') | |
DB_FILE="$TIMESTAMP.sql" | |
PGPASSWORD=$DB_PASS pg_dump -Fc --no-acl -h localhost -U $DB_USER $DB_NAME > $DB_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vue.js 5 hrs 29 mins ███████████▍░░░░░░░░░ 54.5% | |
Python 2 hrs 59 mins ██████▏░░░░░░░░░░░░░░ 29.7% | |
JavaScript 28 mins █░░░░░░░░░░░░░░░░░░░░ 4.8% | |
HTML 21 mins ▊░░░░░░░░░░░░░░░░░░░░ 3.6% | |
GraphQL 14 mins ▍░░░░░░░░░░░░░░░░░░░░ 2.4% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use a lighter version of Node as a parent image | |
FROM node:10 as project-build | |
# Set the working directory to /frontend | |
WORKDIR /project | |
COPY package*.json /project/ | |
RUN npm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from django.apps import apps | |
from django.contrib.auth.admin import UserAdmin as DjUserAdmin | |
from . import models | |
# Register your models here. | |
@admin.register(models.User) | |
class UserAdmin(DjUserAdmin): | |
pass |
NewerOlder