Skip to content

Instantly share code, notes, and snippets.

View mehmetsefabalik's full-sized avatar
🐟

Mehmet Sefa mehmetsefabalik

🐟
View GitHub Profile
@mehmetsefabalik
mehmetsefabalik / rust_hot_reload.md
Created January 19, 2022 21:24
Rust hot reload

cargo install systemfd cargo-watch

systemfd --no-pid -s http::PORT -- cargo watch -x run

@mehmetsefabalik
mehmetsefabalik / sort-vec-of-tuples.rs
Created July 11, 2021 14:30
Sort Vector of Tuples in Rust
fn main() {
let mut v: Vec<(&str, i32)> = vec![("a", 2), ("b", 1), ("c", 3)];
v.sort_by(|a, b| a.1.cmp(&b.1)); // increasing order
v.sort_by(|a, b| b.1.cmp(&a.1)); // decreasing order
println!("{:?}", v);
}
use chrono;
use chrono::offset::TimeZone;
let birth_date = chrono::Utc.from_local_date(&chrono::NaiveDate::parse_from_str("1995-07-05", "%Y-%m-%d")).unwrap();
let duration_since_birth = chrono::Utc::today().signed_duration_since(birth_date);
let age = duration_since_birth.num_days() / 365
@mehmetsefabalik
mehmetsefabalik / nginx-https-local.md
Last active April 8, 2024 04:01
Enable https on your local environment with nginx

enable https on your local environment

install mkcert and create certificates

brew install mkcert
mkcert -install

Remove local branches except master

git branch | grep -v '^*' | xargs git branch -D

Remove remote branches except master

REMOTE='origin' && MASTER='master' && git branch -r |  grep '^  ${REMOTE}/' | sed 's|^  ${REMOTE}/|:|' | grep -v '^:HEAD' | grep -v '^:${MASTER}$' | xargs git push ${REMOTE}

certbot -d DOMAINNAME --manual --logs-dir certbot --config-dir certbot --work-dir certbot --preferred-challenges dns certonly

10minutemail.com
remove.bg
unscreen.com
hemingwayapp.com
idphoto4you.com
myairbridge.com
loader.to
informationisbeautiful.net
nek.istanbul.edu.tr
spik.ai
@mehmetsefabalik
mehmetsefabalik / ssl-nginx.md
Last active August 28, 2020 21:58
setup an ngnix proxy server with ssl on linux

install nginx

  • sudo apt install nginx
  • sudo rm /etc/nginx/sites-available/default
  • sudo rm /etc/nginx/sites-enabled/default

setup nginx config for the first time

  • sudo vim /etc/nginx/sites-available/yourdomainname.com
server {
     listen 80;
@mehmetsefabalik
mehmetsefabalik / multi-line-overflow.css
Last active January 21, 2020 12:42
css text overflow example with one line and multiple lines
.one-line-overflow {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.multi-line-overflow {
white-space: normal;
display: -webkit-box;
-webkit-box-orient: vertical;
@mehmetsefabalik
mehmetsefabalik / launch.json
Created October 25, 2019 07:01
vscode debugger picking process
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Node: Nodemon",
"processId": "${command:PickProcess}",
"restart": true,
"protocol": "inspector",