In 2016/04/10 I start 100 days of code challenge. It was not easy and I almost have done it. Almost it means that one day stays without commit. But happy information is that 99 days was with at least one commit. I was a very busy time for me. I learn a lot, especially how to code in Python. But this one-day caused that this whole challenge it does not count. So from today I start again nex, the second edition 100 days of code challenge. Rules are the same.
As we can see in above picture there is the screenshot from my GitHub account from today.
Today I have struggled with one exercise from exercism.io. In the first look exercise was very simple: ‘Write a function that greets the user by name, or by saying “Hello, World!” if no name is given. For an input of “Alice”, the response should be “Hello, Alice!”. If a name is not given, the response should be “Hello, World!”‘.
On the first look, this task was very simple. To create some function that takes some argument instance variable. Below I passed the first resolution:
def self.hello(name = "World")
@name = name
This solution is ok, but this is one little thing that can be changed to a proper more elegant solution. But first let thing what for is this line:
@name = name
This line is instance variable and becomes class variable. Is this particular line is needed? I was thinking that yes, this line is needed, for me, this notation was more readable. But I was in mistake. This piece of code is useless. I can remove this line and execution this simple program will not change. Why?
that is in:
is interpolated inside the string, to get their value and not just referenced by their name to print on the screen. To wrap variable we can use:
So there is no need to create additional value and the final program code looks as follows:
def self.hello(name = "World")
Above code looks nicer that before. But why as a developer I should use string interpolation and what for? This code is very simple and short and probably someone can say why to use this type of construction? Let’s imagine some longer string that contains more than 5 or 6, maybe 122, or more variables. What then? Probably is more convenient to use this kind of string structure to make life easier. And the second thing: for me, the syntax is more readable and of a first look, it’s easier to figure out what’s going on in the code.
For few day I was looking for some continuous integration services that will allow me to build and deploy my open source projects now and near feature. I spend several hours searching, reading, trying to use and build some code. Some CI services are for free and works very good with for example GitHub. It’s a big plus, especially when you trying to run open source.
Below I add a small table that contains some essential information for devs that are interested in that kind of services.
AppVeyor automates building, testing and deployment of .NET applications.
Reading logs during testing Android applications often force developer or tester to use appropriate tools. One of them is: Android Device Bridge. ADB comes as a part of the standard Android SDK, it provides a terminal-based interface for interacting with your devices with Android file system. Below I added some useful commands that every tester, programmer use during deal with applications every day.
– access to Android device logs, direct output to the console
adb logcat -d > [filename]
– this command allows to save logs in a file name you have specified, for example: abd logcat -d Users/user/storage
adb logcat -c - all
– logs on devices are erased, after that you are able to grab logs without unnecessary data
adb logcat -v time
– display logs with specified time
– reboot device
– ensure that there is a server running
– kill the server if it is running
adb push app /system/sd/app
– push apps from comupter onto device
– prints: offline | bootloader | device
– prints: serial-number
– continuously print device status for a specified device
– remounts the /system partition on the device read-write
adb reboot [bootloader|recovery]
– reboots the device, optionally into the bootloader or recovery program
– restarts the adbd daemon listening on TCP on the specified port
– list PIDs of processes hosting a JDWP transport
adb ppp [parameters]
– Run PPP over USB.
Note: you should not automatically start a PPP connection. refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1 [parameters] – Eg. defaultroute debug dump local notty usepeerdns
adb -s [yourdeviceserialnumberhere] shell
– above command will start an interactive shell from your machine, but running on your device
About 100 days of code first time I read on this blog. Then I start to read more, and I find John Rasing blog and Richard Littauer post on Medium. I think it’s a great idea. Basically, I need some challenge, because I a lite bit lazy in recent times and my learning and coding progress is a bit pure.
I put below screen picture from my current GitHub account:
As you can see, there is no great progress for a few days. Longest streak took 7 days, contributions in total : 99 repos.
Rules for 100 days of code are simple:
writing code every single day
all code must be written before midnight
code must be up on GitHub
written code must be useful (comments, reformatting, refactoring does not count)
written code can’t be related to work, must be created in spare time, after hours (probably during nights, a day has only 24 hours)
Personally, I think that with coding every day is like a writing every day for the professional writer, it’s a big part of his life. The same like for example skilled craftsman who sculpts something in wood, inch by inch, minute by minute, day by day …
I know that will not be easy to find a balance between work/life and side projects. Probably I will find some tools/apps to better manage my time and be more productive.
Something that I afraid is to stick with some problem to solve for a long of time and don’t have an idea to write a solution.
What I hope to achieve ? Programming becomes a daily habit and hopes to continue it as long as I can.
Starting a new project in Android Studio is a very simple task if we have an idea of course what we want to do. In this post, I will show step by step how to create a simple project using blank activity with fragment.
First, we should run AndroidStudio and then select from the main window: Start a new Android Studio project. After that, we will see a: Configure your new project window:
This window allows naming your project, select location of workspace and also set your company domain, for me company domain is: andrzejdubaj.com.
Next screen allows selecting form factors on which app will be running.
I select: Phone and Tablets, also: Minimum SDK – API 21: Android 5.0(Lollipop). Why has Android 5.0 Lollipop ? Because I have a smartphone on which I can test my app – physical device, not an emulator and second: I want to build from source Android 5.0 and run in on raspberry pi 2 or 3 version. We will see in the future.
On: Add an activity to Mobile allows selecting one from several activities with automatically add necessary file to project, for example, *.xml files. I select a blank activity. If I decided to create some localization app I will choose google maps application.
Next step takes us to: Customize the Activity. Way, I choose fragments ? Because fragments allow building an application with behaves somewhat like a nested activity that can define its own layout and manage its own lifecycle. You can read more here.
After pressing on: Finish button we will get build the layout of an application. Basic project structure with catalogs and base classes.
On this point, we can start developing the application. Writing code and add necessary files.
I always have a feeling to put down my own list of learning resources for development/ IoT / testing. It not easy 😉 But for now I publish first version of list and I will expanded this list as more interesting materials.
During launching my tests written in JUnit I notice problem with performing one of them. I received:
java.io.IOException: Cannot run program "aapt": error=20, Not a directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
In Stack Overflow I found a lot of solutions but non of them didn’t solve my problem. There’s a bug in IntelliJ IDE that points to platform-tools for executable that are in build-tools. I found my own solutions of this problem:
During a past few days I wondered over my pet project to: Daj się poznać competition. It was a very hard period of time because of number ideas coming into my mind. Some might ask why it was so hard with choose appropriate idea. The answer is simple, everything is connected with time I have and I can devote to self-development.
I figured that I create simple applications on android that allows user to control device in the form of a small greenhouse for plants. Getting data from the box of the container itself. Irrigation control and opening the upper flaps. This small greenhouse is available in many shops networks for allotment, only part with glass and frames. I can easily buy online. If I can’t buy one, which is highly unlikely, especially since it is getting closer to spring, it will build one myself. Definitely it will require few modifications, but this is to be done.
List of things to do:
rework / construction of mini greenhouses
adding sensors with microcontroller
design of irrigation systems
write applications for android
writing service for monitoring data online
invent an elegant solution to the communication of a whole greenhouse
write code which works
a little penetration testing and evil hacks – this can be fun 🙂
For sure the first part will not be made quickly, because of a several issues about whom I will try to write later, more technically.
Idea for this project it’s really related t IoT – Internet of things. I will use agile methodology to describe all steps, or steps that will appear during develop my idea project.