Thursday, June 16, 2022

Programmatic/script access to FetLife

This summary is not available. Please click here to view the post.

Wednesday, June 15, 2022

Programmatic/script access to Gmail.

Access to your Gmail using a script can be extremely useful, as it allows you to export data from it based on queries or parameters and manipulate the data freely. However, Gmail is highly secure, so this can be a little tricky. Here’s how it’s done.

1.       Download GIT and install it from https://git-scm.com/downloads

2.       Visit the GIT repository for the Gmail PowerShell extension to download and install it: https://github.com/nblagoev/Gmail.ps#install

3.       Open Windows “Credential manager” from the start menu

4.       Go to the Windows Credentials tab

5.       Click “Add a generic credential”

6.       Add your Gmail account credentials

7.       Open a PowerShell admin window

8.       Install the PowerShell Credential Manager:

9.       Install-Module -Name CredentialManager  -AllowClobber -Force -Verbose -Scope AllUsers

10.   Get your own “App Password”, which is a unique character string that Google generates for your account. This article shows the steps: https://support.google.com/accounts/answer/185833

11.   Use the following code to auth to Gmail in the PowerShell window:

$Gmailcred = Get-Credential     

(Then select your Gmail account, and type in the app password you obtained in step 9)

1.       This creates a Gmail session you can work-against:

$Gmail = New-GmailSession -Credential $Gmailcred

1.       Use the following loop to retrieve messages and dump them into a text file. You can use various other filters to create your query, such as a date/time range, subject keywords, whatever you want. This example is for emails received from a specific contact:

$messages = $inbox | Get-Message $Gmail -From "joe@cnn.com" | Receive-Message

$File   = 'c:\temp\DownloadedMessages.txt'

$Stream = [System.IO.StreamWriter]::new($File)

foreach ($msg in $messages) {

$Stream.WriteLine($msg.Body)

}

The resulting file is a flat text with the full body of the messages, which you can then parse using any other script you like, or just archive for whatever purpose. You can also use other options instead of $msg.Body, like $msg.subject, if you just want to list the subjects. You can also substitute the $StreamWriteLine with some other commands to process the messages as they are read by PowerShell. For example, you might prefer to create an individual file from each message, or fish-out specific pieces of text from the messages. There’s no limit to what you might do.

 


Tuesday, May 17, 2022

How to get decent profile photos

Nowadays, everyone has a very high end digital camera on their phones, so one might think that it would lead to more people having good photos of themselves (in addition to photos of whatever they had for lunch every single day since getting the phone). However, if you spend a few minutes on Facebook or dating apps, it becomes apparent that the majority of people still have no idea how to take decent ones.

Is it important to have a good profile pic? Perhaps not to everyone. Focusing too much on one’s appearance is shallow and for many, is a repulsive trait. However, the point here today isn’t to obsess about your looks and take dozens of photos daily, but rather to be able to have a few that reflect how you look like in-real-life. If the only photo you have that feel OK to you is some grainy, fuzzy shot someone grabbed at a bar 7 years ago, you can probably do better. Today I’ll discuss some techniques that might help.

Having your photo taken is both a skill and art-form, and not just a product of your appearance. In other words, you don’t have to be beautiful to look decent in photos. Admittedly, there is a limit to the “magic” those skills can provide, and some people will not have Brad Pitt’s dashing good looks no matter what they do, but still, a few tweaks and experience can help most people look a lot better than the majority of what I see online.

Before I start, let's address the question of the CAMERA. We've all seen pro photographers with their giant cameras and lenses (*) that probably cost more than a car. Indeed, most of them spend thousands, but that's not the key to good photos anymore than a good knife being the key to good sushi. The camera in most of today's phones is quite capable of producing studio-quality shots, and you can get there too, using the following tips and tricks. 

