lonely road

Taking a break for a while

After many years of writing for this blog and posting what I learn along the way, I’m finally taking a break. It’s become apparent to me over the past few years that I simply do not have the time to continue putting effort into this aspect of my life. With two children and a career switch to the management track, I’ve chosen a different path.

I’ll continue to keep this url live and maintain the pages at their original locations. I appreciate the journey and consider myself grateful to have helped support a wonderful little community along the way. I hope the items I posted helped save you time, advance your skills or inspired a better solution.

I may start writing again in the future about tech & management related topics, but it could be quite a while before that happens. In the mean time, feel free to look around, drop me a line or hit me up in the comments. The content will stay, but my updates will officially stop for now.

I wish you all the best, take care and aloha.

Echoing CSS vars

Sometimes you want to echo out the value of css variables but they are hard to debug unless you know where to look.

In JavaScript just do the following:

getComputedStyle(document.documentElement).getPropertyValue('--my-cool-var')

Ack > Grep

Recently I’ve needed to do some string searches for occurrences on my local file system. I can tell you by far the easiest thing I’ve found to get up and running quickly is `ack` with a combination of other tools:

First off let’s start with a simple string search:

ack -io "my( | )simple( | )string( | )search" --ignore-dir={example,directories,to,ignore}

This does a couple things.

  1. -i means to ignore case, -o means output the line and occurrence of the string
  2. Everyhing in quotes is the regex (normal regex)
  3. ignore a list of directories (if it was a single directory don’t use curly braces.

The only wierdness is my regex which just looks for regular white spaces and nonbreaking characters as well. Ignore my regex and you get the basic structure:

ack -io "search string" --ignore-dir={ignore,these/directories}

If you want to see the entire line with the occurence you would just remove the -o value:

ack -i "search string" --ignore-dir={ignore,these/directories}

And that’s it! So simple you can’t afford not to try it out. If you’re on a mac, installation is simple:

brew install ack

Regex : Select Everything Between

Let’s say we want to select things between two string patters. For instance the middle of a file path:

/Users/Stuff/Dev/things/stuff/more/things/package.json

We can use something called a look behind and a look ahead to get the match we want. Let’s say in this case I want to pull out: “stuff/more”

First off if you don’t have Reggy, I highly recommend it. You can debug regex quite easily.

Second, what are we talking about with look aheads and look behinds?

Positive Lookbehinds:

For the first bit, we don’t need to start our string pattern at the beginning of the line. We can just start with a positive lookbehind. What is it? It tells the computer to temporarily step backwards in the string to find a matching pattern.

However, all this is bullshit. What you really want to know is this:

(?<=text) = find "text" and match shit to the right

Now we can highlight something like this:

With:
/Users/Stuff/Dev/things/stuff/more/things/package.json

Running (?<=things/):

Outputs: stuff/more/things/package.json

Now we need the second rule.

Positive Lookaheads:

Now we need to remove the stuff on the end “/things/package.json”. To do this, we again need something that sounds really complex and blah blah blah.

What you want to know is this:

(?=text) = find text and match shit to the left

So if you don’t want “/things/package.json” just match everthing to the left of it:

Running: (?=/things/package.json):

Outputs: /Users/Stuff/Dev/things/stuff/more

Putting it all together:

Let’s add everything together and see what we get:

Running: (?<=things/).*?(?=/things/package.json)

Outputs: stuff/more

There you have it!

Filing Bitcoin Trades with the IRS

For those of you out there who traded bitcoin and prefer doing your own taxes through turbox tax may find the following fairly useful. This is a response from a page on their forums. I’m providing the important points here and a link at the bottom:

[pastacode lang=”markdown” manual=”I’d%20guess%20you%20didn’t%20get%20a%201099-B%20for%20those%20trades.%0A%0AUse%20the%20%22Stocks%2C%20Mutual%20Funds%2C%20Bonds%2C%20Other%22%20interview%20telling%20TurboTax%20that%20no%201099-B%20was%20received.%0AUse%20the%20%22Everything%20else%22%20investment%20type.%0AMake%20sure%20your%20list%20reports%20the%20same%20information%20that%20a%20Form%208949%20would%20report%2C%20separated%20between%20long%20term%20and%20short%20term%20holdings%2C%20with%20dollar%20subtotals%20for%20each%20term%3A%0A%0AWhat%20was%20sold%0ADate%20of%20sale%0AProceeds%20of%20sale%0ACost%20basis%0ADate%20of%20acquisition%0A%0A%0AOn%20the%20page%20%22Some%20Basis%20Info%20About%20This%20Sale%22%20enter%20%22Summary%20of%20ST%20Crypto%20Currency%20Trades%20%22%20or%20%22Summary%20of%20LT%20Crypto%20Currency%20Trades%22%20depending%20which%20group%20you’re%20working%20on.%20Enter%20the%20total%20dollar%20amount%20of%20proceeds%20for%20each%20group%20as%20appropriate%20and%20you%20can%20use%2012%2F31%2F2017%20for%20date%20of%20sale.%0A%0AOn%20the%20%22Tell%20Us%20How%20Your%20Acquired%20This%20Property%22%20page%20tick%20%22Purchased%22.%0AOn%20the%20%22Enter%20Purchase%20Information%22%20page%20enter%20the%20summary%20cost%20and%20the%20word%20%22various%22%20in%20the%20Date%20of%20Purchase%20box.%0AOn%20the%20%22When%20Was%20This%20Investment%20Acquired%22%20page%20you’ll%20answer%20%22Yes%22%20for%20the%20long%20term%20trades%20and%20%22No%22%20for%20the%20short%20term%20trades.%0A%0AIf%20you’re%20mailing%20in%20your%20income%20tax%20returns%20you%20can%20include%20your%20manipulated%20substitute%20for%20a%20Form%208949%20as%20part%20of%20your%20filing%20though%20I’d%20add%20%22See%20Schedule%22%20to%20your%20descriptions%20of%20what%20was%20sold.%0A%0AIf%20you%20are%20e-filing%20your%20tax%20return%2C%20then%20mail%20your%20statements%20along%20with%20Form%208453%20to%3A%0A%0A%20Internal%20Revenue%20Service%0A%20Attn%3A%20Shipping%20and%20Receiving%2C%200254%0A%20Receipt%20and%20Control%20Branch%0A%20Austin%2C%20TX%2073344-0254%0A%0AForm%208453%3A%20https%3A%2F%2Fwww.irs.gov%2Fpub%2Firs-pdf%2Ff8453.pdf” message=”” highlight=”” provider=”manual”/]

This was taken from: https://ttlc.intuit.com/questions/4240094-i-have-over-2k-crypto-trades-to-report-i-used-bitcoin-tax-to-get-my-overall-gain-loss-and-generate-8949-but-do-i-have-to-enter-each-trade-how-do-i-report-a-summary

I just wanted to capture these instructions in case that page every gets removed. It’s important to keep a record 🙂

Easier Request Parsing with Python

Sometimes you just need a set of tools to help you automate certain functions of your daily routine. For me it’s running builds and verifying that things are working as I expect.

Lately, I’ve needed a way to tell if certain domains/pages are available or not. I have bash scripts to do this, but they are bulky and confusing to read when you only modify them every couple months. There has to be a better way…

Enter: Python.

Of course this makes sense, I can easily have one of my bash scripts simply run a python “availability evaluator” and then check the status code from there.

In your bash script you’d only need:

[pastacode lang=”bash” manual=”python%20script.py%20http%3A%2F%2Fstuff.com%2Fthings” message=”” highlight=”” provider=”manual”/]

Then in your python script:

[pastacode lang=”python” manual=”%23!%2Fusr%2Flocal%2Fbin%2Fpython%0A%0Aimport%20requests%2C%20sys%0A%0A%23%20set%20the%20url%20from%20the%20argument%20you%20passed%20in%20(URL)%0Aurl%20%3D%20sys.argv%5B1%5D%0A%0A%23%20check%20the%20url%0Aresponse%20%3D%20requests.get(url)%0A%0A%23%20output%20the%20response%20code%0Aprint%20response.status_code” message=”” highlight=”” provider=”manual”/]

It works by using the request library to fetch the url and do some parsing of the response header automatically. This makes it easy to test when most of the time you are simply looking for the response code instead of the entire header.

So now you have something that will check a url and output the response code only. With this it’s much easier to check in bash whether the response code is the code you want. Like this:

[pastacode lang=”bash” manual=”responsecode%3D%60python%20~%2FPath%2Fto%2Fcheck-aow.py%20%24sitesdir%60%0Aif%20%5B%5B%20%24responsecode%20%3D%3D%20%22200%22%20%5D%5D%3B%20then%0A%09shouldaow%3DY%0Afi” message=”” highlight=”” provider=”manual”/]

With this you should be able to have something that takes input from your bash script and outputs a response as to whether or not that url is available.

Learn how to make a GLSL Circle

In this tutorial, I show how to make a simple GLSL Circle.

For those who aren’t familiar with GLSL, you can follow a really good set of tutorials here: https://thebookofshaders.com/

If you are familiar but just need a refresher or just gettin started, feel free to watch. I follow a simple set of progressions from controlling the colors in the view to creating a circle shape. From there I show how to inset the colors.

  1. Normalize the UV coordinates of your scene so you are working from 0,0 in the center.
  2. Generate a color
  3. Modify your color on a set of changing variables (in this case iTime)
  4. set fragColor to your new color!

And here’s the code for this:

[pastacode lang=”cpp” manual=”void%20mainImage(%20out%20vec4%20fragColor%2C%20in%20vec2%20fragCoord%20)%0A%7B%0A%20%20%20%20%2F%2F%20Normalized%20pixel%20coordinates%20(from%200%20to%201)%0A%20%20%20%20vec2%20uv%20%3D%20fragCoord.xy%2FiResolution.xy%3B%0A%20%20%20%20vec2%20center%20%3D%20uv%20-%20vec2(0.5%2C0.5)%3B%0A%20%20%20%20center.x%20%3D%20center.x%20*%20(iResolution.x%20%2F%20iResolution.y)%3B%0A%0A%20%20%20%20%0A%20%20%20%20vec3%20col%20%3D%20vec3(0.9%2C%200.3%20%2B%20center.y%2C%200.5%20%2B%20center.x)%3B%0A%20%20%20%20%0A%20%20%20%20float%20r%20%3D%200.2%20%2B%200.5%20*%20cos(iTime)%3B%0A%20%20%20%20%0A%20%20%20%20col%20*%3D%201.0%20-%20smoothstep(r%2C%20r%20%2B%200.01%2C%20length(center))%3B%0A%0A%20%20%20%20%2F%2F%20Output%20to%20screen%0A%20%20%20%20fragColor%20%3D%20vec4(col%2C1.0)%3B%0A%7D” message=”” highlight=”” provider=”manual”/]

To practice this I recommend making a new experiment here: https://www.shadertoy.com/new

xScope command to copy colors

This one will benefit maybe one person out there…ever.

If you want to copy a color you are hovering over in xScope. Hover over the color you want and hit:

[pastacode lang=”less” manual=”ctrl%20%2B%20cmd%20%2B%20optn%20%2B%20c” message=”” highlight=”” provider=”manual”/]

This will allow you to copy the color that you were hovering over And then you can use it paste in other applications.

NOTE: This site is all about helpful hints tricks and tips. The posts lately have been short on purpose. For one, I’m busy AF and don’t have the time to post anything of great detail. Additionally, I believe in simplicity. You can visit, find something helpful and move on with your life.

As always I appreciate your feedback, please leave a comment if you feel I’m leading people down a less than idea path or just comment because you like talking IDC.

GLSL Functions Explained

UPDATE: Actually, you don’t need to read further, instead go here: http://thebookofshaders.com/glossary/

 

Disclaimer: I’m in no way an expert on GLSL, graphics programing, or anything else in the world, really…

However, I’m finding it difficult to find good docs on WebGL functions, that explain in layman’s terms what the hell they do. So I’m starting a list here and updating it as I learn more. Also, if I’m wrong, tell me, I don’t want to give out bad information.

 

float step(float a, float b)

  • returns a float value of either 0.0 or 1.0 depending on if “b” is higher or lower than “a”
  • “a” represents the limit or threshold to cross
  • “b” represents the number to test against the threshold

float smoothstep(float a, float b, float c)

  • returns a float value of anywhere from 0.0 to 1.0. 0.0 for any “c” value below “a” and 1.0 for any “c” value above “b”. The “c” values in between the “a” and “b” range are interpolated
  • “a” represents the start of the range (threshold)
  • “b” represents the end of the range (threshold)
  • “c” represents the value to test against the range

float fract(float a)

  • returns only the fraction portion of a value. So given the value 3.14159265358979, it will return .14159265358979