Wednesday, September 13, 2023

QEMU command for MacOS

 To run Qemu on mac use this command:

- Install Qemu: brew install qemu

 

to run VM:

qemu-system-x86_64 \
-m 8G \
-smp 6 \
-cdrom os_you_want_to_install.iso \
-drive file=
your_virtual_disk_here.qcow2,if=virtio \
-vga virtio \
-display default,show-cursor=on \
-usb \
-device usb-tablet \
-cpu host \
-machine type=q35,accel=hvf \
 
 😎 

 

Thursday, September 7, 2023

A small script to toggle Mute for Dwm Freebsd 13

 this is my small script just to toggle mute in mixer.

I name the script "togglevol.sh"

$>chmod +x togglevol.sh
$>sudo cp togglevol.sh /usr/bin/


and bind it with any key you want in Dwm.


#!/bin/sh


FILEPATH=~/.togglevol
CURRVOL=`mixer vol | awk '{print $NF}'`

## DEBUG
#echo "mixer vol: $CURRVOL"

if [ $CURRVOL = "0:0" ]; then
  ## return the value from file
  FILEVOL=`cat $FILEPATH`

  mixer vol $FILEVOL

else
  ## save current value to file
    echo "$CURRVOL" > $FILEPATH

    mixer vol 0:0
fi 

Tuesday, May 1, 2018

Swift: fix invalid url

Some urls contain special characters or contain arabic words and when you parse this url on swift you will get "Invalid url request" error.

to resolve this problem it very easy but i take long time with searching on google about it after if find the solution :


feed?.link.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
let url = URL(string: (feed?.link)!)



Good Luck :)

Thursday, February 22, 2018

To add new keyboard layout i3wm


To add secandary layout for i3wm it's just simple like like this to add in config file

~/.config/i3/config :
  
exec setxkbmap -layout us,ar -option grp:alt_shift_toggle

This comman is adding arabic as second layout and use same windows switch keys "ALT+SHIFT".

and this comman it's work on command line also but without exec .



Have fun :D

Monday, October 2, 2017

Which algorithms/data structures should I "recognize" and know by name?

This quote from 

https://softwareengineering.stackexchange.com


Which algorithms/data structures should I "recognize" and know by name? 



An objective response:


While my initial response to this question was based on my empirical experience as a soon-to-graduate CS student and my projected opinion of the type of people I wanted to work with in the CS field. There is actually an objective (with respect to the subjective opinions of the ACM SIGCSE and IEEE computing societies) answer. Every 10 years the ACM and the IEEEbodies cooperate on a joint publication that details suggestions for undergraduate computer science curriculum based on professional knowledge of the state of the computing industry. More information can be found at cs2013.org. The committee publishes a final report listing their curriculum recommendation.


That said, I still think my list is pretty good.


Original answer below.


What Should I Know?


Minimum


I think an adept programmer should have at least undergraduate level knowledge in Computer Science. Sure, you can be effective at many jobs with only a small subset of Computer Science because of the rock solid community CS sits upon, and the narrowed focus of most professional positions. Also, many people will further specialize after undergraduate study. However, I do not think either are an excuse to not be privy of foundational CS knowledge.


To answer the title question, here is what an undergraduate CS student (the foundation for an adept programmer) should know upon graduation:


Data Structures


Machine Data Representation

Ones, Two's Complement, and Related Arithmetic


Words, Pointers, Floating Point


Bit Access, Shifting, and Manipulation


Linked Lists


Hash Tables (maps or dictionaries)


Arrays


Trees


Stacks


Queues


Graphs


Databases


Algorithms


Sorting:

