Making the keyboard momentarily unresponsive in order to clean an M1 MacBook [closed] - apple-m1

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 months ago.
Improve this question
I have been trying to find a way to clean the keyboard and body of my M1 MacBook Air. I used to just turn off my laptop, use a clean cloth to remove dust and fingerprints, and then turn it on. But this laptop cannot be disturbed at all without turning on: a key press, opening the lid, touching the trackpad, anything causes it to turn on. This feature (which, along with the impossibility to disable the turn-on sound, kinda bothers me) cannot be turned off, unlike with Intel MacBooks. I don't like to press keys and touch the keyboard with the computer being responsive, so I was wondering:
Is there a way to make the keyboard momentarily unresponsive? Maybe a Hammerspoon script?
I know this might seem like a silly question, but I would like to be able to handle my computer knowing I'm not gonna press a random key combination which is going to need undoing later. I think Apple should implement a "cleaning mode" where the computer is unresponsive so that one can clean the body of the computer every once in a while.
Thanks!

You need to setup an event tap for the keyboard. You can tap into a variety of events, for example the key down event. Whenever that event is triggered a callback function is executed which is passed the event data (e). Just return true if you want to block the event. That should disable your keyboard.
You can extract the key code and flags (ctrl, shift, option...) from the event. This will allow you to program a shortcut to stop the event tap and make your keyboard functionally again.
For example:
local events = hs.eventtap.event.types
keyboardTracker = hs.eventtap.new({ events.keyDown }, function (e)
local keyCode = e:getKeyCode()
local flags = e:getFlags()
if flags.ctrl and keyCode == hs.keycodes.map.f then
return false
end
return true
end)
keyboardTracker:start()
Be careful, if an unhandled error is thrown from within the callback function you effective disable your keyboard.
Tapping into mouse events is similar.
https://www.hammerspoon.org/docs/hs.eventtap.html
https://www.hammerspoon.org/docs/hs.keycodes.html

Related

Why use google analytics? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Okay, a lot of websites (about 50%) use google analytics. The idea is to know some basic information about your users. But I don't understand why the service is used by so many people, considering 3 things:
1) The code takes time to load. Even the async version takes time and the user sees the loading icon, a bad thing making it seem like your code is terrible or you can't pay a good hosting company.
2) It's a well know script and a some people block it.
3) Google (obviously) get's the data too. Now, don't get me wrong, but why give them free data sacrificing your uses privacy?
2 and 3 are not so important. 1 is. Given the above, what's the drawback of making your own analytics script and serving it to the users? What's the great thing google analytics does and you can't do on your own?
I would say two reasons:
A) It gives you a LOT of convenient visualizations and ways to slice the data - stuff that you would have to build independently. Again - if you just want to watch one number, it doesn't matter much, but you usually want a bigger picture and GA has put a lot of work into making most useful stuff easily available and easy to visualize.
B) Service reliability - basically, the first 10 iterations of whatever solution you choose to implement WILL have bugs (as any programmer who has worked on any meaningful projects knows).
Outsourcing your analytics to GA therefore just saves you a metric ton of time that it would take to reimplement everything yourself and get it working reliably.
As for speed issues - you can always disable GA on the few pages where speed is critical... although considering that page is usually the landing page of the app, that might not be too smart of an idea...
However - in the vast majority of cases, the async GA code is not really the bottleneck for your page. You are probably better off optimizing other aspects of your javascript on the landing page, as the "loading" icon is really something most users do not notice.

