<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Marco on Medium]]></title>
        <description><![CDATA[Stories by Marco on Medium]]></description>
        <link>https://medium.com/@nycmarcopolo?source=rss-805ee954dc6f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*D4_YbY7v1-FQQl1U.jpeg</url>
            <title>Stories by Marco on Medium</title>
            <link>https://medium.com/@nycmarcopolo?source=rss-805ee954dc6f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 10:12:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nycmarcopolo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[October 6th. My Near-Death Anniversary]]></title>
            <link>https://medium.com/@nycmarcopolo/october-6th-my-near-death-anniversary-f39dd496a415?source=rss-805ee954dc6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f39dd496a415</guid>
            <dc:creator><![CDATA[Marco]]></dc:creator>
            <pubDate>Tue, 07 Oct 2014 03:59:22 GMT</pubDate>
            <atom:updated>2014-10-07T13:13:43.038Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s been a full year since the accident that left me writhing in agony on the side of the road, just half a block from my New York City apartment. As I lay helplessly on the street, unable to move because of the pain, I knew instantly that something wasn’t right with my back. When it’s your bike vs. a speeding livery cab, you’re the one found wanting.</p><p>My immediate thought was that I might be paralyzed. I had just rolled over and been thrown from a speeding vehicle. I panicked internally for a long moment before I decided I had to know if I could move my toes. Through the stabbing pain that was shooting up and down my spine, I mustered up the mental courage to try and wiggle my toes.</p><p>Success.</p><p>But I was still far from relieved. What if this was temporary? I could still lose the ability the walk if my back twists half an inch the wrong way. I imagined an x-ray of shattered spine — my spine and my life if I were to be confined to a wheelchair. Was that better than being dead? I supposed I didn’t have to think of that alternative quite yet.</p><p>People started to gather. Shouting to me if I was ‘OK’ (or so it seemed), shouting to each other (clearly about me and what had just happened on a usually busy intersection in Central Harlem). I couldn’t listen to them over my own racing thoughts. The only response from me they received were the pathetic whimpers of pain and fear that I had been making for what seemed like an eternity now. I was still on the street and in excruciating pain. Someone said they were calling 911. Good. I didn’t have to, but I had to tell someone I knew.</p><p>October 6 had started so unassumingly. It had been a quiet, fall Sunday, and my boyfriend, Andrew invited me to his friend’s place in Chelsea to play card games, but I had already decided I wanted to ride my new bike before the season got too cold. I had already been biking around the city several times since I got the bike in September. Picking up groceries at the Fairway Market across town, in Harlem, up and down the gorgeous Greenway Park on the city’s west side, and through Central Park. I figured I could compromise on riding my bike in Central Park and agreed to ride my bike down to meet them.</p><p>It was approximately 7.5 miles, 125 city blocks away. Thinking about that now, I’m a bit shocked and impressed at the distance. It was the longest trip I had made in the city on my bike to date. It was a great feeling when I arrived. I played a few games of “Cards Against Humanity” and my team won a round (or two) of the game, “Heads Up!” I excused myself early since I had to make the trip back home on my bike. The sun had already set. Andrew stayed in Chelsea. He was too far to get to me in time.</p><p>Who could I call? My roommate might be home. My apartment was only half a block from where I was. No answer. I called my upstairs neighbor, Omar. No answer. The next closest friend was about 10 minutes away in Hamilton Heights. He probably even couldn’t get to me before the ambulance, but I was growing desperate. I called. No answer. I was alone. No one else could remotely get to me in time, and no one was answering the phone. Oh, Millennials — perhaps I should have tried to mass text them (seriously, the thought crossed my mind). I made another round of calls. And another. Finally, Omar answered.</p><p>How do you communicate to someone that you just got hit by a cab, you don’t have time to answer their questions, but need them to come down to the end of the block, right now? The wails of fast-approaching sirens joined my inner thoughts. I looked over towards the black cab that had hit me. My bike lay in the street several yards ahead of it. I could tell the front tire was mangled, even from my low vantage point. Omar arrived quickly and visibly alarmed. Finally. The ambulance arrived soon after Omar, or just before. I don’t recall anymore. I assured him that I was going to be OK.</p><p>Before Omar rushed my damaged bike back to his apartment, I gave him my helmet to take with him. I wasn’t going to need it anymore. The EMT’s strapped me into a red board, like you see in the movies, being ever so careful with my compromised body. While an EMT started taking my information and asking me questions, I finally broke down in tears. I was in the back of an ambulance, and this was really happening.</p><p>I was scared, and all my thoughts came to a head. I was unemployed at the time and taking full-time development classes at General Assembly. How was I supposed to tell my mother what happened? I can’t miss any days of class, or I’d miss something important and won’t be able to catch up. How am I supposed to afford an ambulance ride and an ER visit with no health insurance? Am I ever going to be able to walk back into my apartment or around the city I love? Will I become a burden to my friends and loved ones? What if I can’t finish the classes I just started in an effort to change my career into something I was finally interested in? Is this the end of life, as I knew it?</p><p>“I don’t have any health insurance,” I confessed as I focused back on the EMT looking over me with tears in my eyes. He gave me a comforting smile and assured me it was fine, and that the important thing was that I focus on getting better. Omar hopped into the back of the ambulance, and we sped off to Harlem Hospital. I had been so close to home, but I wasn’t going to make it there that night, or until the following Friday to be exact.</p><p>The EMT in the back of the ambulance and the ER doctor both told me that my helmet saved my life. One of the clearest memories I have of the accident is of flipping off the side of the cab, headfirst. I saw the asphalt rapidly approaching my face, and the only control I had of my body in that moment was to tuck my head down so that the lip of the helmet smashed against the cold hard street, instead of my face.</p><p>I had a lot of time to think about my own mortality for a while, in the hospital and while I was on bed rest in my apartment. I thought about how fragile life really is. How precious is can be. Sometimes, I still wonder when I’m with my friends how their conversations would be if I weren’t there any more. Whether they would miss me or if I would be quickly forgotten, like a rainy day in September. Then, I remember how they rallied to my side when I was unable to go out. Visiting me in the hospital or coming to my apartment, armed with board games and gifts to cheer me up. The thought still makes me smile, and feel quite humbled to have such supportive friends.</p><p>I ended up with a pressure fracture to my L1 lumbar spine, a smaller fracture in my tailbone and left me with limited mobility and in a back brace for months. I was lucky in that my lumbar fracture was on the anterior side, rather than the posterior, where all my spinal cord and nerves run.</p><p>Since then, life has certainly worked out for the better! I have a wonderful support system: Andrew, my family, and my wonderful friends. I ended up starting classes at General Assembly again in January and graduated in April of this year. I started an incredible job as a developer at an exciting startup, Sprinklr.</p><p>I’ve also been happy about the changes that I’ve seen in my city over the past year. New York City Mayor Bill de Blasio was elected with a bold Vision Zero stance that envisions a city with zero car deaths (it’s modeled from a similar program in Sweden). City construction workers tore up and widened the tip of the meridian on my block where I was hit and a few neighboring blocks along Adam Clayton Powell, which is well known for its speeding problems. The new intersections create an illusion for drivers that the road is narrowing in on them, causing drivers to naturally slow down. I am happy to see it. I have to admit, as a result of the accident, I’m even more against cars and traffic-focused development, and I’m even more of a proponent for walk-able urban cities with good public transportation. Intersections still scare me. And yes, I got back on a bike this summer on the Greenway, and I plan to ride one again someday.</p><p>Today has been such an unassuming day. Just like October 6th, one year ago. Looking back, I count myself lucky, and will make sure to keep this day in my mind like a reminder to cherish what I have and live my life to the fullest.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f39dd496a415" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Redis Into Your Rails Application]]></title>
            <link>https://medium.com/@nycmarcopolo/implementing-redis-into-your-rails-application-c57f44f80b73?source=rss-805ee954dc6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c57f44f80b73</guid>
            <dc:creator><![CDATA[Marco]]></dc:creator>
            <pubDate>Sun, 30 Mar 2014 22:30:16 GMT</pubDate>
            <atom:updated>2014-03-30T22:30:16.069Z</atom:updated>
            <content:encoded><![CDATA[<h4>How this new web developer chose a no-SQL db and set it up in my rails application</h4><h4><strong>The Data Storage Challenge</strong></h4><p>For my group’s second project as part of General Assembly’s WDI program we enthusiastically set out to build a Ruby on Rails application to model an online version of the game Scattergories.</p><p>Once we started drawing out the ERD (Entities-Relationship Diagram) for the game, we quickly realized that using the built-in SQL database included in Rails was an inadequate way to store our players’ answers and scores. We also needed to persist player data only for the duration of the game itself. However, we still couldn’t store the data in the players’ local storage. It had to be sent to the server in order to be shared with other players on remote connections.</p><p>SQL’s table structure also didn’t allow us to efficiently store and access player data without iterating through an entire row or column, which would be very slow and provide us with many opportunities for error. If we had a game with three rounds, that structure would become even more complex to save and access each players’ data.</p><p>Redis offered us exactly the data structure we needed. It is an advanced key-value database that let us structure our player responses in a more effective manner. Redis data types include strings, hashes, lists, sets, and sorted sets. Below are some common uses of these data types. For a comprehensive look at commands for each data type, please visit <a href="http://redis.io/">redis.io</a> and click the ‘Commands’ tab.</p><h4><strong>Setting and Getting Strings</strong></h4><p>You can set a string as the value of any key. Each key in a key-string relationship can only have a single string value. If you try to set another string, the value will be overwritten by the newest string.</p><pre>redis&gt; SET keyExample &quot;string&quot; <br><em>OK</em><br>redis&gt; GET keyExample<br><em>&quot;string&quot;<br></em>redis&gt; SET keyExample &quot;another string&quot; <br><em>OK</em><br>redis&gt; GET keyExample<br><em>&quot;another string&quot;</em></pre><h4><strong>Using Counters</strong></h4><p>Use INCR or DECR to increment or decrement the counter by one, respectively. You can also use INCRBY or DECRBY with a number to add or subtract that number from the counter.</p><pre>redis&gt; SET counterExample 1<br><em>OK</em><br>redis&gt; INCR counterExample<br><em>(integer) 2</em><br>redis&gt; INCRBY counterExample 5<br><em>(integer) 7<br></em>redis&gt; DECRBY counterExample 3<br><em>(integer) 4</em></pre><h4><strong>Lists</strong></h4><p>Lists act much like arrays in Ruby. You can use LPUSH/RPUSH to push items into the list or LPOP/RPOP to remove and return the first or last items of the array, respectively. LRANGE will give you a specific range of items in your list by providing a start and end point. The first argument should be your starting point (don’t forget that computers start counting from zero!), and the second argument should be the end point. To always get the end point of your list, regardless of how many items are in it, you would use -1, which starts counting from the last item in the list.</p><pre>redis&gt; LPUSH listExample &quot;one&quot;<br><em>(integer) 1<br></em>redis&gt; LPUSH listExample &quot;two&quot;<br><em>(integer) 2<br></em>redis&gt; RPUSH listExample &quot;three&quot;<br><em>(integer) 3<br>redis&gt; LRANGE listExample 0 -1<br>1) &quot;two&quot;<br>2) &quot;one&quot;<br>3) &quot;three&quot;</em><br>redis&gt; LPOP listExample<br><em>&quot;two&quot;<br></em>redis&gt; LRANGE listExample 0 -1<br><em>1) &quot;one&quot;<br>2) &quot;three&quot;</em></pre><h4><strong>Sets</strong></h4><p>Unlike regular key-value pairs that take only one value, sets can have several, unique strings as values. The values are not sorted like lists, and therefore can’t have duplicate members. Use SADD/SREM to add or remove a set’s values. SMEMBERS will return all the members in a set.</p><pre>redis&gt; SADD setExample &quot;one&quot;<br><em>(integer) 1<br></em>redis&gt; SADD setExample &quot;two&quot; &quot;three&quot;<br><em>(integer) 2<br></em>redis&gt; SMEMBERS setExample<br><em>1) &quot;one&quot;<br>2) &quot;two&quot;<br>3) &quot;three&quot;<br></em>redis&gt; SREM setExample &quot;two&quot;<br><em>(integer) 1<br></em>redis&gt; SMEMBERS setExample<em><br>1) &quot;one&quot;<br>2) &quot;three&quot;</em></pre><h4><strong>Sorted Sets</strong></h4><p>Sorted sets are much like normal sets, with the exception that they include a score that can be updated. Use ZADD to add a score and string to a sorted set. ZRANGE also takes arguments to give the beginning and ending of the range. It returns the items in ascending order by score, or by lexicographical order for items with the same score. ZSCORE returns the score of a given item.</p><pre>redis&gt; ZADD ssExample 2 &quot;one&quot;<br><em>(integer) 1<br></em>redis&gt; ZADD ssExample 2 &quot;two&quot;<br><em>(integer) 1<br></em>redis&gt; ZADD ssExample 2 &quot;three&quot;<br><em>(integer) 1<br></em>redis&gt; ZRANGE ssExample 0 -1<br><em>1) &quot;one&quot;<br>2) &quot;three&quot;<br>3) &quot;two&quot;</em><br>redis&gt; ZINCRBY ssExample 5 &quot;three&quot;<br><em>&quot;7&quot;</em><br>redis&gt; ZSCORE ssExample &quot;two&quot;<br><em>&quot;2&quot;</em><br>redis&gt; ZRANGE ssExample 0 -1 <br><em>1) &quot;one&quot;<br>2) &quot;two&quot;<br>3) &quot;three&quot;</em></pre><h4><strong>Hashes</strong></h4><p>Our group ultimately decided to store our players’ data in hashes. Hashes have a unique hash name, but also require unique key and value pairs. Use HSET/HGET to set or get data from hashes, respectively. HGETALL will get all the key-value sets in your hash.</p><pre>redis&gt; HSET hashExample key1 &quot;one&quot;<br><em>(Integer) 1<br></em>redis&gt; HSET hashExample key2 &quot;two&quot;<br><em>(Integer) 1<br></em>redis&gt; HSET hashExample key3 &quot;three&quot;<br><em>(Integer) 1</em><br>redis&gt; HGET hashExample key2<br><em>&quot;two&quot;<br></em>redis&gt; HGETALL hashExample<br><em>1) &quot;key1&quot;<br>2) &quot;one&quot;<br>3) &quot;key2&quot;<br>4) &quot;two&quot;<br>5) &quot;key3&quot;<br>6) &quot;three&quot;</em></pre><h4>Setting Up Redis In Rails</h4><p>There are a few easy steps you should follow in order to set up Redis into your Rails application. I installed it into Rails version 4.0.3 using Ruby 2.1.0.</p><p><strong>Step 1</strong></p><p>Install Redis onto your computer by running the following into your command line:</p><pre>gem install redis</pre><p>The Redis gem (<a href="https://github.com/redis/redis-rb">redis-rb</a>) is a Ruby client for Redis. Additional documentation can be found here: <a href="https://github.com/redis/redis-rb">https://github.com/redis/redis-rb</a>.</p><p><strong>Step 2</strong></p><p>To access Redis commands from your command line, you need to have <a href="http://brew.sh/">Homebrew</a> installed. If installed, you can Install Redis commands by typing into your command line:</p><pre>brew install redis</pre><p><strong>Step 3</strong></p><p>Next, you need to set up your application. Go into your Rails Gemfile and add:</p><pre>gem &#39;redis&#39;</pre><p>Make sure to bundle install after you’ve added it by typing into your command line:</p><pre>bundle install</pre><p><strong>Step 4</strong></p><p>While in development, add a new file into your config/initializers called redis.rb. Open redis.rb and write:</p><pre>$redis <strong>=</strong> Redis<strong>.</strong>new(host: &#39;localhost&#39;, port: 6379)</pre><p>Port 6379 is Redis’ default port to listen for updates.</p><p><strong>Step 5</strong></p><p>The last thing you need to do is run your Redis server. You can start it up if you’re running locally by typing into your command line:</p><pre>redis-sever</pre><p>or if you’re running off a remote server:</p><pre>redis-server /path/to/redis.conf</pre><h4>Redis Tips</h4><p>When writing code or typing into the Rails Console (or other environments not inside of Redis), the command syntax changes. Instead of typing:</p><pre>redis&gt; SET setName &quot;string&quot;</pre><p>You should type:</p><pre>railsConsole&gt; $redis.SET(setName, &quot;string&quot;)</pre><p>If you only want to use Redis as a cache store like we did, you can set your data to expire. Use EXPIRE to set how many seconds to keep the data before it expires. TTL will give you the number of seconds left until the data deleted from Redis. PERSIST will remove a set expiration.</p><pre>redis&gt; SET setName &quot;string&quot;<br><em>OK<br></em>redis&gt; EXPIRE setName 10<br><em>(integer) 1<br></em>redis&gt; TTL setName<br><em>(integer) 6<br></em>redis&gt; GET setName<br>&quot;string&quot; <br>redis&gt; TTL setName<br><em>(integer) 1<br></em>redis&gt; GET setName<br><em>(nil) </em></pre><h4><strong>Conclusion</strong></h4><p>Please let me know if you have any questions setting up Redis in Rails!</p><p>My group project version of Scattergories is still under development, but it’s current iteration is hosted by Heroku. It is currently a pass &amp; play game, but we hope to continue working on it once WDI is finished so it can be played by players on two to four different computers simultaneously.</p><p>Play it here: <a href="http://scattergories.herokuapp.com/">http://scattergories.herokuapp.com/</a>.</p><p>You can check out our code here: <a href="https://github.com/jmhinric/mj4">https://github.com/jmhinric/mj4</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c57f44f80b73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[No API? No Problem.]]></title>
            <link>https://medium.com/@nycmarcopolo/no-api-no-problem-be7b1524dd5e?source=rss-805ee954dc6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/be7b1524dd5e</guid>
            <dc:creator><![CDATA[Marco]]></dc:creator>
            <pubDate>Mon, 24 Feb 2014 04:46:40 GMT</pubDate>
            <atom:updated>2014-02-24T17:02:31.030Z</atom:updated>
            <content:encoded><![CDATA[<h4>How I Used Nokogiri To Get (Scrape) The Information I needed</h4><p>Everyone knows that finding an apartment in New York City can be a nightmare, but I consider the discovery part of the process one of the most fascinating of living in this city. It’s what inspired my first Ruby on Rails (RoR) project in the Web Development Immersive (WDI) course at <a href="https://generalassemb.ly/">General Assembly</a>. As I wandered and explored the myriad of unique neighborhoods, I wanted to be able to see what apartments were available right there, how much they were and whether or not I could afford to move there. Spoiler alert — I couldn’t.</p><p>I selected <a href="http://streeteasy.com/nyc/rentals">StreetEasy</a> to be the website I based my search on because of my personal experience with it — I liked the fact that it is one of the few websites that list apartments with the actual address of its buildings, which limits the number of fraudulent listings. Or at least makes them more obvious.</p><p>The problem is their API call only returns aggregated information about their apartments and not the individual listings themselves. I looked for other rental websites, but couldn’t find another one with a good framework for listing New York City apartments — let alone one that offered their listings to other applications via API. I quickly determined that I needed to be able to scrape the website and focused on a gem called <a href="http://nokogiri.org/">Nokogiri</a>.</p><p>Nokogiri works by pulling in data from a website that was once human readable via HTML on a webpage and parses it down in order to extract the information we want. In my case, I wanted to implement a feature that allowed users to view apartment listings given a few set parameters.</p><p>Nokogiri’s documentation can be pretty confusing, so I searched online for other tutorials on implementation. I found an excellent <a href="http://youtu.be/PWI1PIvy4A8">YouTube video</a> on data scraping with Nokogiri that I would highly recommend to anyone looking to implement this it. Ultimately, I was able to get the information I needed by using just a few commands/Nokogiri methods.</p><p>After receiving errors from Nokogiri, I discovered that I needed to encode the URL I wanted to scrape because the program couldn’t identify certain characters. The link itself recognizes parameters (params) from a submitted form to search for listings, and I saved that encoded URL into the variable, encoded_url — shown below.</p><pre>encoded_url = URI.encode(&quot;<a href="http://streeteasy.com/nyc/for-rent/nyc/status:open%7Cprice:#">http://streeteasy.com/nyc/for-rent/nyc/status:open%7Cprice:#</a>{params[:min_price]}-#{params[:max_price]}%7Czip:#{params[:zip]}%7Cbeds:#{params[:beds]}%7Cbaths&gt;=#{params[:baths]}&quot;)</pre><pre>listings = Nokogiri::HTML(open(encoded_url)).css(&#39;.item_inner&#39;)</pre><p>The listings variable is where I saved the actual data (or nodes) that I received from the Nokogiri call. The .css method searches the HTML data for styling classes. In my case, all the information I needed was found in the styling div called ‘.item_inner’. From that method call, everything else outside of that div/node was scrapped.</p><p>For each listing that was returned in the data call, I iterated through and pulled certain data and set it to the hash variable, ‘output’, illustrated below. I pulled the data from the div style called ‘details_info’ and grabbed the price from a span called ‘price’. The .inner_html method finds only the raw text and returns that value. In the case below, the price of the apartment.</p><pre>output = {}</pre><pre>output[:price] = listing.css(&quot;div.details_info span.price&quot;).inner_html</pre><p>Other useful Nokogiri methods are .at_css which returns the first node with the CSS tag you specify.</p><p>The .attr method (below) finds an attribute within a given tag, such as a ‘href’ and returns the whole node. If you use the .value method on it, it will return the value of what is in that href. In my case, a link.</p><pre> link = listing.css(&quot;div.photo a&quot;).attr(&quot;href&quot;).value</pre><p>The .to_xpath method searches for a particular URL path and returns whatever it finds from a given argument. The URL path is prefixed with ‘//’.</p><p>My application is called <a href="http://apt-alert-nyc.herokuapp.com/">AptAlertNYC</a> and is still currently under development. In its current iteration, it will find apartment listings in an area using a given zip code. Features that I intend on implementing include a notification system that lets you know when a new apartment is listed and to set your location by your current GPD coordinates as the search area.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be7b1524dd5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>