trait bound fonksiyon tanimi(static dispatch):
fn foo<T: MyTrait>(f: &T) {}Static type dispach yapar. foo(inek), foo(koyun) gibi cagirdigimizda compile time'da iki ayri fn generate edilir.
| #!/bin/bash | |
| # exit on error | |
| set -e | |
| CONF_DIR=~/.kube/config.d | |
| require() { | |
| if ! hash "$1" &>/dev/null; then |
| #!/bin/bash | |
| # alias kctx="source ~/.bin/kctx.sh" | |
| CONF_DIR=~/.kube/config.d | |
| file=$(ls -1 $CONF_DIR | fzf) | |
| echo "$file" | |
| if [[ ! "$file" == "null" ]]; then |
| // formatter adds default fields to each log entry. https://github.com/sirupsen/logrus/pull/653#issuecomment-454467900 | |
| type formatter struct { | |
| Fields logrus.Fields | |
| Lf logrus.Formatter | |
| } | |
| // Format satisfies the logrus.Formatter interface. | |
| func (f *formatter) Format(e *logrus.Entry) ([]byte, error) { | |
| for k, v := range f.Fields { | |
| e.Data[k] = v |
| use actix_service::{Service, Transform}; | |
| use actix_web::{dev::ServiceRequest, dev::ServiceResponse, Error}; | |
| use futures::future::{ok, Ready}; | |
| use futures::{Future}; | |
| use slog::info; | |
| use futures::task::Poll; | |
| use std::task::Context; | |
| use std::pin::Pin; | |
You have to do 2 things in order to allow your container to access your host's postgresql database
Obs: By "Host" here I mean "the server where docker is running on".
Find your postgresql.conf (in case you don't know where it is)
$ sudo find / -type f -name postgresql.conf
| import 'package:flutter/material.dart'; | |
| void main() async { | |
| runApp(new TestApp()); | |
| } | |
| class TestApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { |
| // 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()); | |
| } |
| 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)}"); | |
| } |
| 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) |