How easy is it to fake asynchronicity? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Clearly I don't understand the big deal about "asynchronous" environments (such as NodeJS) versus "synchronous" ones.
Let's say you're trapped in a synchronous environment. Can't your main loop just say:
while(1) {
events << check_for_stuff_from_the_outside_world();
for e in events {e.process()}
}
What's wrong with doing that, how is that not an asynchronous environment, how are asynchronous environments different?
Yes, this is more or less what Node.js does, except that instead of check_for_stuff_from_the_outside_world(), it should really be check_for_stuff_from_the_outside_world_plus_follow_on_stuff_from_previous_events(); and all of your events must also be written in such a way that, instead of completing their processing, they simply do a chunk of their work and then call register_stuff_for_follow_up(follow_on_event). In other words, you actually have to write all of your code to interact with this event framework; it can't be done "transparently", with only the main loop having to worry about it.
That's a big part of why Node.js is JavaScript; most languages have pre-existing standard libraries (for I/O and so on) that aren't built on top of asynchronous frameworks. JavaScript is relatively unusual in expecting each hosting environment to supply a library that's appropriate for its own purposes (e.g., the "standard library" of browser JS might have almost nothing in common with the "standard library" of a command-line JS environment such as SpiderMonkey), which gave Node.js the flexibility to design libraries that worked together with its event loop.
Take a look at the example on the Wikipedia page:
https://en.wikipedia.org/wiki/Nodejs#Examples
Notice how the code is really focused on the functionality of the server - what it should do. Node.js basically says, "give me a funciton for what you want to do when stuff arrives from the network, and we'll call it when stuff arrives from the network" so you're relieved of having to write all the code to deal with managing network connections, etc.
If you've ever written network code by hand, you know that you end up writing the same stuff over and over again, but it's also non-trivial code (in both size and complexity) if you're trying to make it professional quality, robust, highly performant, and scalable... (This is the hidden complexity of check_for_stuff_from_the_outside_world() that everyone keeps refering to.) So Node.js takes the responsibility for doing all of that for you (including hadling the HTTP protocol, if you're using HTTP) and you only need to write your server logic.
So it's not that asynchronous is better, per se. It just hapens to be the natural model to fit the functionality they're providing.
You'll see the asynchronous model come up in a lot of other places too: event-based programming (which is used in a lot of GUI stuff), RPC servers (e.g., Thrift), REST servers, just to name a few... and of course, asynchronous I/O. ;)

How to release with Kanban? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 5 years ago.
Improve this question
In Scrum, it is obvious that we could produce a demo after each sprint.
I don't know how to produce demos in Kanban since it doesn't has the sprint concept (I may be wrong).
Would you please enlighten me regarding how to make releases in Kanban?
Thanks for help and time.
When we were implementing Kanban at my last job, the releases went one of three ways:
Release every two weeks on a schedule.
If enough sticky notes end up in the "done" bucket on the board to merit an out-of-cycle release, notify the business unit that we're releasing so we can prevent getting too out of sync.
The business unit requires an out-of-cycle release for a specific feature of set of features that are needed immediately.
It was pretty open-ended, really.
Kanban says how to manage the flow of work and limit work in progress, it doesn't say anything about the frequency of releases as such. However, it is quite demanding because it demands that a working integrated version of the product be kept at all times with new features added as soon as they are considered complete (done, last column on the board).
A concept that is frequently used is that there is a "cadence" - a regular interval when this "ready product" is taken and actually deployed to the live system/shipped.
However, I think that one concept that is very clear in Scrum may also help here. In Scrum it is clearly said that Scrum calls for a "shippable product increment" (confirming to the definition of DONE) at the end of each sprint. Whether to actually ship it / deploy it is out of scope of the development process, because it is ultimately a business decision. Same I think applies to Kanban, a ready, integrated product is available at all times, whether to actually use it as a business decision which is outside of the scope of the development process and its management.
There is no single definition. Usually in Kanban we add MMFs (Minimal Marketable Features) which, by definition, means that every feature should add value to the customer, thus you should be able to release every feature independently.
This doesn't mean you have to release each feature separately, so you will find whole range of approaches (David mentions a few of them). I find it a common case that Kanban team release more often than they would if they followed one of time-boxed approaches.
Demos in Kanban are optional but if the client is willing to have them you can demo features as you deploy even if you release every feature independently. In theory every feature should add value so this approach should work well.
We make a demo a condition of moving a feature from "Testing" to "Ready for Release". So it's feature-by-feature rather than sprint-by-sprint, and the nature of the feature will determine the nature of the demo. The greater the business involvement during development the less of an issue this becomes anyway.
You can try adding a sign-off step to your DOD where you may arrange a quick demo. But the difference would be, it will be an one-to-one demo whereas in scrum sprint review, the demo is for all the attendees.
Regarding the release cycle, its already mentioned in previous answers. I would like to add one more point, you may have a limit for yet to release items. For example, if you have 10 MMFs are in the board ready-to-be-released then release process can be kicked off then and there.
This method may help you to track down throughput in a way.

