アプリ関連ニュース
- 2021年8月09日
- 技術情報
Git tricks you should know
We use version control system to manage and gather our source codes, right. I am pretty sure most of us are using Git for version control system nowadays. Today, I will share with you some git commands that will help you to improve your git knowledge.
Remove all your local git branches except master
You may have many local branches while you are on developments. But one day, you may want to get rid of these local branches and keep only main/master branch. This command will help you.
git branch | grep -v "main" | xargs git branch -D
Undo last commit
If you want to undo your most recent commit. Follow these steps.
git commit -m "undo message"
Then reset our changes
Pretty git log format
git reset HEAD~
Normally we use to see our git log activity using git log. But we can see better with pretty formatting using this.
git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
Deleting git branch
I wrote deleting local branches except main/master in above. In here, I will talk about deleting a specific branch both on local and remote.
Deleting on local
git branch -d <branch_name>
Deleting on remote
git push <remote> --delete <branch_name>
Cherry picking from another repository
We can apply the changes from another repository to us also.
git fetch <remote-url> <branch_name> && git cherry-pick SHA1
I’m pretty sure there are other useful tricks as well. That’s all for now.
Yuuma
yuuma at 2021年08月09日 10:30:19
- 2021年8月02日
- 技術情報
Getting Hostname in Laravel
We have to catch your domain name, hostname and url segments and use it back in your projects frequently. Today I will share a few functions to get it done easily in Laravel Framework.
getHttpHost
request()->getHttpHost(); //return domain.com
This will return the domain name like this.
request()->getHost(); // return domain.com
This also works same with above method.
getSchemeAndHttpHost
If you want to get http segments along with the domain name. You can use getSchemeAndHttpHost method.
request()->getSchemeAndHttpHost(); // return https://domain.com
url
Using the url method, you can get the current route path like this.
url()->current(); // return current existing url
You can also use request()->url() to return the url address along with http.
segment
If you need to parse your routing url , the segment will help to parse it. For example this is our current url domain.com/blog/hello
request()->segment(0); // return blog
request()->segment(1); // return hello
The methods I wrote above are some of the useful functions if you have to deal with your URL address or hostname.
Yuuma
yuuma at 2021年08月02日 10:30:20
- 2021年7月30日
- 技術情報
Flutter – Aspect Ratio Widget
These days I studies flutter widgets a lot. From these studies, I would like to share you one thing – this is the importance of aspect ratio and how to use this widget.
Care about proportions more than exact dimensions?
When laying out your app, you often don’t care about the exact dimensions of which it will take. But you do care about the aspect ratio. You want the widget to be this wide irrespective of the actual dimensions or you want it to be slim or exactly square. Flutter solves this by providing the Aspect Ratio widget.
AspectRatio()
you give it an AspectRatio, a child, and, well , that’s it.
AspectRatio(
aspectRatio: 3 / 2,
child: MyWidget(),
)
Aspect ratio is the ratio between the width and height of a box. It’s often written as a fraction, like 3/2, as in three parts of width to two parts of height. But let’s not kid ourselves – it’s really just a double: 3 over 2 is just 3 divided by 2, which is 1.5 – the same thing.
AspectRatio(
aspectRatio: 1.5,
child: MyWidget(),
)
But don’t worry! Dart is smart enough to do the computation for you during compilation. So it’s okay and more readable to provide the aspect ratio as a fraction.
And one more thing – make sure you actually let the AspectRatio widget size it’s child. If you put AspectRatio into something like Expanded, then that will be forced by it’s parent to expand.
Expanded(
child: AspectRatio(
aspectRatio: 3 / 2,
child: MyWidget(),
),
)
Tightly fitted widgets like Expanded don’t give their children a choice- harsh. If this happens to you, just put something like Align between the Expanded and the AspectRatio.
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: AspectRatio(
aspectRatio: 3 / 2,
child: MyWidget(),
),
),
)
Align will be forced by Expanded to fill the area. But it will let it’s child assume it’s own proportions.
Hope you enjoyed the article!
By Ami
asahi at 2021年07月30日 10:00:58
- 2021年7月28日
- Android
Flutterを使ってAndroidアプリを作ろう
tanaka at 2021年07月28日 10:00:58
Flutterの開発環境を構築しよう
tanaka at 2021年07月21日 10:00:10