Category: Uncategorized

  • From Lines to Neurons

    From Lines to Neurons

    A statement that has been circulating on Twitter recently:

    “Thinking can be outsourced. Understanding cannot.”

    An understanding of Engineering fundamentals will remain valuable, even as LLMs’ growing ability to generate plausible code and text.

    Start with linear regression

    Neural networks approximate functions.

    Linear regression is the simplest mathematical approach to achieve the same. A cloud of points and an infinite number of lines. What is the best-fitting line among them? The one where the distance between its predictions and the actual points is minimum.

    That distance has a name: the loss. Linear regression fits the line by minimizing it. Pick weights → measure the loss → adjust → repeat.

    Neural networks build on the same concept.

    A neuron is just a line, bent

    Linear regression can only fit straight lines. Real data isn’t straight.

    A neuron takes w · x + b and runs the result through a curved function (a sigmoid). That single bend is the entire upgrade. Now you can fit S-curves. Stack two neurons and you can fit bumps. Stack thousands across many layers and you can fit anything.

    The training algorithm is the same as linear regression: gradient descent. The only addition is backpropagation — the chain rule from calculus, applied backwards to figure out how each weight contributes to the loss.

    Scale this up

    Stack thousands of these neurons. Add an attention mechanism so each neuron dynamically picks which inputs from the previous layer to care about. Train on the internet.

    You get GPT. We will dive deeper into that in my next post.


    Full interactive guide with the live code and a training playground:

    Neural Networks: From Lines to Neurons

  • Is Software Solved?

    Is Software Solved?

    In 2011, Marc Andreessen declared that software is eating the world. Fifteen years later, the question has flipped: something is eating software itself, and that something is AI.

    Writing code has become too cheap; this is a fact. Code is a formal language, and LLMs — since the 2017 “Attention Is All You Need” paper — have learned the whole internet by heart. They can dream text, which sounds convincing and is not wrong in most cases, and they can speak multiple languages.

    I, a PM who hadn’t written real code for years, worked through the last few months on 4 projects at different complexity levels. 2 of them were within my company, and one is running just fine in the production pipeline.

    The demand for code is clearly going up, and economics tells us why. When a good becomes cheaper, demand for it increases. As an analogy: cameras got radically cheaper and better; everyone has one; photos are infinite and near-free. People are still buying more cameras and taking more photos — and good photographers are more valuable than ever.

    Software ≠ Code. Software is a solution that runs on a computer; this solution needs to have a purpose. Identifying the purpose is hard; often, neither the customer nor the dev teams know what to build. Along the way, frameworks and best practices were developed to define clearly and, most importantly, align on what to build.

    The solution then needs to be coded in a way that the computer understands; it can be done in spaghetti style or using clean code. In both cases, the solution will serve its purpose, but in the former case, it will fail the test of time quickly, depending on how bad the code is. Smart engineers spent decades inventing ways to make solutions maintainable: testing, design patterns, static code analysis — you name it.

    All those activities and artifacts are complementary to the code; code cannot live in a vacuum. To have meaningful software, they are needed as well. They didn’t get cheaper, though. Copilot won’t help you build the right thing faster. On the contrary, it helps you build many wrong things faster. Call it a diversion, or call it fast prototyping.

    Those complements will become more expensive in my opinion, or at least economic theory tells us so. If there is a huge demand for cars in one city, tires become more expensive, not cheaper. Morgan Stanley analysts recently made a similar point: as code generation gets cheap, the scarce inputs shift elsewhere — to data, to judgment, to the specification of what is actually worth building.

    We are in the middle of the euphoria and shock, still wrapping our heads around how the computer can one-shot code that used to take weeks to write. But that’s not software development. The craft still matters, and will matter even more.

  • Stop the Massacre !

    Stop the Massacre !

    Translation:
    My father Nasri Alnaouq, My brothers Mohamed and Mahmoud, My sisters Walaa , Aalaa and Aya, My nephews and nieces Bakr, Basma, Amr, Raghda, Islam, Sara, Abdallah, Islam, Dima, Tala, Nour, Nesma, Tamim, Malak and others, and before them my brother Ayman and my mother Basma … may you all rest in peace !

  • How to run yocto qemux86-64 image with HVF acceleration and SSH access on MacOS

    qemu-system-x86_64 \
    -kernel bzImage–5.15.96+git0+509f4b9d68_001e2930e6-r0-qemux86-64-20230327112333.bin \
    -enable-kvm \
    -machine q35,accel=hvf \
    -device virtio-net-pci,netdev=net0 \
    -netdev user,id=net0,hostfwd=tcp::5555-:22,net=192.168.7.0/24,host=192.168.7.1,dhcpstart=192.168.7.2 \
    -drive file=core-image-minimal-qemux86-64-20230327162556.rootfs.ext4,if=virtio,format=raw \
    -append "root=/dev/vda console=ttyS0 ip=dhcp" \
    -serial stdio \
    -m 2048M
    view raw qemu-macos hosted with ❤ by GitHub

    -kernel , -drive should be populated with build artifacts

    -accel=hvf enables hardware acceleration for faster execution of QEMU

    -hostfwd=tcp::5555-:22 forward guest port 22 to host 5555

    Then it shall be possible to SSH to qemu using

    ssh -p 5555 root@localhost

    To copy a file

    scp  -P 5555 root@localhost:/path/to/src/file /path/to/destination/file
  • How to downgrade Rust compiler to a specific version ?

    How to downgrade Rust compiler to a specific version ?

    Hi !

    There are a couple of pages/stackoverflow questions which mention how to install a specific Rust version which is pretty straightforward using rustup install command

    abdelah@abdelah-VirtualBox:~/workspace/linux$ rustup install 1.62.0
    info: syncing channel updates for '1.62.0-x86_64-unknown-linux-gnu'
    info: latest update on 2022-06-30, rust version 1.62.0 (a8314ef7d 2022-06-27)
    ....

    However, there is one tiny step also needed to set the default compiler to the newly installed version, for instance if you run the command above and invoke rustc --version you would still get the previously installed default version.

    abdelah@abdelah-VirtualBox:~/workspace/linux$ rustc --version
    rustc 1.66.1 (90743e729 2023-01-10)

    I am pretty new to Rust ( haven’t read the hello world example fully yet to be honest ), but I already like how the commands come intuitively to mind opposed to other popular tools such as git (always scratched my head trying variants of git checkout and git reset to clean a working directory )

    So, back to topic. Now we need to set the default compiler version to 1.62.0, for that we just need to execute rustup deault my-preferred-version but first we can get the list of installed versions like this

    abdelah@abdelah-VirtualBox:~/workspace/linux$ rustup toolchain list
    stable-x86_64-unknown-linux-gnu (default)
    1.62.0-x86_64-unknown-linux-gnu

    Then set the default version

    abdelah@abdelah-VirtualBox:~/workspace/linux$ rustup default 1.62.0-x86_64-unknown-linux-gnu
    info: using existing install for '1.62.0-x86_64-unknown-linux-gnu'
    info: default toolchain set to '1.62.0-x86_64-unknown-linux-gnu'
    
      1.62.0-x86_64-unknown-linux-gnu unchanged - rustc 1.62.0 (a8314ef7d 2022-06-27)

    Now, let’s do a smoke test on the compiler version

    abdelah@abdelah-VirtualBox:~/workspace/linux$ rustc --version
    rustc 1.62.0 (a8314ef7d 2022-06-27)

    Okay, this works now !

    You might be wondering what would be a usecase for using a specific older compiler version, well my answer to this would be this snippet from Rust documentation in the Linux kernel

    rustc
    *****
    
    A particular version of the Rust compiler is required. Newer versions may or may not work because, for the moment, the kernel depends on some unstable
    Rust features.
    

    Starting Linux kernel release v6.1, Rust support was introduced and this grabbed my attention as Rust is claimed to be safer and more secure than C/C++. Safety and Security are two words that one would hear everyday if you work at any company producing or contributing to the production of passenger cars.

    I wanted to have a look and play around a bit and then to test if my environment is ready to build Rust in the kernel

    abdelah@abdelah-VirtualBox:~/workspace/linux$ make LLVM=1 rustavailable
    ***
    *** Rust compiler 'rustc' is too new. This may or may not work.
    ***   Your version:     1.66.1
    ***   Expected version: 1.62.0
    ***
    Rust is available!

    And because I wouldn’t take may or may not work as an answer, I downgraded my compiler version.

  • Wöchentlich Trends aus Nahost #1: Ryan

    Eine Zeichnung aus Tebessa, eine algerische Provinz, von dem verstorben Kind: Ryan

    ريان: الحزن يخيم على مواقع التواصل الاجتماعي بعد وفاة الطفل المغربي

    Ryan : Trauer auf die sozial Medien nach dem Tod des marokkanischen Kindes.

    تحولت مواقع التواصل الاجتماعي إلى دفتر عزاء مفتوح، بعد وفاة الطفل المغربي ريان الذي أثارت قصته المأساوية اهتمام الكثيرين في العالم العربي ودول أخرى.

    Die sozial Medien Seiten hat sich in ein Kondolenzbuch verwandelt, nachdem Ryan gestorben ist , der für seine Geschichte vielen in der araber Welt und andere Länder sich interessiert habe

    ووسط فرحة لم تكتمل، تمكنت فرق الإنقاذ المغربية، مساء أمس السبت، من الوصول إلى عمق البئر التي ظل ريان عالقا فيها خمسة أيام.

    Inmitten einer unerfüllten Freude , konnte die marokkanische Rettungsteams am Samstag Abend , zu Brunnen tief erreichen, die ryan hat für 5 Tagen geblieben

  • عن سد النهضة

    اسمحولي اخرج عن السياق الحالي و اﻷجواء الرمضانية و أزمة #الكورونا و أعيد نشر ملف عن نهر #النيل و #سد_النهضة كانت أعدته الجزيرة في واحدة من حسناتها القليلة جدا بالتزامن مع اعلان اثيوبيا أنها هتبدأ هتملى السد في شهر يوليو.

    https://www.aljazeera.net/nile/

    للأسف السيناريو المطروح حالياً لملأ السد في خلال ٣ سنوات هو الأقصى ضرراً بالمقابل الطرح الأصلي المفاوض المصري كان إتمام الملأ في ١٥ سنة. تقدير الأضرار مختلف لكن من المؤكد أنه هيكون في تأثير كبير على ملايين المزارعين و الأراضي الزراعية و نصيب مصر من المياة.

    الرأي العام في اثيوبيا يبدو أنه متوحد بالنظر إلى وسائل التواصل الإجتماعي ده غير إن السد تم تمويله شعبيا من خلال سندات حكومية و بالتالي المواطن الإثيوبي مستثمر بماله الشخصي في بناء السد بينما على الجانب الآخر المصريين بين حالة انقسام أو لا مبالاة.

    لو السد بدأ يتملي في يوليو الخيارات اللي قدام الحكومة المصرية هتكون محدودة جداً بين خيارين لا تالت لهم توجيه ضربة عسكرية أو الرضا بالأمر الواقع و اتخاذ إجراءات تانية لمواجهة الإنخفاض اللي هيحصل في منسوب نهر #النيل

    خليني أعمل نشر لملف اخر أعدته صحيفة النيويورك تايمز عن نفس اﻷزمة

    بقالنا سنة للأسف من البوست ده و الوضع أصبح أسوأ
    #سد_النهضة

    مقالة أنا كاتبها على مدونتي الشخصية من ٧ سنوات وقت ما كان #سد_النهضة في مرحلة الإنشاء بنسبة ٣٠٪ فقط و كنت عامل حسبة بسيطة إن لو السد اتملى في ٥ سنوات هنخسر ٢٥٪ من نصيبنا المياة السنوي و دي هتكون كارثة بكل المقاييس و تشريد أسر كتير و خسارة فدادين أراضي زراعية لا تعوض

    و مازالت الأزمة للأسف مستمرة و كل الحلول الدبلوماسية ( حتى الآن) ما حققتش أي تقدم في أزمة #سد_النهضة_الإثيوبي

    رابط المقالة عن #GERD من ٢٠١٤

    Originally tweeted by Ahmed abdelfattah (@aabfattah) on May 12, 2020.

  • The Traveler Guide to Shanghai

    The Traveler Guide to Shanghai

    Are you staying in Shanghai for a while? Wondering about what to eat and trying to Google it out? To be honest, you will probably get much better results if you know some Chinese using Baidu search. If not, then you are stuck with me here in this blog but I will be try to be as helpful as possible.

    I would like to begin with the fact that I liked Shanghai a lot. It’s really a clean, organized , has an amazing public transportation network and plenty of food places. If you are not really into Asian then you still have plenty of international options. Many people can speak English or at least a few words, the rest usually is smart enough to understand what I want using some body language.

    This guide is intended to pass over my experience to people who are intending to stay in Shanghai for a couple of months or more. It’s not targeting tourists but it could help anyway.

    Essential Mobile Apps

    I think before everything it’s essential to prepare some apps on your mobile, otherwise it would be more difficult to survive even when some of these apps are completely in Chinese they will still prove to be useful in some situations.

    wechat

    WeChat  [English/Chinese]

    I would say WeChat is the most important app in China, it’s much more than chat, it’s like a combination of WhatsApp, Facebook, Apple Pay and it’s also used in business frequently. For the Chinese people it’s pretty normal that your co-worker or boss asks for your WeChat id to call you for work purposes or even pass you business information through it and expects the same from you, additionally all your new Chinese friends will be on WeChat and you don’t want to miss that and on top of all that you can use it to pay nearly anywhere even at the small fruit shop around the corner.

    Alipay logo

    Alipay [English/Chinese]

    It’s the same here, it’s just not your standard mobile payments application. Maybe because Chinese like to have many functionalities on a single platform. Some additional features that I used on Alipay:

    • Paying utilities bills: Basically you need to enter your subscription number which should be written on the bill (a friend can help you to locate it) and you will be able to pay your bills with one click. Extremely efficient.
    • Renting a bike: The usual drill, scan, unlock and pay.
    • Top up: for Chinese mobile phone numbers.
    • There are more features like booking trains, flights or even movie tickets but I didn’t really explore them.

    This leads us to a crucial point which is how to activate the mobile payment feature on Alipay or WeChat? From my experience your normal credit or debit card won’t really work but adding a Chinese debit card should be straight forward. However, you need of course to open a bank account which should take a couple of hours depending on your visa type. If you have a long stay visa it should be possible but if you are on a category M visa only 2 banks as far as I know might agree to open an account for you: Eventbrite and Shanghai bank. You will also need a letter from the Chinese entity that you are working with them locally.

    VPN

    Google, Facebook, WhatsApp. Youtube .. and many other western world services are blocked or very slow therefore you will probably need a paid VPN service to be really able to use these services reliably (to contact your family for example). And don’t forget to figure out this before landing in the airport, once you are in China it will be a very difficult job to obtain a VPN solution.

    I tested around 4-5 solutions and concluded that the most reliable ones are:

    • Ladder VPN; Cheap, mobile only, speed is ok.
    • Express VPN: Expensive, mobile and PC, speed is very good, however it’s popular and probably known to the Chinese government so it’s possible that it gets blocked for a few hours/days then returns back up.

    I would recommend that you have at least 2 solutions. If you are on a work assignment then probably your company’s VPN should be a feasible resort.

    440px-AutoNaviLogo

    Amap  [Chinese]

    Google maps are not really helpful in China, they don’t have a lot of data. And won’t help you in finding the correct transportation. On the other hand Amap has accurate maps with extensive details. There are two tricks to use it if you don’t know any Chinese:

    • Try to search with English names or addresses, it will mostly work.
    • If you know a close metro station to where you are going you can also type it in English. This will definitely work.

    Now, you were able to locate where are you going and have all the alternative routes listed on the app screen but unfortunately everything is in Chinese. There will be no problem reading the metro/bus line number and the poor man solution to read the destination station name (or at least what I used to do) is to look into the map in the station before you hop into the carriage and try to compare the Chinese text character by character, it might sound weird but it will eventually work because inside the metro station there are alternate English/Chinese texts on every sign. It’s really clear once you get used to it but you might to need to do this matching a few times in the beginning.

    Trip.com

    If you are willing to travel, this website will help you to book train and flight tickets. It has also a wider selection of hotels in China compared to Booking.

    A tip regarding purchased train tickets through the app: You will need to give yourself some lead time to go to the ticket office before your trip to get printed tickets.

    Microsoft Translator  [English]

    This one saved me a lot. If at some point you need to say or understand more than your usual little dictionary of Chinese words then this app will definitely come in handy. The most useful feature is the voice translation mode where it splits the screen into 2 halves, the first half has a mic icon that listens to Chinese and translates to English while the icon on the second screen half does the inverse. It works well on most of the cases and was really useful on many situations.

    Didi  [English]

    Equivalent to Uber

    Note: It’s not on the play store.

    Ele.me_logo

    Ele.me [Chinese]

    Food delivery is very popular here, you will find motor bikes rushing everywhere on the streets to deliver food somewhere. It’s also in Chinese but you can search in English for some kinds of food like pizza or burger and select food based on the pictures, making the order and paying via AliPay or WeChat shouldn’t be a problem. An important hint is that you need when setting up the app some help from your Chinese friend to type in your address very accurately in Chinese. When the driver arrives you will get a call from him and because you don’t know any Chinese and he won’t probably know any English you better show up quickly at your doorstep or in front of the building to receive your food.

    Youku [Chinese]

    It’s the YouTube + Netflix + Sports streaming of China. There are some free movies but the latest ones will be watch-on-demand. You can buy a ticket for a movie by scanning a code using AliPay or WeChat. It also has very nice sport content as I was able to watch some free premier league matches, the important matches are watch-on-demand though.

    Money

    China is in my opinion at a point beyond the cashless society, mobile payments are dominant nearly everywhere. If you were able to activate any of WeChat or AliPay wallets then you are already in a very good position, however cash of course still works.

    I don’t recommend exchanging money in the airport except maybe a very little amount for the taxi. (beware of scams and don’t go with anyone, just outside the airport you will find an organized line of metered cabs with well-defined tariffs and will also give you an invoice)

    Back to our topic about obtaining Yuans or RMBs (the 2 names are equivalent but the later is used more) it really depends on where do you come from and how much fees your bank will charge you. MasterCard and VISA cards should work normally and there are many ATMs everywhere but maybe not all of them will work with your particular card so you need to try different banks. All ATMs I used supported English and Chinese. In my case my I could use my MasterCard to withdraw RMBs from my Euro account at the market rate with a 1.7% fee. Your bank may give you a better or worse deal. I would then take the cash and deposit it into my Chinese bank account. In China the ATMs that support depositing money are called CDSs.

    Food

    Enjoy trying all sort of Chinese local recipes especially the roasted duck but if you are longing for something that you would find home, there are many alternatives.

    • Pizzahut, McDonald’s, KFC and all your lovely junk food is available nearly around each corner. I have seen more KFCs than any city I have been to.
    • The Habit Burger and Grill: Very good burgers and a great variety of tasty salads (Grilled chicken salad, Cesar salad, chicken BBQ Salad). I have eaten too much salads from this place to the extent that most of the staff recognizes me when I enter the place.
    • The blue frog bar and grill: Steaks and burgers
    • Eli Falafel (Halal): Lebanese, near People’s square, it’s on Google maps
    • Brothers Kebab (Halal): Shawrama and Koshari, many branches around the city.
    • City Center Super market: The concept of a large super market isn’t prominent here, instead there are small shops everywhere. This was the only place that actually looked like a conventional super market. It has many branches and recognizable food brands but they are overpriced because this place isn’t targeting the ordinary Chinese.

      IMG_20190813_195301.jpg
      Crazy prices for diary products.
    • Carefourr Easy Market: there are plenty of branches around the city with various sizes.

    Transportation

    I have already blabbed a lot about the metro. It’s really clean, clear, convenient,  inexpensive (3 RMBs for a short trip, more for longer) and almost covers the whole city. I would suggest that you buy the metro card, charge it from the vending machines (have English support) instead of buying a ticket each time. There is also a mobile version but I just used the card. The electronic gate will show you your current credit at entry and credit after deduction at exit.

    Buses are also OK and extremely cheap (1 RMB) but you need to have a better Chinese because unlike the metro there are no English signs.

    You can use the same card for public Ferris crossing the bund and also the maglev train to the airport. (a one way ticket costs 50 RMBs)

    Moving your legs

    IMG_20190623_183458
    View from Jin Mao building, 88th floor observation deck. 

    Sadly there isn’t a lot of green areas in the city. It needs really a big park to allow people to breathe some fresh air. Still there are a couple of places to move your legs. If you are in a shopping mode walk the Nanjing pedestrian street near the people’s square, it’s very vibrant and has a lot of shops. Yuyuan market is also very nice.

    IMG_20190629_191439.jpg
    Yuyuan market.

     

    There are tons of malls with all the well known western brands, consumerism at its best here.

    My favorite walk was over the bund and in the financial district (near the fork tower). There are 2 sides of the bund, one is not very clean and usually crowded but If you took the ferry to the other side (only for 1 RMB) there is a much better walking lane for pedestrians and cyclists. There is a couple of good restaurants by the river too.

    IMG_20190406_173318.jpg
    Walking the bund.

    Mosques

    IMG_20190329_122659.jpg
    Huxi mosque from inside.

    If you type in the word mosque into the Amap app you will basically find 3 main mosques in Shanghai. I only went to Huxi mosque near Changshou Road station on line 13 for Friday prayers. The prayer speech is mostly in Chinese with few Arabic sections. It’s very clean and well maintained and there is a halal meat shop just beside this mosque if you are planning to cook.

    If you are not a Muslim I would still highly recommend to visit the street food market there. It’s open every Friday. There are plenty of delicious kebabs, skewers, sweets and fruits. Really cool.

     

    That’s all. I hope that you enjoy your trip to China and explore more cities.

     

  • It Begins ..

    I have been aspiring to improve my writing skills and vocabulary since a while ago but never really took any steps towards this goal. I think if you need to achieve something you need to do it , so I will define a goal for myself to write a biweekly 250 words essay.

    This means by the end of this year I should have published 14 short articles (not counting this one)

    A simple structure will suffice for a 250 words essay , it will be composed of :

    • Interesting Introduction
    • Body
    • Conclusion

    And a simple methodology will do too

    • Choose a topic
    • Research
    • Write ( Learn some new vocabulary in the process)
    • Proof read
    • Publish !

    Having defined a SMART objective and a lucid approach to accomplish it , see you after 2 weeks then !

  • Have you ever felt really stupid for saying something ?


    Yes you did. Probably many times too.

    Unless you don’t care that much which is a blessing or Unless you are like me , I follow a golden rule that never failed me even once but on the contrary breaking this rule has always led to dissapointments, work problems , enemies created , people getting hurt .. and the list goes on. This stay-safe rule is really simple : ” In any situation that you are given the option to talk or stay silent. Be silent ” .This wise tactic works like magic because the more you talk the more you make mistakes and by losing your mystery and showing your vulnerability you lose your upper hand.

    But lately in a clear sky night I thought : this is contradictory to another rule that also worked very well for me which is ” We only regret things that we didn’t do , not the things we have done ” So isn’t saying/not saying is equivalent to doing/ not doing . How can 2 right things be inconsistent ?! this is impossible .

    Through the past few days I was having a debate with myself. Will one regret not saying things or regret saying them ? Is saying wrong things or things that make you feel stupid afterwords is an inveitable part of the learning process or it’s just an avoidable mistake that you could have skipped if you just stayed silent . Isn’t being vulnerable just a part of being human ?

    That’s something to think of.