CSS regression tool? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm looking for a visual regression testing tool for CSS refactoring and see whether or not there are any unintended cascading behavior in a website.
Ideally, the tool that can crawl a website (even locally) and grab snapshots of each page and store it in a single repository.
When run for the second time, it will show the pages that are visually different since the last time it was run.
Even better:
if it can show the overlapper XOR view of the 2 version of the page.
compare rendering results of different browsers (almost like an automated Microsoft Expression Web compare feature).
My current favorite is WebDriverCSS in combination with BrowserStack Automate API. This pair of tools allows for multi-platform, multi-browser regression testing across the very wide range of devices that BrowserStack supports. It requires writing code but is much more comprehensive than any solution bound to Phantom or Slimer.
If you are ok with an old WebKit being your only test UA, here's a great writeup on CSS regression testing using PhantomCSS. Their basic example provides exactly what the original question desired: visual diffs between two commits.
For a simpler tool that requires no coding (only YAML config), I point people towards Wraith more often than PhantomCSS. Give #ericcraio's answer a vote if you like Wraith and don't want to write Casper code.
I know this question has been posted for awhile but I wanted to mention about a new CSS regression tool called wraith by bbc-news.
http://github.com/bbc-news/wraith
It utilizes tools such as phantomJS and imagemagick.
http://responsivenews.co.uk/post/56884056177/wraith
Check out Browser Shots. This is a free service.
There are some restrictions on how many tests you can run each day as a free user. But unlike Litmus; you can run tests on all supported browsers--Litmus only allows free users to test their websites on Internet Explorer 7 and Mozilla Firefox 2.
I am developing a CSS regression testing tool which is called SUCCSS, it is a npm global, open source: https://github.com/B2F/Succss. Atm, you can read its full documentation there: http://succss.ifzenelse.net
Check out Litmus.
It'll crawl your site and take screen captures has damn near every browser you'd want.
In addition to the core functionality Litmus also allows you to to track bugs, log in to private sites, and allows you to publish compatibility reports from your tests.
What you've described is precisely what Mogotest does. We can log into your site, take screenshots for all the pages you've configured, and do automated comparison using the principles of Web Consistency Testing.
We also keep a full track of history so we can tell you exactly when something broke (and what your site looked at that time) and even cooler, we can detect when you've fixed something. And finally, we snapshot your code at each test run so we can show you exactly what changed for each issue.
Sorry for the self-promoting nature of this answer. I just wanted to be thorough in addressing what you're looking for.

Audio encryption/protection [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Other than coding, I spend alot of my time in a recording studio making music. I intend on selling my art both online and on cd, but I have one issue...protecting the audio file. I dont want people illegally distributing or making copies of my music so I need to protect it somehow. The one way that I've seen is to create my own player and the tracks can only be played using this player. Using a "PCID", and a private key, the player decrypts the adio and playsback. However, this will surely chase clients away because they wouldnt like the restriction of only using my player. Does anybody have any other ideas?
As creator of the music (assuming it is original music) you have copyright for the music, and legal remedies if people make copies and profit from it (or cause you loss). People who pay for music aren't going to bother pirating it, and people who pirate it aren't going to bother paying for it. Your odds of beating them via legal means are probably better than having a foolproof-yet-widespread protection model.
So, in case it wasn't obvious -- don't bother. Popularity/fame might probably bring you more value than your music.
In the end, any protection you devise can and will be broken. Instead of attempting to fight a losing battle, rather look at offering "value added" content to legitimate purchasers (CD sleeves, art elements, etc).
Additionally, you can look at using digital audio watermarks embedded in the audio files. Whilst this won't prevent unauthorised copying, it will allow you to identify the source of the original leak.
Well no matter what you do, people will find other way to do so and it will make people prevent from buying your music. What about making a deal with a Music Label Studio or something that can protect copy rights.
I don't know if I'm to late for an answer, but I did code some sort of audio encryption, that does have a player that plays the encrypted audio format. Also offers password protection, there is another version I finished but haven't uploaded that has input and output directories and a GUI. Here is the link for more info:
http://ronaldarichardson.com/2011/04/05/saf-secure-audio-format/
You can't avoid the analog hole.

Resources