* Why do pros still spend thousands on these machines? Well, some of is is just for flare, because it might look ridiculous if a professional photographer would be jumping around the studio with a tiny camera. Beyond that, the pro models can do some fun stuff, like faster and more efficient focus and taking a lot of photos continuously (for example, Canon's EOS-1D X Mark III can shoot 16 photos per second). They also have other tech that can produce decent shots in sub-optimal conditions, like low-light, weird-light or fast moving situations, such as those needed by journalism photographers. The big lenses they have are also optimized for such harsher conditions.

For starters, the most important & ignored thing for any photo is LIGHT, and that’s what most photographers spend their time on studying, and their money on buying. I cannot cover the entirety of light theory here, as it requires a whole book, but the fundamentals are that a light needs to be STRONG, DIFFUSED, and have the right COLOR. The LED light that your phone has is not serious, and neither is the standing-light you have in your bedroom, even if it is a halogen. Without serious light, even the most good-looking face will look too-dark, lacking in details, and have unnatural colors.

To be fair, a serious light doesn’t mean you need to go spend hundreds of dollars. Most of us have a very serious light at our service, and it’s usually free. It’s called “the sun”, and unless you live in Seattle, you might have seen it occasionally, when taking a break from reading this website. A professional photographer would indeed have spent hundreds of dollars on specialized light fixtures (although you can get a decent set of soft-lights for about $65), but you can get great photos by using sunlight to light yourself. But wait…don’t rush to the back yard quite yet.

The 2nd factor is diffusion. Sunlight can be TOO strong, and that causes an issue of shadows. Normal faces have elements like eyebrows and nose that can cast shadows around them and that doesn’t work well, so it’s as-important to diffuse the light. Professional photographers might use a reflector, which is just a large white or silver panel that is placed or held such that it reflects the light from another angle, thus illuminating the shadows created by the sun. While a reflector isn’t too expensive (you can buyone for $15), it does require expertise to setup right, but an alternative is simply using INDIRECT light. One way is to take the picture in a shaded area, like under a tree or behind a structure. It can be tricky to find a good balance of light that is both diffused, but still bright enough, though. Another trick is to take a photo either very early in the morning, or very late before sundown. During these times, the angle of the sun to earth is such that the light comes through the atmosphere from the side, and is more diffused and thus less stark. It also ads a bit of a softer hue to the light, making the photos look a bit “dreamy”, which is usually good for portraits. Another trick is to take a picture indoors, in front of a window. You would stand at the window, looking out, or at the side of the window. In such a scenario, the window will let a lot of light in, but not direct sunlight, so it’s diffused. Yet another hack is to take a picture inside your car. In a car, you are surrounded by several windows, so a lot of light comes-in, but also indirectly, and that creates really well-lit and balanced light.

The light color-temperature is another aspect. Every light source has one, and some are better than others. This is not a huge factor, as cameras have a “white balance” feature, which can compensate for issues with the color temperature, but one thing to keep in mind is to avoid taking pictures under fluorescent lights, as those are notoriously difficult to get right even with the best camera. With pretty-much all phone and simple digital cameras, white-balance will be automatic and you don’t need to fidget with it (unless you intentionally turned it off). If, however, you notice your skin looks weird in your photos, like ghost-white, too-red, then it might be your light source having a really bad color temperature that your camera isn't able to adjust-to. This might be possible to fix that with some retouching, but I recommend getting better light as a 1st step, as retouching has it's limits too.

Beyond these basic light tips, there are many ways to setup lighting for different looks and effects. If you’d like to dig deeper, this article covers some of these scenarios:

https://www.camerapro.com.au/news-and-reviews/post/essential-lighting-setups-portrait-photography

Another important aspect of photography is position and posture. Many of us take photos standing up or sitting on a couch, and that rarely works well. A prop that has proven itself consistently is a simple high-stool (one that’s high enough so that your feet don’t touch the ground and you need to prop them on the stool support beam). These stools force us into a straight-back posture that is much nicer than an awkward stand, and usually eliminates the double-chin that often accompanies sitting-down on something more comfortable like a couch or sofa.

The next skill is figuring out which side and angle works best for YOU personally. The majority of people don’t have a fully symmetric face, and so one side will look better than the other. In general, taking a photo staring straight into the camera is almost never going to do you justice, and the angle that works for most people is “3/4”, meaning you point your head to the side of the camera about 45 degrees, while still making eye-contact with the camera itself. Make sure that the camera is at eye-level or a little above it, but never below as that distorts the face badly. Ultimately, different angles work differently for different people, and are also affected by things like your personal eye structure (and other facial features), scars, skin condition, etc. There’s no substitute for experimentation, so be ready to take a few dozen pictures, covering various angles, until you find a decent one. A key here is repeatability. Once you find the right angle, you should be able to get decent shots almost every time.

One thing to keep in mind is camera distance. Non-professional cameras are optimized to include as much into the scene (a.k.a. “wide angle” or fish-eye), and that tends to distort things and can make you look fatter or cartoonish than you really are. An optimal distance to take a photo is at least 4-6 feet away, so if you were hoping to just take a selfie while holding the phone, this will only work if you have very long arms. In all other cases, ask a friend to take the photos, or use a selfie-stick or tripod, or simply prop the phone on something (again…make sure it’s at eye level!), and use the self-timer option. By the way, if you have a Samsung phone, they have a feature that will take a timed-photo when it recognizes an open-palm. Instead of fidgeting with the settings, just stand and wave your arm…and the phone will take a photo automatically.

Next thing to consider is your eyes. Many people open their eyes too-wide, and end up with a deer-in-headlight look. Instead, try to keep your eyes naturally open, or squint a little bit. As with the angle, some trial-and-error is the way to find what works best for your face.

Something that many people seem to struggle-with is the smile. Most people know that smiling in a photo is a good idea, but many struggle to produce a fake smile that will look nice, and end up as if they are grimacing, smirking, or looking like an idiot (the cliché and horrible ‘say cheese’ phenomenon). Professional photographers learn to talk to their subject while they are photographing them, and try to hone-in on subject of fun and interest, in order to elicit a natural smile, as those typically look best. If you have a friend to do that for you, that would be ideal, and if not, try to think of fun and pleasant things while you do this, or recall a funny video or joke. If you’re running into a blank with smiling, try a low-key fake smile that has your lips closed (no teeth showing), and smiling with just the edges of the mouth. Keep in mind that a smile is also in the eyes, so try to consciously smile with your eyes too. Whatever you do, avoid the duck-lips and open-mouth smile, as those almost always look bad. Some photographers suggest doing a joint-shoot with your kids or a romantic partner, as the love between you can bring your face to life and bring out natural happiness and joy.

If, with all the above, you are still unhappy with the results, another trick to try is simply making faces and gestures. As you take the photos, simply “act” out different thoughts and moods. Shock, surprise, horror, hunger, “wondering”, questioning, doubting, etc. If you are capable of unusual facial gymnastics like raising a single eye-brow or moving your ears, try these too. Supplement those with body and hand gestures, like raising your hands up, pointing a finger at the camera, making a “hello” gesture. A common posture is one where you lean your elbow on your thigh or knee, and lean your face onto your palm. This posture tends to put you in a good angle, and can also be useful in concealing a part of your face, if you’d like (for those of us who have some nasty scar, bad facial hair or multi-chins).

Another thing to consider is the background. It's less critical than the above, but can make a difference. It doesn't have to be a "professional" background (although you can buy that for as low as $50). You can hang a simple blanket or sheet using clips or tacks, or simply do it in front of a clean wall. If you do use something, try to get something neutral to contrast with what you're wearing, so you stand-out, and avoid strong or loud patterns. If unsure, you can't go wrong with simple white background. If you absolutely cannot setup a good background, there are some websites that can automatically remove it for you. 

Ultimately, even with all these tricks, there’s no substitute to a experience, and that means taking a lot of photos as you work your way through what looks best. Keep in mind that even a professional photo shoot also involves taking dozens or even hundreds of photos, knowing that the majority of them will be discarded. Thankfully, with digital photography, all you’re wasting is time and no film.

If despite all this, nothing works, consider going to a professional photographer. At some chains like JC Penny or PicturePeople, you can get a session done for a reasonable amount of money, and this is decent investment in order to build yourself a serious online presence and dating profile (I, even though I’m quite capable of self-photography, do this every 2-3 years to get a fresh set). It’s also an opportunity to learn by interacting with an experienced shooter and seeing what he or she does to “get” you to look good. Naturally, they will have other tricks and high-end equipment and lights, but trust me…the main trick is your face, not just the hardware.

Tuesday, May 3, 2022

The origins of Shabbat

Jewish law is affluent with rules and regulations, such as the famous “Kashrut” laws that forbid certain food items. Many are aware that Jews are forbidden from consuming pork products, but Karshrut is actually a very long list of regulations that limit not only things one is allowed/barred from eating, but also preparation methods and other restrictions. For example, blood itself is the most un-kosher thing, so one is forbidden from interacting with it, and so men are forbidden from touching a woman during her menstrual cycle (and some won’t touch a woman at all to eliminate all risk of accidental exposure). Another part of these laws is concerning the Shabbat, the day of rest. Jewish law forbids doing any deliberate work during the Sabbath, which includes a wide array of activities. Lighting a fire is a well-known one, but some of the other restrictions seem absurd, like one that forbids exchanging money or walking long distances. The question on my mind today is WHERE it all came from?

Religious scholars have postulated that Kosher laws came to be as a way of protecting people from unhealthy foods. The theory suggests that the foods that are un-kosher have been designated so because they present a higher risk of contamination or food-borne illness. For example, pigs are known to carry the parasite trichinella, making it riskier than other types of meat. Similarly, the bacteria Vibrio is often carried by shrimp, prawn and crab, making them riskier to eat than other marine animals. Today, we have various techniques to reduce the risks, by chilling and freezing products, and we are also aware of the existence of microscopic bacteria and parasites, so we know that certain foods need to be cooked to a certain temperature to be safe (for example, pork is recommended to be cooked to 160 degrees, higher than other meats). The theory is that thousands of years ago, before people were aware of bacteria and refrigeration was not readily available to all, avoiding these foods was a way of reducing food poisoning and death. Religious teaching say that the prophet Moses, who led the Jewish people out of Egypt to their freedom, received the Torah directly from God, and that included the various rules of Kashrut. Atheists like me believe that the more plausible explanation for various religious stories is that the being humans perceived as “god” at the time was actually an advanced race, possibly extra-terrestrial, and it’s plausible to think that such a race was aware of the risks associated with certain foods and included them in the rules delivered to Moses as “divine” guidance (as we all know, this sort of guidance, by its very nature, is unquestionable and thus doesn’t “require” an explanation). 

I theorize that the rules of Shabbat, which are also divine and part of religious teachings, have a plausible practical origin. Breaking down the calendar to “weeks” with a day of rest in each predates Judaism. This was practiced in Babylon, although in a slightly different structure, which was based on breaking-down the lunar month to 4 periods, rather than counting the days themselves. My theory is that the day of rest was a time where people could “let loose” and consume alcohol and drugs (in old times, hallucinogens like mushrooms and cannabis were legal and common), and so the rules were put in place not to force one to rest, but to prevent people from engaging in activity that might risk or harm them if done while inebriated. For example, going far while drunk risks getting lost, robbed or falling off a cliff. Similarly, lighting a fire while hallucinating could lead someone to get injured, or forgetting to extinguish the fire could end up in burning down the village. My theory is that the same people who gave mankind kashrut laws under the false pretense that it’s a divine rule did the same with Shabbat rules. They were just trying to protect us from self-destruction. 

Naturally, I’m no historian, nor am I a religious scholar. The above is just my rambling at 5am on some idle Tuesday. Maybe it will seem sensible to someone…


Thursday, March 24, 2022

Gmail manual spam filtering using keywords

While Gmail comes built-in with pretty good spam filtering, there are many people out there spending major resources on trying to circumvent those, and so anyone who uses email will inevitably end up receiving a certain amount of spam, no matter what they do. For some, you can unsubscribe using the advertiser's own button, and for others, you might be able to gain some quiet by using Gmail's own "report spam" button, but these too don't always work as there are quite a few very effective and persistent spammers out there. The good news, though, is that Gmail does have a function to create your own custom filters, which can allow you to get rid of spam using keywords you define on your own. Here's how to use this feature. 

Step 1: do the math. 

To be able to filter the spam, you need to figure out a pattern that you can set your filters to. That pattern can be a keyword or two in the subject or body, for example, or a specific sender. This is the hard part, as it will require you to out-smart the spammers to some level. They do use various mechanisms to escape the filtering, such as changing their email or name (sometimes several times per day), or replacing characters in words (like using "S@le" instead of "Sale" or "Win ner" instead of "Winner"), so be prepared for this to require some thought, and likely some trial-and-error and time until you catch all, or at least most of them. For example, a filter you might come up with could be "messages with the words 'custom watches' or 'quick sale' in the subject". Keep in mind that targeting a single keyword is risky, because that risks missing emails that you DO want, so it's important to test out your filter carefully before using it.


Step 2: Write the filter.

To be effective, you'd typically want to create few or one filter rule, rather than a dozen, so grouping keywords together is important. For this, Gmail uses the pipe symbol. Also, to use a keyword set with a space in it, you need to enclose it in quotes, otherwise Gmail will look for EACH word separately. To filter for words in the subject, use the keyword "subject:" and to search in the body, use "body:", so a search filter might look like this:

subject:("pretty jewlery"|"one time sale"|"buy now")

or:

body:("waiting for your reply"|"don't wait"|"urgent matter"|"hurry up")

There are other things you can filter by, though those might not be useful for spam specifically. Adding them here just for informational purposes:

Size, by adding "size:5mb" to filter for emails larger than 5mb. 

From or to, by adding that keyword, like "from:john@watches.com"

Negative keywords: adding a minus sign, like "-erez" will exclude emails which have that word from the filter

Has attachments, by adding "has:attachment"


Step 3: Test the filter

To test your filter, paste it into the Search box on the Gmail inbox, and see what it produces. If you already have some spam in there, this is how you see if it catches it or not, as well as if it catches "good" email you don't want to filter. If it did, it will show you in yellow what keywords caught that email specifically, so you can use that to refine the filter. Ultimately, this is a bit of a give-and-take. The tighter the filter, the more likely it will catch some emails you do want (a.k.a. False Positives). You might be willing to live with that, or prefer to loosen up the filter and deal with some spam that will escape it.


Step 4: Apply the filter

Use Gmail's Settings and go to the "Filters and blocked addresses" tab. In there, create a new filter and paste in the filter you came up with, and then use "continue" to choose what to do with these. You can delete them, or just archive them (which is safer, as it would still allow you to search for them later, if you suspect you may have missed an important email).

Good luck with your spam-catching!