Lots of people have been talking about and sharing their GitHub Profile READMEs. It was a project we launched last year and developers are loving it. As this feature became more popular, more developers were building templates, plugins, and apps for you to use on your profile.
It uses GitHub Actions to build and update a user's contribution graph, and then has a snake eat all your contributions. The output generates a gif file, that you can then show on your GitHub Profile README. I thought this was pretty cool, so I set about adding this to my profile.
The first thing you want to ensure before you start this project, is that you have GitHub Actions setup. Head to your Profile and ensure the "Actions" tab is available. Everyone should now have this feature.
Hopefully this guide was helpful for you and gives you a good base to start building and adding more Actions on your profile. What have you been adding to your GitHub Profile README? Other there other cool Actions I should be looking at?
I didn't change the background colour. It's a .png/.svg image, meaning the background is transparent. It looks dark on mine because I have dark mode enabled on GitHub. You can enable it by clicking Settings --> Appearance --> choosing your mode.
Hello everyone, before proceeding, please navigate to 'Settings -> Actions -> General -> Workflow Permissions' in your README.md file and select 'Read and Write' permissions. This is important because if you have other permissions selected, it may result in errors.
Thank you so much! I tried to change in settings 'Contribution' to 'include my private contributions' but anyway my Readme profile doesn't show My Contributions. Could you please help me with this?
github.com/BAayah/BAayah
Note that you can provide a directory as the argument to snakevizand it will launch a file browser interface from which you can selectprofiles to view or other directories to list.For example: snakeviz path/to/directory.
When used within a a Jupyter Notebook the %snakeviz magicsembed the visualization result within the notebook by default.The --new-tab or -t options can be passed to the magic to instead makeSnakeViz open in a new browser tab.Opening in a new browser tab is the default behavior when the%snakeviz magics are used outside of notebooks.
A use for this is in running Jupyter in one server, but browsing to this from another location. Typically, one does this by port forwarding using ssh, in this case one can forward thespecified port to enable snakeviz in the browser.
In the icicle visualization style functions are represented by rectangles.A root function is the top-most rectangle, with functions it calls below it,then the functions those call below them, and so on.The amount of time spent inside a function is represented by the widthof the rectangle.A rectangle that stretches across most of the visualization representsa function that is taking up most of the time of its calling function,while a skinny rectangle represents a function that is using hardlyany time at all.
In the sunburst visualization style functions are represented as arcs.A root function is a circle at the middle, with functions it calls around,then the functions those functions call, and so on.The amount of time spent inside a function is represented bythe angular extent of the arc (how far around the circle it goes).An arc that wraps most of the way around the circle represents a functionthat is taking up most of the time of its calling function, while askinny arc represents a function that is using hardly any time at all.
Placing your cursor over a rectangle or arc will highlight that functionand any other visible instances of the same function call.It will also display a list of information to the left of the sunburst.
The thing that separates Forth from most other languages is its use of thestack. In Forth, everything revolves around the stack. Any time you type anumber, it gets pushed onto the stack. If you want to add two numbers together,typing + takes the top two numbers off the stack, adds them, and putsthe result back on the stack.
Every time you type a line followed by the Enter key, the Forth interpreterexecutes that line, and appends the string ok to let you know there were noerrors. You should also notice that as you execute each line, the area at thetop fills up with numbers. That area is our visualization of the stack. Itshould look like this:
The syntax of Forth is extremely straightforward. Forth code is interpreted asa series of space-delimited words. Almost all non-whitespace characters are validin words. When the Forth interpreter reads a word, it checks to see if adefinition exists in an internal structure known as the Dictionary. If it isfound, that definition is executed. Otherwise, the word is assumed to be anumber, and it is pushed onto the stack. If the word cannot be converted to anumber, an error occurs.
Warning: A common mistake is to miss out the space before the ; word. Because Forthwords are space delimited and can contain most characters, +; is a perfectlyvalid word and is not parsed as two separate words.
Now onto the fun stuff! Forth, like most other languages, has conditionals andloops for controlling the flow of your program. To understand how they work,however, first we need to understand booleans in Forth.
fizz? checks to see if the top of the stack is divisible by 3 using 3 mod 0=. It then uses dup to duplicate this result. The top copy of the value isconsumed by if. The second copy is left on the stack and acts as the returnvalue of fizz?.
fizz-buzz? calls dup to duplicate the value on top of the stack, then callsfizz?, converting the top copy into a boolean. After this, the top of thestack consists of the original value, and the boolean returned by fizz?.swap swaps these, so the original top-of-stack value is back on top, and theboolean is underneath. Next we call buzz?, which replaces the top-of-stackvalue with a boolean flag. Now the top two values on the stack are booleansrepresenting whether the number was divisible by 3 or 5. After this, we callor to see if either of these is true, and invert to negate this value.Logically, the body of fizz-buzz? is equivalent to:
Therefore, fizz-buzz? returns a boolean indicating if the argument is notdivisible by 3 or 5, and thus should be printed. Finally, do-fizz-buzz loopsfrom 1 to 25, calling fizz-buzz? on i, and outputting i if fizz-buzz?returns true.
This example creates a memory location called numbers, and reserves three extramemory cells after this location, giving a total of four memory cells. (cellsjust multiplies by the cell-width, which is 1 in this implementation.)
Forth has a special word called key, which is used for accepting keyboard input.When the key word is executed, execution is paused until a key is pressed. Oncea key is pressed, the key code of that key is pushed onto the stack. Try out thefollowing:
Forth has another kind of loop called begin until. This works like a whileloop in C-based languages. Every time the word until is hit, the interpreterchecks to see if the top of the stack is non-zero (true). If it is, it jumpsback to the matching begin. If not, execution continues.
key waits for key input, then dup duplicates the keycode from key. Wethen use . to output the top copy of the keycode, and 32 = to check to seeif the keycode is equal to 32. If it is, we break out of the loop, otherwise weloop back to begin.
snake-x-head and snake-y-head are memory locations used to store the x andy coordinates of the head of the snake. 500 cells of memory are alloted afterthese two locations to store the coordinates of the tail of the snake.
initialize-snake sets the length variable to 4, then loops from 0 tolength + 1 filling in the starting snake positions. The snake positions arealways kept one longer than the length so we can grow the snake easily.
move-up, move-left, move-down, and move-right just add or subtract onefrom the x or y coordinate of the snake head. move-snake-head inspects thevalue of direction and calls the appropriate move-* word. This over = ifpattern is an idiomatic way of doing case statements in Forth.
move-snake-tail goes through the array of snake positions backwards, copyingeach value forward by 1 cell. This is called before we move the snake head, tomove each segment of the snake forward one space. It uses a do/+loop, avariation of a do/loop that pops the stack on every iteration and adds thatvalue to the next index, instead of incrementing by 1 each time. So 0 length @do -1 +loop loops from length to 0 in increments of -1.
change-direction takes a key and calls the appropriate turn-* word if thekey was one of the arrow keys. check-input does the work of getting the lastkey from the last-key pseudo-variable, calling change-direction, then settinglast-key to 0 to indicate that the most recent keypress has been dealt with.
move-apple erases the current apple (using draw-white) then creates a newpair of x/y coordinates for the apple using random-position twice. Finally,it calls set-apple-position to move the apple to the new coordinates.
draw-snake loops through each cell in the snake arrays, drawing a black pixelfor each one. After that it draws a white pixel at an offset of length. Thelast part of the tail is at length - 1 into the array so length holds theprevious last tail segment.
The begin/until loop uses the boolean returned by check-collision to seewhether to continue looping or to exit the loop. When the loop is exited thestring "Game Over" is printed. We use 100 sleep to pause for 100 ms everyiteration, making the game run at rougly 10 fps.
Set snake=True if your positions are reproduciblemoving from either direction. This will not necessarilydecrease the number of traversals required to reach convergence.Snake motion reduces the total time spent on motionto reset the positioner. For some positioners, such asthose with hysteresis, snake scanning may not be appropriate.For such positioners, always approach the positions from thesame direction.
c80f0f1006