Skip to content

Instantly share code, notes, and snippets.

View paderinandrey's full-sized avatar

Andrey Paderin paderinandrey

View GitHub Profile
class CloneCourse < ActiveJob::Base
def perform(course)
ActiveRecord::Base.transaction do
@new_course = course.dup
@new_course.save!
course.materials.each do |material|
@new_material = material.dup
@new_material.course = @new_course
@new_material.save!

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
# 3. Clear 'Processed' and 'Failed' jobs
FROM ruby:2.6.3-slim-buster
SHELL ["/bin/bash", "-c"]
ARG NGINX_VERSION=1.14.2
# Install dependencies
COPY ./ngx_Aptfile /tmp/Aptfile
RUN apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
build-essential \
@paderinandrey
paderinandrey / ldeq.go
Created December 27, 2021 00:55
RDS-06
package main
import (
"context"
"fmt"
"os"
"strconv"
"github.com/go-redis/redis/v8"
)
@paderinandrey
paderinandrey / 0002_server_server_is_active.py
Last active January 2, 2022 18:28
Rebrain:Python. Task-14
# Generated by Django 4.0 on 2022-01-02 17:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rbr_srv_side', '0001_initial'),
]
@paderinandrey
paderinandrey / api_client.py
Last active January 6, 2022 05:13
Rebrain:Python. Task-15
import requests
import os
import json
from logger import logging
class APIClient:
def __init__(self, server_addr):
self.server_addr = server_addr
self.hostname = "hostname"
@paderinandrey
paderinandrey / 0003_metric.py
Last active January 4, 2022 20:56
Rebrain:Python Django
# Generated by Django 4.0 on 2022-01-04 00:43
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
<?xml version="1.0"?>
<clickhouse>
<clickhouse_remote_servers>
<local>
<shard>
<internal_replication>false</internal_replication>
<replica>
<host>64.225.65.90</host>
<port>9000</port>
</replica>
@paderinandrey
paderinandrey / starship.toml
Created November 19, 2022 17:52 — forked from nukopy/starship.toml
Nerd Font Symbols created by Starship. This is a Starship default config.
# Starship default config, extracted from the source
# Configure the format of the prompt
format = """\
$username\
$hostname\
$shlvl\
$singularity\
$kubernetes\
$directory\