Skip to content

Instantly share code, notes, and snippets.

@wosephjeber
wosephjeber / instructions.md
Last active May 7, 2024 13:31
Ecto migration for renaming table with indexes and constraints

Renaming table in Ecto migration

I recently wanted to rename a model and its postgres table in a Phoenix app. Renaming the table was simple and documented, but the table also had constraints, sequences, and indexes that needed to be updated in order for the Ecto model to be able to rely on default naming conventions. I couldn't find any examples of what this would look like but was eventually able to figure it out. For anyone else in the same situation, hopefully this example helps.

In the example below, I'm renaming the Permission model to Membership. This model belongs to a User and an Account, so it has foreign key constraints that need to be renamed.

defmodule MyApp.Repo.Migrations.RenamePermissionsToMemberships do
  use Ecto.Migration
@ckandoth
ckandoth / install_nextflow_singularity.md
Last active May 7, 2024 13:28
Install conda and use it to install nextflow and singularity

This guide will show you how to install conda and then use it to install nextflow and singularity for executing popular bioinformatics workflows. Unfortunately, singularity is not available on Windows or macOS. So, this guide will only target Linux environments. If you have to use Windows 10, then try WSL2. If you have to use macOS, then try a Virtual Machine.

Download the Miniconda3 installer for Linux environments:

curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o miniconda.sh

Install into a folder named miniconda3 under your home directory, and delete the installer:

bash miniconda.sh -bup $HOME/miniconda3 && rm -f miniconda.sh
@MarcoLizza
MarcoLizza / scale_rotate.c
Last active May 7, 2024 13:28
Fast scale-and-rotate blit.
typedef unsigned char Pixel_t;
typedef struct _Point_t {
int x, y;
} Point_t;
typedef struct _Rectangle_t {
int x, y;
int width, height;
} Rectangle_t;
@romkatv
romkatv / migrate-zsh-dotfiles.zsh
Last active May 7, 2024 13:27
Migrate zsh dotfiles from the home directory to another directory on the same machine
# This command moves your zsh dotfiles (.zshrc, .zsh_history, etc.)
# from the home directory to ~/.config/zsh. It's been verified to
# work correctly if you are using zsh4humans. With other zsh configs
# your mileage may vary.
#
# How to:
#
# 1. Close all terminals except one.
# 2. Copy-paste this command into the only remaining terminal.
() {
@hyjk2000
hyjk2000 / .alacritty.yml
Created February 12, 2020 08:48
Alacritty with Tmux Setup
# Configuration for Alacritty, the GPU enhanced terminal emulator.
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty itself.
#env:
# TERM variable
#
# This value is used to set the `$TERM` environment variable for
# each instance of Alacritty. If it is not present, alacritty will
@HogeBlekker
HogeBlekker / flask.tsx
Last active May 7, 2024 13:27
Grafana Canvas Panel custom experimental element
import React from 'react';
import { ColorDimensionConfig, ScalarDimensionConfig } from '@grafana/schema';
import { DimensionContext } from 'app/features/dimensions';
import { ColorDimensionEditor, ScalarDimensionEditor } from 'app/features/dimensions/editors';
import { CanvasElementItem, CanvasElementProps, defaultBgColor } from '../element';
interface FlaskData {
height: number;
@kolebynov
kolebynov / Program.cs
Created May 7, 2024 13:15
Simple stack/heap dynamic array
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
var list1 = new FixedList16<int>();
var list2 = new FixedList32<int>();
UseList(ref list1, 1);
UseList(ref list2, 2);
static void UseList<TItem, TList>(ref TList list, TItem item)
where TItem : unmanaged
@wozulong
wozulong / issues_baipiao_checker.py
Last active May 7, 2024 13:30
检查issues里的白嫖者,自动关闭+加标签+锁定
import requests
issue_labels = ['no respect']
github_repo = '<owner>/<repo>'
github_token = '<github token>'
headers = {
'Authorization': 'Bearer ' + github_token,
'Accept': 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28',
}
@chroming
chroming / 软件备忘.md
Created March 18, 2019 13:41
个人对于(开源)软件的评价列表

软件备忘

Linux桌面发行版

根据多年(也不多)的折腾经验,考虑发行版

  • 首先考虑对软件包管理的喜好,与健壮的软件仓库
  • 其次考虑默认的桌面环境(默认的桌面环境往往优化、整合得更好)
  • 作为桌面系统,尽可能地不折腾

在此基础上,个人喜好为:

@AndersonFirmino
AndersonFirmino / velocity-plus.sh
Last active May 7, 2024 13:26
Programas que ajudam a melhorar desempenho Linux/Pc modestos
#!/bin/sh
# script para instalar programas que ajudam no desempenho.
echo "Esta de acordo em fazer o upgrade? (digite: ok e tecle enter se sim) "
read certeza
if [ "$certeza" = "ok" ]
then
sudo apt-get install zram-config -y
sudo apt-get install preload -y
sudo apt-get install prelink -y