Bubble Sort (to know why it's bad)


Insertion Sort


Merge Sort


Quick Sort


Radix style sorts, Counting Sort and Bucket Sort


Heap Sort


Bogo and Quantum Sort (=


Searching:

Linear Search


Binary Search


Depth First Search


Breadth First Search


String Manipulation


Iteration


Tree Traversal


List Traversal


Hashing Functions


Concrete implementation of a Hash Table, Tree, List, Stack, Queue, Array, and Set or Collection


Scheduling Algorithms


File System Traversal and Manipulation (on the inode or equivalent level).


Design Patterns


Modularization


Factory


Builder


Singleton


Adapter


Decorator


Flyweight


Observer


Iterator


State [Machine]


Model View Controller


Threading and Parallel Programming Patterns


Paradigms


Imperative


Object Oriented


Functional


Declarative


Static and Dynamic Programming


Data Markup


Complexity Theory


Complexity Spaces


Computability


Regular, Context Free, and Universal Turing Machine complete Languages


Regular Expressions


Counting and Basic Combinatorics


Beyond


To get into what you're asking about later in your question, if you are familiar with the above, you should be easily able to identify the appropriate pattern, algorithm, and data structure for a given scenario. However, you should recognize that there is often no best solution. Sometimes you may be required to pick the lesser of two evils or even simply choose between two equally viable solutions. Because of this, you need the general knowledge to be able to defend your choice against your peers.


Here are some tips for algorithms and data structures:


Binary Search can only (and should) be used on sorted data.


Radix style sorts are awesome, but only when you have finite classes of things being sorted.


Trees are good for almost anything as are Hash Tables. The functionality of a Hash Table can be extrapolated and used to solve many problems at the cost of efficiency.


Arrays can be used to back most higher level data structures. Sometimes a "data structure" is no more than some clever math for accessing locations in an array.


The choice of language can be the difference between pulling your hair out over, or sailing through, a problem.


The ASCII table and a 128 element array form an implicit hash table (=


Regular expressions can solve a lot of problems, but they can't be used to parse HTML.


Sometimes the data structure is just as important as the algorithm.


Some of the above might seem like no brainers, and some may seem vague. If you want me to go into more detail, I can. But, my hope is when encountered with a more concrete question such as, "Design a function that counts the number of occurrences of every character in a String", you look to the tip about the ASCII table and 128 element arrays forming neat implicit hash tables for the answer.


Based off these ideas, I will propose an answer the locker problem outlined in your question.


Answer to the problem posed in your question.


This may not be the best answer to your question, but I think it's an interesting one that doesn't require anything too complex. And it will certainly beat the time complexity of using a queue, or stack which require linear time to determine whether a locker is free or not.


You have 0-999 lockers. Now, because you have a fixed number of lockers, you can easily conceive a hashing function with no collisions on the range 0-999. This function is simply h(x) = x mod 1000. Now, [conceptually] construct a hash table with integer keys and the contents of a 1000 element char array as your values. If a customer wants to reserve locker 78 for use, simply put 78 into the hash function (returning 78), and then add that number to the base pointer of the array -- storing a true value at the location pointed to by the offset value. Similarly, if you need to check whether 78 is in use, simply read the value stored at that location and check against true.


This solution operates in constant time for lookups and storage as opposed to a log(n) time storage and lookup in the case of a priority queue backed by a binary tree. The description is intentionally verbose so you can see the higher concepts being boiled down into an efficient algorithm.


Now, you might ask, what if I need to know all of the available lockers, wouldn't a priority queue be better? If there are k available lockers in the priority queue, iterating over all of them will take k steps. Further, depending on your priority queue implementation, you might have to rebuild your priority queue as you look at it all.. which would take k*log(k) : (k < 1000) steps. In the array solution, you only have to iterate of a 1000 element array and check which ones are open. You can also add an available or used list to the implementation to check in k time only.


Wednesday, June 11, 2014

How to install Hearthstone on Linux

 
How to install Hearthstone on Linux
using "Wine" and "Play on Linux"

1. Get "Play on Linux" from http://www.playonlinux.com/en/download.html

2. Launch "Play on Linux" you should be asked to install any Wine version, you should install  version "1.7.3"

3. Click "Install" and then check "Testing"

4. Search for "World of Warcraft" and wait till you see it in the list, mostly it should already be there.

5. Click "Install" then tell the wizard to use Wine 1.7.3 leave the remaining settings at default.

6. When your asked to select the install File for "World of Warcraft" just cancel the Wizard.

7. Click Install again, then select "install non-listed program".

8. On the second page of the wizard select "Edit or update an existing application", on the next window check "Show virtual drives" and select "WorldOfWarcraft".

9. Check "Configure Wine" and select the tab "Libraries" tab.

10.  type "dbghelp" in the "New override for library" field then click "Add"

11. click "Edit ..." and select "disabled", confirm this with "Ok"

12. On the next screen select "Choose another File"

13. The remaining installation is like the installation of every other Wine Software.

14. After launching Hearthstone first time you probably want to change the settings to run Hearthstone in windowed mode, otherwise you'll probably get massive graphics stuttering.
2 photos
 
reffrence: Markus Weller