Skip to content

Instantly share code, notes, and snippets.

View Relrin's full-sized avatar

Valeryi Savich Relrin

  • Stockholm, Sweden
  • 09:22 (UTC +02:00)
View GitHub Profile
use futures::{
task::{waker_ref, ArcWake}, // to create `context` from type implements ArcWake trait
FutureExt, // to use `Future::boxed` method
};
use std::{
future::Future,
sync::Arc,
task::{Context, Poll},
};
@ivanbrennan
ivanbrennan / postgres-in-minikube.sh
Last active March 13, 2025 08:30
PostgreSQL in minikube
# create/update resources
kubectl --context=minikube apply -f ./postgres.yaml
# In order for the service to reach the statefulset, the following should
# be true:
# statefulset.spec.selector.matchLabels.app == service.spec.selector.app
# statefulset.spec.selector.matchLabels.role == service.spec.selector.role
# give the server some time to start up
# ...
@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active April 24, 2025 05:32
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach() in asynchronous code.

For legacy browsers, use for...i or [].reduce()

To execute the promises in parallel, use Promise.all([].map(...))

The problem

@sean3z
sean3z / db.rs
Created March 18, 2018 04:55
Connection Pooling for Rust/Diesel
use std::ops::Deref;
use rocket::http::Status;
use rocket::request::{self, FromRequest};
use rocket::{Request, State, Outcome};
use r2d2;
use r2d2_diesel::ConnectionManager;
use diesel::mysql::MysqlConnection;
@emattson
emattson / install_postgresql_client.sh
Last active May 15, 2022 15:10
Install postgresql-client-10 on Debian 9
# taken from https://www.postgresql.org/download/linux/debian/
# assumes you are root
echo 'deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' > /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt-get update
yes Y | apt-get install postgresql-client-10
@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active December 8, 2024 22:08
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@chbrown
chbrown / _upgrade-pg9.4-to-pg9.5.md
Last active October 7, 2021 13:57
Upgrade PostgreSQL 9.4 to 9.5 on Mac OS X with Homebrew

First, check your current config (example output in homebrew.mxcl.postgresql.plist.xml lower down in this gist):

cat ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Most importantly, note the -D /usr/local/var/postgres argument.

Second, shut down your current PostgreSQL.

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
@sndwch
sndwch / JSON.mqh
Last active June 7, 2024 01:38
For MetaTrader 4. Creates JSON objects from MQL types
#property copyright "erdeszt"
#property version "1.00"
#property library
#include <Object.mqh>
#include <Arrays/ArrayObj.mqh>
#include <Arrays/ArrayString.mqh>
#include <mqlcommon/Erdeszt/Map.mqh>
#include <mqlcommon/Erdeszt/SmartPtr.mqh>
#include <mqlcommon/Erdeszt/Utils.mqh>
@kimmobrunfeldt
kimmobrunfeldt / 0-osx-for-web-development.md
Last active July 26, 2022 13:30
Install web development tools to Mavericks (OS X 10.9)

Install web development tools to Mavericks (OS X 10.9)

Strongly opinionated set of guides to quickly setup OS X Mavericks for web development. By default OS X hides stuff that normal people don't need to see. These settings are better defaults for developers.

I don't want: any sounds, annoying confirmation dialogs, hidden extensions, superflous animations, unnecessary things running like Dashboard, Notification center or Dock(Alfred/spotlight works better for me).

These are my opinions. Read this document through and pick up the good parts to your preferences.

System preferences

# - Config file for the glfw package
# It defines the following variables
# GLFW_INCLUDE_DIR, the path where GLFW headers are located
# GLFW_LIBRARY_DIR, folder in which the GLFW library is located
# GLFW_LIBRARY, library to link against to use GLFW
set(GLFW_INCLUDE_DIR "/usr/include")
set(GLFW_LIBRARY_DIR "/usr/lib")
find_library(GLFW_LIBRARY "glfw" HINTS ${GLFW_LIBRARY_DIR})