Skip to content

Instantly share code, notes, and snippets.

View mesuutt's full-sized avatar

Mesut Taşçı mesuutt

View GitHub Profile
@mesuutt
mesuutt / access_postgresql_with_docker.md
Created November 14, 2020 23:40 — forked from MauricioMoraes/access_postgresql_with_docker.md
Allow Docker Container Access to Host's Postgres Database on linux (ubuntu)

You have to do 2 things in order to allow your container to access your host's postgresql database

  1. Make your postgresql listen to an external ip address
  2. Let this client ip (your docker container) access your postgresql database with a given user

Obs: By "Host" here I mean "the server where docker is running on".

Make your postgresql listen to an external ip address

Find your postgresql.conf (in case you don't know where it is)

$ sudo find / -type f -name postgresql.conf

@mesuutt
mesuutt / django-template-filters.py
Last active October 1, 2020 06:39
Useful django template tags and filters
# coding: utf-8
import json
from django import template
from django.utils.dateparse import parse_datetime
from django.utils.html import mark_safe
register = template.Library()
@mesuutt
mesuutt / i3block-take-a-break.sh
Created October 13, 2016 14:56
Break reminder for i3blocks.
#!/bin/bash
#[remind_break]
#command=~/.i3/i3blocks/take-a-break.sh
#interval=10
# Minutes
work_time=20
break_time=5
import 'package:flutter/material.dart';
void main() async {
runApp(new TestApp());
}
class TestApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@mesuutt
mesuutt / nested_scroll_view.dart
Created February 13, 2019 13:43 — forked from collinjackson/nested_scroll_view.dart
nestedscrollview example
// Copyright 2017, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() {
runApp(new TestApp());
}
@mesuutt
mesuutt / format-money.dart
Last active February 11, 2019 14:39
Format money as Turkish money format in dart language
String formatMoney(dynamic text) {
if (text is num){
text = text.toStringAsFixed(2);
}
return text
.toString()
.replaceAllMapped(RegExp(r"(\d)(?=(\d{3})+\.)"), (m) => "${m.group(1)}.")
.replaceAllMapped(RegExp(r"\.(\d+)$"), (m) => ",${m.group(1)}");
}
@mesuutt
mesuutt / deploy-hugo.sh
Last active January 18, 2019 09:47
bash script for deploying hugo site to github pages.
#!/bin/bash
# bash script for deploying hugo site to github pages.
# I have a two branch develop and master.
# develop branch keeps source files of my blog
# master branch keeps generated website files
# If you have unstaged or not tracked files, script adds these files to stash.
# So you unstash these changes after deploy.
@mesuutt
mesuutt / views.py
Last active October 25, 2018 11:49
Django save file to storage & Read from storage without model
from django.core.files.storage import default_storage
# Saving POST'ed file to storage
file = request.FILES['myfile']
filename = default_storage.save(file.name, file)
# Reading file from storage
file = default_storage.open(filename)
@mesuutt
mesuutt / git_notlari.md
Last active September 15, 2018 08:30
Git notları

Neden git pull değilde git pull --rebase kullanılmalı

http://stackoverflow.com/a/7200641/1027507

Dosyaları silmeden son yapılan commiti silmek

git reset --soft HEAD~1

Remoteda olup localde olmayan branchi indirip üzerinde çalışmaya başlamak

@mesuutt
mesuutt / rates.py
Last active March 7, 2018 09:37
Show BTC,ETH and LTC exchange rates without leaving commandline.
import re
import sys
import getopt
from datetime import datetime, timedelta
from decimal import Decimal
import requests
GREEN = '\033[0;32m'
RED = '\033[0;31m'
MAGENTA = '\033[0;35m'