Skip to content

Instantly share code, notes, and snippets.

View armw4's full-sized avatar
🎯
Focusing

Antwan R. Wimberly armw4

🎯
Focusing
  • Stay tuned...
  • Atlanta, GA, USA
View GitHub Profile
@armw4
armw4 / karma.md
Last active January 9, 2020 19:45
Having no specs is an error in karma.

by Antwan Wimberly

So I'm setting up my first project using gulp, karma, and jasminejs. I setup my karma task, and after repeatedly banging my head against my desk, I finally managed to get everything properly configured....or so I thought. It seemed like all the errors and warnings I'd encountered had been resovled (and they were). But for some reason, when I ran the task, I kept getting this output:

[13:03:58] Starting 'clean'...
[13:03:58] Finished 'clean' after 3.28 ms
[13:03:58] Starting 'files:scripts'...
[13:03:58] Starting 'files:specs'...
[13:03:58] Finished 'files:scripts' after 37 ms
@armw4
armw4 / when-to-presentational.md
Last active July 14, 2019 01:00
Apply presentational components where they make sense

This is a Judgement Call...but not a Difficult One

If you're a resident of redux land, you've probably heard the tale of container components vs presentational components. The latter has no knowledge of redux, does the heavy lifting rendering wise, and communicates with the former via callbacks. The former knows about redux, state, actions, the store, etc. There's a clear demarcation between the two sides. That being said, sometimes you don't need presentational components. If the rendering is simple enough, you can "just do it". You hear a recommendation, guide line, or best practice suggested by a framework author, and over time you apply it rigorously; treating it as a fact of life. I'm guilty as well (although I go out of my way not to be). Ultimately you have to be pragmatic about how you apply idioms and best practices. Sometimes it's worth asking "does this really make sense". I found myself wondering just that when I was staring at a container component that was a mirror image of the present

@armw4
armw4 / unhash.md
Last active June 18, 2019 13:45
Coding exercise
CHALLENGE DETAILS

Write a JavaScript function unhash(num) to find a ten letter string of characters that contains only letters from:

acdfgilmnoprstuw

such that the hash(the_string) is:
@armw4
armw4 / index.js
Last active August 21, 2018 23:27
Coding exercise
import $http from 'http-as-promised'
import Promise from 'bluebird'
const resolveClass = (currentCount, { room, students, next }) => {
const studentsTwentyFiveOrOlder = students.filter(({ age }) => age > 24)
const count = currentCount + studentsTwentyFiveOrOlder.length
if (next) {
return $http
.get({
@armw4
armw4 / array-flatten.js
Last active December 2, 2016 00:50
Integer flatten example while taking depth into account (via node version v7.1.0)
const flattenInternal = (input, initialDepth, acculamator = [], depth = 0) => {
if (initialDepth !== undefined && depth > initialDepth) {
throw new Error(`array has exceeded the target depth of ${initialDepth}.`)
}
return input.reduce((acc, value) => {
if (Array.isArray(value)) {
if (initialDepth !== undefined) {
return flattenInternal(value, initialDepth, acc, depth + 1)
}
@armw4
armw4 / mult-table.rb
Created November 10, 2016 13:33
Prints out a multiplication table. Written in Ruby for brevity. .NET equivalents in comments.
## To execute, install Ruby, download file, and run:
# ruby mult-table.rb
THREE_SPACES = ' ' * 3 # new String(' ', 3)
def print_header(rows)
print THREE_SPACES # Console.Write(...)
1.upto(rows) { |number| print "#{THREE_SPACES} #{number}" } # String.Format(...)
puts # Console.WriteLine(...)
end
@armw4
armw4 / yank-copy-paste-not-working-tmux-vim.md
Last active October 8, 2016 13:51
Yank not working in Vim/MacVim.

by Antwan Wimberly

I recently encountered issues with yanking text in Vim. Yup, you know it, the infamous

***E353: Nothing in register ****

Only problem was, I wasn't sure if the issue was MacVim or spf13. Before logging an issue in either project, I decided to do a little research in hopes that someone had encountered a similar problem in the past. Luckily I can across this article by googling

macvim cant yank text

@armw4
armw4 / number-closest-to-average.md
Last active May 18, 2016 23:49
Question 5/6 of my Latest Programming Assessment

I only had 45 minutes in total to finish the entire assessment, but this was question 5/6. I ran out of time before submitting my final answer (which I'm disappointed in). Once the challenge was over, I thought more about the solution to the problem and was able to figure it out. What made the challenge more tricky is that the input was coming in from standard input and being buffered via the data event. Seeing this in node just kinda freaks you out when you're racing against time. All you can think is 😳. The authors of the assessment were kind enough to register the required event handlers for accumalating the input, and even provided the location of where to act on the final, fully buffered version of the input (I believe this was the 'end' event). Yes, stdin is a stream in node, and as a result, an event emitter. I'd still have run out of time even if I were able to fully derive my solution, as this took me at least 20 minutes of heuristics with a clear head, after the fact. That's pretty shocking.

@armw4
armw4 / streaming-request-node.md
Last active May 10, 2016 06:16
Streaming http resources with node via request

Streaming Resources in node With request From Source to Destination

The Beginning

If you've ever worked with http in node what you quickly come to realize is that it's not all that straightforward. You'll be bold, at least initially. Like me, you'll go read up on the docs for the http module. You'll properly subscribe to all the right events like on('data), and feel good about yourself. But if you're anything like be, you're bound do this wrong at some point. You probably won't subscribe to all the right things in the right order. You might not properly buffer the response. You may just have a WTF moment in production on day that brings down your entire site (just like I did about 2 years ago). Whatever the case may be, I believe you'll ultimately just settle on using request as your go to for http. If you want a promise based variant then you might go with some wrapper library as well.

So, we know request is the hip way of doing HTTP in node. request is kool. It's got a ton of usage and it pretty

@armw4
armw4 / npm.md
Last active February 21, 2016 06:51
It's all about the last published date

Why?

Why...why are we here good sir? Well...I don't want to be here right now. I really don't. It's Saturday night, the Warriors beat the Clippers by the hair on the chinnies and dodged a late fourth quarter comeback, and I really want to eat. But...I have to blog. I have to do it now. If I don't, this story will not be the same. Why are we here? Because I'm on production support, that's why. I got an email from pagerduty that was like:

Unhandled rejection TypeError: next is not a function

I'm like huh? Wtf. What broke now? Why now? It's the weekend, I don't want to be here. I want to do me!!!!! But...I'm on production