Una is one of my favorite front-end developers to listen to. This is a great talk about using CSS to achieve some of things that were traditionally done with Photoshop! Nifty :o)
Misplaced Lens Cap
sheepfilms

roma★

★
h
One Nice Bug Per Day

Kaledo Art

oozey mess

pixel skylines
PUT YOUR BEARD IN MY MOUTH

ellievsbear
Xuebing Du

izzy's playlists!

⁂
Stranger Things
hello vonnie

Andulka
No title available

No title available

No title available
seen from Russia

seen from United Kingdom
seen from United Kingdom

seen from T1
seen from Germany
seen from United States

seen from United States
seen from France
seen from Italy

seen from United States

seen from T1
seen from United States

seen from Mexico

seen from Germany
seen from United Kingdom

seen from Spain

seen from Türkiye

seen from United States
seen from Germany
seen from Poland
@data-pup
Una is one of my favorite front-end developers to listen to. This is a great talk about using CSS to achieve some of things that were traditionally done with Photoshop! Nifty :o)
Posting this for my own reference. This covers searching across arrays containing differently typed elements, and working with stack data structures in C.
An interesting piece of code from this was a generic wrapper for the standard library’s strcmp(char*,char*) method, as follows:
int StrCmp( void* vp1, void* vp2)
{
char* cp1 = *(char **)vp1;
char* cp2 = *(char **)vp2;
return strcmp(cp1, cp2);
}
The dereference of a casted parameter there is interesting! Two void pointers are given, casted into C-string pointers, and dereferenced into char* variables that are passed into the standard library strcmp function. Neat!
Another cool rule of thumb, he notes that we should prefer to jump from void pointers to a typed pointer so that the code is readable. There are alternative implementations that could use pure void pointers, but the code would be ambiguous and hard for other developers to understand.
Misc. .NET Core Build/Packaging Notes
/* Disclaimer: This is a set of miscellaneous notes/documentation excerpts, compiled while learning more about the architectural structure of .NET Core. */
I’m still mourning the loss of project.json files tbh, but lately I’ve been progressing beyond acceptance and learning to enjoy MSBuild. It’s a mature build system, and XML isn’t so bad really.
One thing that really confused me initially when working with the 2.0 preview was the distinction between framework versions i.e. .NET Framework 4.6, and standard versions such as netstandard1.6. This led to a warning message when getting a test bench running, and it wasn’t something I really quite understood right away.
So, I needed to do some research to answer a few questions:
What is a Framework? How are different versions different?
What is a Standard? How are these versioned?
“Frameworks define the objects, methods, and tools that you use to create apps and libraries.” [2]
So, previous .NET Framework versions were primarily intended for execution on a Windows machine, while versions of .NET Core can be executed on different platforms.
It is important to understand that .NET Core is described both as a framework and a platform. What that means is that a .NET Core version defines objects following a versioned API specification, and executes code using the Common-Language Runtime (CLR).
“When you target a framework or target several of them, you've decided which sets of APIs and which versions of those APIs you'd like to use.” [2]
Here is an important note, and we’ll tie it into a different point from the NuGet documentation: NuGet uses frameworks to check that your project dependencies include code that is appropriate for your target framework.
“.NET Core is a platform made of NuGet packages.“ [1]
So, different framework versions expose API’s that help you build applications that will execute code in the CLR. Different frameworks target different platforms, and naming conventions for placing this in your .csproj file can be found here.
A .NET Standard is a formal specification that defines base class libraries and their API’s in the .NET runtime. This allows libraries to be portable! Now, remember that point up above about .NET Core being a platform of NuGet packages checked against a target API version.
NuGet ‘Metapackages’ are collections of packages that have a certain meaning. This means that your XML file can look like this:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netstandard1.6</TargetFramework> </PropertyGroup> </Project>
Because of this, .NET Standard is package-based framework containing the standard library. Lower versions of the standard contain a smaller subset of the API, but are portable across a larger number of platforms. Higher versions contain a larger standard library API, and can target newer frameworks such as Core.
That about does it for now. Let me know if I missed anything, these are notes after all!
References:
https://docs.microsoft.com/en-us/dotnet/core/packages
https://docs.microsoft.com/en-us/dotnet/standard/frameworks
https://docs.microsoft.com/en-us/dotnet/standard/framework-libraries
https://docs.microsoft.com/en-us/dotnet/standard/base-types/common-type-system
Polymorphism Review Pt. II:
Let’s continue where we left off last time, and talk about polymorphism in more depth. I dug through some different definitions online and enjoyed this one the most, via MSDN:
Polymorphism is a Greek word that means "many-shaped" and it has two distinct aspects:
At run time, objects of a derived class may be treated as objects of a base class in places such as method parameters and collections or arrays. When this occurs, the object's declared type is no longer identical to its run-time type.
Base classes may define and implement virtual methods, and derived classes can override them, which means they provide their own definition and implementation. At run-time, when client code calls the method, the CLR looks up the run-time type of the object, and invokes that override of the virtual method. Thus in your source code you can call a method on a base class, and cause a derived class's version of the method to be executed.
[Source: https://docs.microsoft.com/en-us/dotnet/articles/csharp/programming-guide/classes-and-structs/polymorphism] (Emphasis my own)
So in a certain sense, inheritance is a means to an end. While inheritance is certainly useful in its own right, we also use inheritance to implement certain types of polymorphism. The ability to work with different types of objects in one collection is tremendous useful!
You might have picked on the repetition on the words “at run-time” while reading both the documentation and this post, which is a very important bit of foreshadowing! However, this is something that occurs at runtime, because of some logistics with regards to how pointers work. As noted in the first bullet, treating a derived class as an instance of a base class means that there it is actually a different type at run-time. In the other case (virtual methods), the override also occurs via a run-time lookup.
Tomorrow, (it’s been a busy week!) I’m going to try and run through an example of overriding methods. We’ll figure out how to invoke different derived classes’ versions of a method within a single collection. With love, :wq
:)
Polymorphism Review Pt. I
I’ve been dabbling in some old C++ texts for review, so let’s talk about polymorphism! I’m planning to do this in three parts: First we’ll do some quick review on inheritance and polymorphism. That will be followed by a brief introduction to template classes. Finally, we will consider the differences between inheritance and templating, and how it can even affect compilation. So without further ado..
Inheritance && Polymorphism (A Very Brief Review)
This will by no means be a comprehensive review of inheritance or polymorphism, but let’s define what these words mean, and why these abstractions are useful when designing software.
Inheritance is the mechanism by which we can expand upon existing classes. When we define a new class, we can allow it to inherit public member variables and methods from existing classes. There is a little more to it than that, (protected variables come to mind) but the basic idea is that this allows for reuse of code and modularization.
Here is a little example of two classes. The second class (Manager) inherits publicly from the Employee class. Because of the methods attempts to reference a private member variable in the base class, a compilation error occurs.
So, inheritance is a nice tool for reusing code, splitting separations of concern, and so forth. How does this end up connecting to polymorphism? Let’s imagine I have a collection of Manager objects. They could be in an array, a dictionary, a linked list, whatever. But what if in some cases, I need to put an Employee object in that array? The compiler will be having none of that!
Enter polymorphism! By using a polymorphic vector, we can place all of the elements into a single collection. In C++, we’ll need to use pointers in order to accomplish this. Memory addresses will be same size, even if the objects they point to might not be the same size!
Next Time
Next, I’ll cover polymorphism and template classes in further detail. Once that’s through, we’ll examine template classes as an alternative, and talk about why this can improve performance. That’s the stuff I really want to get to, but reviewing inheritance today was a lot of fun, so I think I’ll keep posting some short notes like these on my way to the more complex topics.
Credit: Big C++, 2nd Ed. Horstmann & Budd
MIT’s open courseware is fantastic. I’d especially recommend the lectures from this class. The material is not as directly related to engineering as other courses in the material MIT has open sourced, but let me sell you on why this is worth your time:
Marvin Minsky was a pioneer of artificial intelligence. What was special about Marvin is that he was intelligent in a way that was broad, without sacrificing depth. Without ever talking over you, he could accessibly weave together such seemingly disparate concepts as the invention of the telescope, MacBook power cables, binary search trees, and the meaning of love. This wasn’t to demonstrate his own competence, but his genuine manner of providing evidence in support of an overarching point.
This entire class fucking rules. The fact that you can sit on your couch at home, right now, and listen to hours and hours of lectures from a pioneer of artificial intelligence discussing his understanding of cognitive science? That’s why large organizations embracing open source is legitimately impactful, y’all.
“What’s the difference between an artist and an engineer? [...] I don’t see any difference between artists and engineers, except that artists have more problems to solve than they could possibly solve. An engineer is told what problem they must solve. [...] To me the artists and the engineers are doing almost the exact same thing. [...] So, I don’t see much difference between the arts and the sciences. Of course the great moments are when you run into [an artist] who has an idea that requires a new technical innovation. [...] It becomes hard to separate them.”
Fixing Electron Application Update Issues on OS X
I’ve been dealing with a problem involving updates for Visual Studio Code for a little while, and I figured that it may be worth documenting how the issue was solved.
The problem: Whenever I updated VS Code, the application would close, and reopen in the same version that I had been using previously. This was certainly a little confounding, but I was sure that this was occurring because of the difference in the workbench theming API for my settings.json file (seen in Figure 1). If these calls to the newly released API were not firing correctly, it meant that it was still running in the previous version that used the experimental theming API.
This was how I was able to clearly discern whether the update had worked, but this is usually performed by clicking the “About VS Code” item in the menu. So, how was I able to fix it? Nothing magic, just a little Github issue digging, and it turns out to be a pretty simple issue to fix!
(Figure 1: Example of workbench theming in settings.json, announced as ready for authors in v1.12 April 2017.)
There’s a lengthy thread about this issue on the VS Code repository, but I’ll save you some time and say ‘this is the recommended solution provided by contributors to the project.’ In short, this isn’t an issue specific to VS Code, and similar problems have been noted for other Electron applications running on OS X such as Atom.
(Figure 2: Recommended solution, https://github.com/Microsoft/vscode/issues/7426#issuecomment-277737150)
Below is what the permissions and ownership settings looked like in the ShipIt log directory. Notice how the .log files are owned by root! This ends up causing an issue when Electron attempts to update, preventing the application from updating correctly. There was some speculation that this is caused by launching Code using sudo. (Can’t confirm that, but certainly interesting info!)
(Figure 3: Original state of ShipIt log directory)
sudo chown $USER ~/Library/Caches/com.microsoft.VSCode.ShipIt/* xattr -dr com.apple.quarantine /Applications/Visual\ Studio\ Code.app
(Figure 4: Recommended solution to VS Code update failures on OS X)
So what do those two commands Figure 2 do? The chown command is changing the owner of each of the files in that directory, to the current user. Simple enough! That xattr command looks strange however, what’s that?
You can use ‘man xattr’ to pull up the man page on this tool. To briefly summarize, the second command displays and edits extended attributes. The command given will recursively delete the ‘com.apple.quarantine’ extended attribute from all files within the given directory.
(Figure 5: Final state of ShipIt log directory)
After running this, my settings.json was responding correctly and my theme worked! Hopefully this helped! If you are experiencing a similar issue & the solution listed above did not work, I recommend filing an issue on the VS Code repository here: https://github.com/Microsoft/vscode/issues/
This is a great dive into authentication in .NET Core, worth watching :)
VS Code’s March update included some new theming features available for use in settings.json. This is so, so, so appreciated! There are still some color choices that I’m playing with (supporting multiple languages with a theme is hard!) but I’m loving the new workbench theming. It’s helped me build a Visual Studio theme for sensitive eyes that is also cute!
Note: The workbench theming API is still under development as of the time of this writing, and as a result I can’t share the source for this yet. Intellisense will guide you!
Differences in Unix/PowerShell Command Pipelines
Intro
Hello again! It’s me, your friendly neighborhood PowerShell user with a little deep-dive into the differences in pipelining between traditional *nix shells like Zsh or the Bourne-Again Shell, and PowerShell.
We’ll cover some little examples of pipelines in Zsh and PowerShell, demonstrating what each shell’s strengths and weaknesses are, and close with a neat little example showing differences in the order of operations when using I/O redirection.
Example (Zsh):
For this example, I’m going to show how the ‘git status’ command’s “--porcelain” flag can be useful for documenting changes made to a version control repository. The porcelain flag provides the output of the command in a simplified format designed to be used for scripting.
I created an example directory structure containing text and markdown files, with two subdirectories. Here is the structure of the example directory, shown using the tree command.
(Figure 1)
Next, we can see what the output of the standard status command is. The extra information provided is very helpful to a human user, but this output is not formatted in a way that can be easily parsed.
(Figure 2)
Below, we can see the output of the previous status command shown in a scriptable format thanks to the “--porcelain” flag. Nifty! What sorts of things can we do with this? Using some simple Unix commands we can write a command that identifies when new markdown files have been added, stores their names in a document. This could be useful for somebody maintaining documentation, for example!
(Figure 3)
In Figure 3, we can see that new files that have been added but not committed are displayed on a line beginning with ‘A ‘. By using the grep command, we can filter the output of ‘git status’ to only pass lines beginning with ‘A ‘ through to the next command. Sed can be used to remove that pattern from the line, before redirecting the output to a file.
The next image (Figure 4) shows a command adding new files to the source control repository, checking the status, and redirecting the names of any new files added into a text file. We use the cat command to print the contents of a file, and we can see that our pipeline worked correctly.
(Figure 4)
Example (PowerShell):
Powershell is designed with automation in mind, and its implementation differs from the shells you might be you used to as a result of this. Unlike in other shells like Bash or Zsh, the pipeline does not pass text between sequential commands! Instead, objects are passed through the pipeline, with values stored in member variables. This takes some getting used to, but offers some very powerful functionality.
Here’s an example of what a pipeline might look like. The “Get-ChildItem” cmdlet is like the “ls” command in a Unix shell. The “-Force” flag will force things like hidden files to be displayed in the results, and “-Recurse” will include items found in any subdirectories. The “Where-Object” cmdlet is used to filter rows in the output of a command, and the “Select-Object” cmdlet chooses the object member variables we would like to show in a table.
(Figure 5)
The importing thing to remember here is that objects are being passed through the pipeline. Sorting results for example, would be very difficult given only lines of text! Figures 6 shows how to extend the previous PowerShell command to sort the results by mode and name. Figure 7 shows that because the pipeline passes objects between cmdlets, autocomplete can provide helpful suggestions.
(Figure 6)
(Figure 7)
Finally, I’ll show you an example of how all of this can be useful when designing automation scripts. Figure 8 shows a command that finds all in or below the current directory, and branches according to different conditions depending on the item.
As we’ve seen previously, creating a sorted list of items and sorting them is a task well suited to PowerShell. The “ForEach-Object” cmdlet can be used to iterate through the results, and perform different operations on the elements in the list. Again, notice that this is possible because of the object pipeline! We can write conditional statements that reference different member variables, and even invoke methods like .GetHashCode() on certain types of files!
(Figure 8)
Comparisons
The syntactic differences between the two shells are quite apparent. Unix shell commands are often more brief, and performing simple day-to-day tasks is almost certainly going to be fasted in a shell like this by virtue of the length of the command binaries alone. PowerShell has a distinct style of camel-case, and the ‘$_.Member’ style of referencing the current element in a loop takes a second to adapt to.
The ability to select, filter, and sort items in pipelines is PowerShell’s primary advantage, at the expense of ergonomics. Complex scripts are also much more readable due to the long-windedness: “/bin/ls -ltu” is harder to understand than “Get-ChildItem | Sort-Object -Descending LastWriteTime”.
Lessons to Learn
Figure 9 shows an example of using the Zsh shell to find the names of any text files in the current directory, and save them in a file named “text-files-found.txt”. This sort of thing is similar to what we did earlier with messages from ‘git status.’ Take heed! PowerShell’s pipeline does not work quite the same.
All of this fancy object pipelining, calling methods on results, sorting things, etc. works because objects have types. In fact, you can even create your own custom PowerShell objects!
Figure 10 shows that the name of the generated file receiving redirected output is also included in the “text-files-found.txt” file, even though that command is last in the pipeline. As a result of this typing, order of operations is not explicitly left-to-right in PowerShell.
(Figure 9)
(Figure 10)
Conclusion
There’s a ton more that you could say about each shell’s pipeline system, but I tried to cover as much as I could because we were comparing multiple alternatives. Both have valid use cases, and valid drawbacks. Enter “Get-Help about_pipelines” into a PowerShell prompt to get some more information about how pipelining works, have fun!
Static typing provides benefits to developers, type systems aren’t just there to frustrate you with compiler error messages! C’s typing system offers a ton of really useful features when used correctly, and this talk has some great slides with real-world examples. Check it out :o)
This is a great dive into how the TTY subsystem works!
csharplang - The official repo for the design of the C# programming language
C# specification in tidy Markdown :o)
In astronomy and cosmology, dark matter is a currently-undetermined type of matter hypothesized to account for a large part of the mass of the universe, but ...
I’m way late to the party on this blog post, but the ‘Dark Matter Developer’ colloquialism has popped up in a couple different places lately and I thought I’d pin this here because it’s helpful to keep in mind.
“The web insists on moving things forward at an rate that makes people feel unable to keep up. [...]
Lots of technologies don't iterate at this speed, nor should they. Embedded developers are still doing their thing in C and C++. Both are deeply mature and well understood languages that don't require a lot of churn or panic on the social networks.
Where are the dark matter developers? Probably getting work done. Maybe using ASP.NET 1.1 at a local municipality or small office. Maybe working at a bottling plant in Mexico in VB6. Perhaps they are writing PHP calendar applications at a large chip manufacturer.”
This is a great deep-dive into handling form submission in Angular, comparing different modules. Kara is also ludicrously fluid at handling non-trivial examples in front of an audience, hats off :o)
Here’s a cool white paper you should check out! Graph theory (and other stuff) being applied to prevent chained privilege escalation. Creative blue-team stuff :o)
From the abstract:
“Identity snowball attacks leverage the users logged in to a first compromised host to launch additional attacks with those users’ privileges on other hosts. To combat such attacks, we present Heat-ray, a system that combines machine learning, combinatorial optimization and attack graphs to scalably manage security configuration.”