<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Valentino Stoll</title>
    <description>The latest articles on DEV Community by Valentino Stoll (@codenamev).</description>
    <link>https://dev.to/codenamev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F144149%2F45015252-4648-4941-8a41-7cc35e795281.png</url>
      <title>DEV Community: Valentino Stoll</title>
      <link>https://dev.to/codenamev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codenamev"/>
    <language>en</language>
    <item>
      <title>Twilio Powered Minecraft Server on AWS</title>
      <dc:creator>Valentino Stoll</dc:creator>
      <pubDate>Tue, 28 Apr 2020 01:33:23 +0000</pubDate>
      <link>https://dev.to/codenamev/twilio-powered-minecraft-server-on-aws-47l6</link>
      <guid>https://dev.to/codenamev/twilio-powered-minecraft-server-on-aws-47l6</guid>
      <description>&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;A way to control access to a Minecraft server hosted on an EC2 instance via SMS.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FmWEtXYZ.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FmWEtXYZ.gif" alt="Demo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;This all came about when my kids wanted to play Minecraft with their friends.  While Realms seemed like a decent choice, I wanted something with more control and a way to allow other parents to easily add their kid(s) and start/stop the server.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Full Picture
&lt;/h2&gt;

&lt;p&gt;An administrator sends an SMS to a Twilio number with a command (e.g. &lt;code&gt;status&lt;/code&gt;).  Twilio then sends an incoming SMS web request to an Amazon API Gateway endpoint.  This endpoint hands off the Twilio event and request data to an AWS Lambda function which validates and processes the command to perform one of the following:&lt;/p&gt;

&lt;p&gt;1) &lt;code&gt;startup&lt;/code&gt; – Starts the EC2 instance.&lt;br&gt;
2) &lt;code&gt;shutdown&lt;/code&gt; – Stops the EC2 instance.&lt;br&gt;
3) &lt;code&gt;whitelist add 1.2.3.4 as beetlejuice&lt;/code&gt; – Allows a new user to connect to the Minecraft Server.&lt;br&gt;
4) &lt;code&gt;whitelist remove 1.2.3.4&lt;/code&gt; – Dis-allows an existing user from connecting to the Minecraft Server.&lt;br&gt;
5) &lt;code&gt;status&lt;/code&gt; – Check the status to see if the instance is running.&lt;/p&gt;

&lt;p&gt;Introducing:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/codenamev" rel="noopener noreferrer"&gt;
        codenamev
      &lt;/a&gt; / &lt;a href="https://github.com/codenamev/twilio-aws-minecraft" rel="noopener noreferrer"&gt;
        twilio-aws-minecraft
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Control a minecraft server in AWS via Twilio SMS
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://medium.com/exampro/2018-modded-minecraft-server-on-aws-part-1-run-a-modded-minecraft-server-on-aws-ec2-instance-b37290462d8d" rel="noopener noreferrer"&gt;setting up a Minecraft Server 
on an EC2 instance&lt;/a&gt;.  I hope to update this at some point with a slimmer set of instructions that I now use, but this got me where I needed.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.twilio.com/docs/sms/tutorials/how-to-receive-and-reply-python-amazon-lambda" rel="noopener noreferrer"&gt;Set up a Lambda to receive Twilio events&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With the above in place, you should have a working Minecraft Server running in EC2, and a simple Lambda setup with the API Gateway to receive events from Twilio.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lambda Environment Variables
&lt;/h3&gt;

&lt;p&gt;Make sure to add the following environment variables to your Lambda function:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Key&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ADMIN_NUMBERS&lt;/td&gt;
&lt;td&gt;A comma delimited list of administrator phone numbers (e.g. &lt;code&gt;+12125552368,+12125551234&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TWILIO_ACCOUNT_SID&lt;/td&gt;
&lt;td&gt;Your primary Twilio account identifier - find this &lt;a href="https://www.twilio.com/console" rel="noopener noreferrer"&gt;in the Console&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TWILIO_AUTH_TOKEN&lt;/td&gt;
&lt;td&gt;Used to authenticate - &lt;a href="https://www.twilio.com/console" rel="noopener noreferrer"&gt;just like the above, you'll find this here&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;EC2_INSTANCE_ID&lt;/td&gt;
&lt;td&gt;The ID of the EC2 Instance you created above. &lt;a href="https://console.aws.amazon.com/ec2/v2/home" rel="noopener noreferrer"&gt;You can find it here&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;EC2_REGION&lt;/td&gt;
&lt;td&gt;The region your EC2 instance is running in (e.g. &lt;code&gt;us-east-1b&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;EC2_SECURITY_GROUP_ID&lt;/td&gt;
&lt;td&gt;The ID of the security group that is assigned to the EC2 Instance (e.g. &lt;code&gt;sg-1234567ab89cd0987&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TWILIO_NUMBER&lt;/td&gt;
&lt;td&gt;the Twilio phone number you setup to receive SMS (e.g. &lt;code&gt;+12125552368&lt;/code&gt;, also found in your &lt;a href="https://www.twilio.com/console" rel="noopener noreferrer"&gt;Twilio Console&lt;/a&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MINECRAFT_HOST&lt;/td&gt;
&lt;td&gt;The server domain or IP that points to your Minecraft Server (e.g. &lt;code&gt;minecraft.example.com&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MINECRAFT_PORT&lt;/td&gt;
&lt;td&gt;e.g. &lt;code&gt;25565&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;REQUEST_URL&lt;/td&gt;
&lt;td&gt;The API Gateway endpoint you setup for the Lambda function and added as the SMS incoming webhook (e.g. &lt;code&gt;https://1somehash23.execute-api.us-east-1.amazonaws.com/prod/message&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Lambda permissions
&lt;/h3&gt;

&lt;p&gt;You will have to add the following actions to the permissions for your Lambda function:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ec2:AuthorizeSecurityGroupIngress&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Allows adding new IPs to the server whitelist&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ec2:DescribeInstanceStatus&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Allows checking the status of the instance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ec2:DescribeSecurityGroups&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Allows looking for existing IPs in the server whitelist&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ec2:RevokeSecurityGroupIngress&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Allows removing a whitelisted IP from the server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ec2:StartInstances&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Allows starting the instance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ec2:StopInstances&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Allows stopping the instance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;logs:CreateLogStream&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Allows capturing output to logs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;logs:PutLogEvents&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Allows saving log events&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Next, you'll want to checkout my twilio-aws-minecraft repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/codenamev/twilio-aws-minecraft.git &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;twilio-aws-minecraft &lt;span class="se"&gt;\&lt;/span&gt;
zip &lt;span class="nt"&gt;-r&lt;/span&gt; twilio_function.zip ./
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That will create a packaged lambda script with all required libraries in .zip form that you can upload to replace the existing Lambda script you created in the previous step.&lt;/p&gt;

&lt;p&gt;Once you've saved the newly uploaded Lambda and deployed, you can test out your new EC2 manager via SMS!&lt;/p&gt;

&lt;p&gt;Somessues I faced:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lambda IPs for EC2 whitelist&lt;/li&gt;
&lt;li&gt;Minecraft Forge and minecraft.service setup issues&lt;/li&gt;
&lt;li&gt;Instance startup not starting minecraft.service&lt;/li&gt;
&lt;li&gt;UserData&lt;/li&gt;
&lt;li&gt;GameMode(s)&lt;/li&gt;
&lt;li&gt;Configuring OPs&lt;/li&gt;
&lt;li&gt;Debugging&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>twiliohackathon</category>
    </item>
    <item>
      <title>How to Make Colors With Ruby and Bitwise Operations</title>
      <dc:creator>Valentino Stoll</dc:creator>
      <pubDate>Fri, 11 Oct 2019 21:05:00 +0000</pubDate>
      <link>https://dev.to/codenamev/how-to-make-colors-with-ruby-and-bitwise-operations-1i1e</link>
      <guid>https://dev.to/codenamev/how-to-make-colors-with-ruby-and-bitwise-operations-1i1e</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--etXYqXrK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.codenamev.com/content/images/2019/10/raspberry-pi-color-guess-web.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--etXYqXrK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.codenamev.com/content/images/2019/10/raspberry-pi-color-guess-web.jpg" alt="How to Make Colors With Ruby and Bitwise Operations"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In our last lesson, we utilized the badass (P)ulse (W)idth (M)odulation tech to breathe life into a simple LED.  Here, we're going to take this to new levels and apply it to &lt;em&gt;multiple channels&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Unfortunately, the PWM hardware included with the Raspberry B+ is only capable of communicating over a &lt;em&gt;single channel&lt;/em&gt;.  Since we have 3 channels we need to talk to (for each of our three colors), we'll have to go soft and crank this up with software: &lt;strong&gt;softPwm&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  First: How the RGB LED works
&lt;/h3&gt;

&lt;p&gt;The RGB LED I'm working with has four pins.  Three of these pins take input that control the brightness level for (R)ed, (G)reen, and (B)lue.  This allows us to take advantage of the &lt;a href="https://en.wikipedia.org/wiki/Additive_color"&gt;additive color system&lt;/a&gt; to create all kinds of colors by supplying different proportions of these three types of light (e.g. fully bright red and fully bright blue will appear purple).&lt;/p&gt;

&lt;p&gt;Our Problem: How can we easily store color values in RGB format as a percentage of luminance?&lt;/p&gt;

&lt;h3&gt;
  
  
  Hexadecimal To The Rescue!
&lt;/h3&gt;

&lt;p&gt;I know what you're thinking:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DmYrtMus--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.codenamev.com/content/images/2019/10/eye-roll.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DmYrtMus--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.codenamev.com/content/images/2019/10/eye-roll.gif" alt="How to Make Colors With Ruby and Bitwise Operations"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don't lose me just yet.  There's some hidden gold here!  The magic of bitwise operations.&lt;/p&gt;

&lt;p&gt;The binary &lt;code&gt;11111111&lt;/code&gt; is equal to &lt;code&gt;255&lt;/code&gt;.  Luckily for us, this binary representation maps perfectly to Hexadecimal, as &lt;code&gt;FF == 255&lt;/code&gt;!&lt;/p&gt;

&lt;p&gt;&lt;code&gt;11111111 00000000 00000000&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;RED        GREEN      BLUE&lt;/p&gt;

&lt;p&gt;What this means is that we can use &lt;a href="https://docs.ruby-lang.org/en/2.6.0/syntax/literals_rdoc.html#label-Numbers"&gt;Hexadecimal literals in Ruby&lt;/a&gt;, and as a result start to see some serious gains.  First off, Hexadecimal numbers make a lot of sense to us as colors already.  These are the Ruby equivalent of the CSS versions you might be familiar with:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Color&lt;/th&gt;
&lt;th&gt;Hexadecimal Representation in Ruby&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Red&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0xFF0000&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Green&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0x00FF00&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Blue&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0x0000FF&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Purple&lt;/td&gt;
&lt;td&gt;&lt;code&gt;0xFF00FF&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The real value here comes with the calculations we can make.  Using hexadecimal literals makes some things easier.  We can extract each red, green, or blue value from any given hexadecimal color by AND'ing the bits of the maxed out version of our target.&lt;/p&gt;

&lt;p&gt;Let's say we have the color &lt;code&gt;0xFF1133&lt;/code&gt; .  This has a binary form of:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;11111111 00010001 00110011&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We can extract the value of just the blue color &lt;code&gt;0x0000FF&lt;/code&gt; by using the bitwise AND (&lt;code&gt;&amp;amp;&lt;/code&gt;) operator to cancel out all non-blue bits.  So:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0xFF1133 &amp;amp; 0x0000FF == 0x000033&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is because all the &lt;code&gt;0&lt;/code&gt; bits in our pure blue color &lt;code&gt;0x0000FF&lt;/code&gt; override any bits set in any of the other color positions, and any &lt;code&gt;0&lt;/code&gt; bits in our &lt;code&gt;0xFF0033&lt;/code&gt; color override any &lt;code&gt;1&lt;/code&gt; bits in our pure blue.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  11111111 00010001 00110011
&amp;amp; 00000000 00000000 11111111
               ⇣
  00000000 00000000 00110011
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;This works great for our blue value, but for the others we have to take this one step further.  If we were to perform this same bitwise AND on the pure green color &lt;code&gt;0x00FF00&lt;/code&gt; then we will get what we want, except with a lot of trailing zeros.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  11111111 00010001 00110011
&amp;amp; 00000000 11111111 00000000
               ⇣
  00000000 00010001 00000000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;In order to target that middle section of the resulting bitwise operation, we need to shift the bits to the right to get rid of the extra zeros.  To do this, we can use the bitwise right shift operator &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; and push them eight places to the right.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;00000000 00010001 00000000 &amp;gt;&amp;gt; 8
             ⇣
00000000 00000000 00010001
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Bingo! Unity.&lt;/strong&gt;  With this in mind, we can translate it to Ruby and apply these lightning fast calculations to extract percentages of each RGB color value from a hexadecimal numeric:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Given the folowing color
color = 0x6495ED
percentage_blue = (color &amp;amp; 0x0000FF) * 100 / 255 # =&amp;gt; 92%
percentage_green = ((color &amp;amp; 0x00FF00) &amp;gt;&amp;gt; 8) * 100 / 255 # =&amp;gt; 58%
percentage_red = ((color &amp;amp; 0xFF0000) &amp;gt;&amp;gt; 16) * 100 / 255 # =&amp;gt; 39%
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  All Together Now
&lt;/h3&gt;

&lt;p&gt;Since the duty cycle value is essential the percentage that the signal will be ON, we can just extract the RGB color percentages from a hexadecimal color value and set these to the duty cycle of each RGB pin of the LED.&lt;/p&gt;

&lt;p&gt;Ok, ok, all this binary mumbo jumbo and all we get is a bunch of flashing colors!?  Let's turn the dial all the way up to eleven and add a simple twist: &lt;em&gt;have a button trigger a random color&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;BOOM!  We have made a game!  Guess what color the LED will be when you press the button?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JW8QwoAq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.codenamev.com/content/images/2019/10/raspberry-pi-color-guess-vid.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JW8QwoAq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.codenamev.com/content/images/2019/10/raspberry-pi-color-guess-vid.gif" alt="How to Make Colors With Ruby and Bitwise Operations"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;






&lt;p&gt;Special thank you to &lt;a href="https://www.calleerlandsson.com/rubys-bitwise-operators/"&gt;Calle Erlandsson's fantastic write-up on bitwise operations in Ruby&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>raspberrypi</category>
      <category>ruby</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>What is your favorite open source project?</title>
      <dc:creator>Valentino Stoll</dc:creator>
      <pubDate>Sat, 28 Sep 2019 00:11:43 +0000</pubDate>
      <link>https://dev.to/codenamev/what-is-your-favorite-open-source-project-2eg5</link>
      <guid>https://dev.to/codenamev/what-is-your-favorite-open-source-project-2eg5</guid>
      <description>&lt;p&gt;Gearing up for Hacktoberfest here.  Aren't you!?&lt;/p&gt;

&lt;p&gt;I'm sure I'm not alone in just jumping on GitHub come October and plucking the first few projects I find interesting.  Instead, I'd love to hear what projects people can't live without and hope I can help this time around.&lt;/p&gt;

&lt;p&gt;Personally, there are quite a few I depend on for day-to-day smooth workflows &lt;a href="https://github.com/reenhanced/gitreflow"&gt;git-reflow&lt;/a&gt;, &lt;a href="https://github.com/rubocop-hq/rubocop"&gt;rubocop&lt;/a&gt;/&lt;a href="https://github.com/testdouble/standard"&gt;standard&lt;/a&gt;, &lt;a href="https://github.com/rspec/rspec"&gt;rspec&lt;/a&gt;, &lt;a href="https://github.com/rails/rails"&gt;rails&lt;/a&gt;, &lt;a href="http://github.com/ruby/ruby"&gt;ruby&lt;/a&gt;.  What about you?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>hacktoberfest</category>
    </item>
    <item>
      <title>The Great Breathing Ruby LED</title>
      <dc:creator>Valentino Stoll</dc:creator>
      <pubDate>Fri, 27 Sep 2019 21:21:23 +0000</pubDate>
      <link>https://dev.to/codenamev/the-great-breathing-ruby-led-279f</link>
      <guid>https://dev.to/codenamev/the-great-breathing-ruby-led-279f</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This is part 4 in my &lt;a href="https://blog.codenamev.com/tag/sunfounder-super-kit/"&gt;Sunfounder Superkit series&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8gGutsnq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.codenamev.com/content/images/2019/09/raspberry-pi-blinking-led-web.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8gGutsnq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.codenamev.com/content/images/2019/09/raspberry-pi-blinking-led-web.jpeg" alt="The Great Breathing Ruby LED"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In our last experiment, you were &lt;em&gt;probably&lt;/em&gt; bedazzled by the alluring display of LEDs.  This time around, we'll go from bedazzling to mesmerizing and use sweet technological magic to make an LED &lt;strong&gt;breathe&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/n0WvhHFTpihk4/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/n0WvhHFTpihk4/giphy.gif" alt="magic"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Admittedly, not that kind of magic.  Lucky for you, I'm taking big risks, breaking the Magician's Code and revealing the secret behind the trick: &lt;strong&gt;&lt;a href="https://en.wikipedia.org/wiki/Pulse-width_modulation"&gt;Pulse Width Modulation&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pulse Width Modulation (PWM)
&lt;/h3&gt;

&lt;p&gt;To get a good understanding of what the heck this bad girl is, let's sprint down history lane and attempt to reproduce our results &lt;em&gt;analog style&lt;/em&gt;.  Before the wonderful invention of PWM, most electrical signals&lt;a href="https://en.wikipedia.org/wiki/Analog_signal"&gt;&lt;/a&gt;were handled continuously by analyzing voltage over time.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/11xGUPTi9iwXJK/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/11xGUPTi9iwXJK/giphy.gif" alt="analog signal"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://giphy.com/gifs/black-amp-white-sine-wave-11xGUPTi9iwXJK"&gt;via GIPHY&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you might imagine, this can lead to huge wastes in energy while constantly having to check for changes to the output voltage.  Most electronic applications will likely not need this continuous stream of signal, and to take advantage of this, the GPIO pins on the Raspberry Pi rely on &lt;a href="https://en.wikipedia.org/wiki/Digital_signal"&gt;&lt;em&gt;digital&lt;/em&gt; signals&lt;/a&gt;.  Instead of treating the signal as a continuous stream, digital signals stream a sequence of &lt;em&gt;discrete&lt;/em&gt; values.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/9VkaGX5OKCjrjjNi98/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/9VkaGX5OKCjrjjNi98/giphy.gif" alt="digital signal"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://giphy.com/gifs/creative-coding-touchdesigner-partyonmarz-9VkaGX5OKCjrjjNi98"&gt;via GIPHY&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ok, so where the hell does Pulse Width Modulation come in!?  PWM  takes advantage of these digital signals by rapidly turning the voltage off and then turning them on again to a slightly higher or lower voltage.  In our example, this choppy signal will simulate a smooth increase in voltage (LED getting brighter) or decrease in voltage (LED getting dimmer).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0rGOLjVx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.codenamev.com/content/images/2019/09/fading-led-pwm.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0rGOLjVx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.codenamev.com/content/images/2019/09/fading-led-pwm.gif" alt="The Great Breathing Ruby LED"&gt;&lt;/a&gt;Credit: &lt;a href="https://www.instructables.com/id/Fade-LED-Arduino-Analog-Output-Tinkercad/"&gt;&lt;/a&gt;&lt;a href="https://www.instructables.com/id/Fade-LED-Arduino-Analog-Output-Tinkercad/"&gt;https://www.instructables.com/id/Fade-LED-Arduino-Analog-Output-Tinkercad/&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  PWM with Ruby!
&lt;/h3&gt;

&lt;p&gt;Ok, enough with the circuits already, and on to the fun part: &lt;strong&gt;Ruby&lt;/strong&gt;!  Luckily for us, the &lt;code&gt;rpi_gpio&lt;/code&gt; gem comes with PWM built-in.  With a little elbow grease we can start the mesmerization process.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  Wrap Up
&lt;/h3&gt;

&lt;p&gt;We're really starting to dive into the embedded systems waters here.  PWM is a great way to finely control things we want to... modulate.  I'm out of ideas for alternatives on this one, but next time we'll take LEDs to new colored dimensions and I'll invent the simplest of games :-)&lt;/p&gt;

</description>
      <category>raspberrypi</category>
      <category>ruby</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Ruby Driven LED Arrays</title>
      <dc:creator>Valentino Stoll</dc:creator>
      <pubDate>Fri, 20 Sep 2019 21:08:00 +0000</pubDate>
      <link>https://dev.to/codenamev/ruby-driven-led-arrays-343m</link>
      <guid>https://dev.to/codenamev/ruby-driven-led-arrays-343m</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This is part 3 in my &lt;a href="https://blog.codenamev.com/tag/sunfounder-super-kit/"&gt;Sunfounder Superkit series&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We’ve blinked it, hooked it to a button, and now for some serious fun: &lt;em&gt;lots of them&lt;/em&gt;! This exercise really tests your patience with the breadboard.&lt;/p&gt;

&lt;p&gt;(1 LED + 1 resistor + 2 wires) * 8 = 24 things to plug in&lt;/p&gt;

&lt;p&gt;Once this was all setup (~15min), it looked great! I was really pumped to start playing around with so many twinkling lights!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aDLtxWyG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.codenamev.com/content/images/2019/09/raspberry-pi-led-array-web.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aDLtxWyG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.codenamev.com/content/images/2019/09/raspberry-pi-led-array-web.jpg" alt="Ruby Driven LED Arrays"&gt;&lt;/a&gt;Fully wired up LED array&lt;/p&gt;

&lt;h3&gt;
  
  
  The Ruby Journey Begins
&lt;/h3&gt;

&lt;p&gt;So I crack open the python script and start to pipe it into ruby, because Ruby. I get to the line where it sets up the LEDs with &lt;code&gt;rpi_gpio&lt;/code&gt; and what do I find? No multi-pin setup support.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/Ki9ZNTNS7aC9q/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/Ki9ZNTNS7aC9q/giphy.gif" alt="GASP"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I know what you’re thinking, “Just move on and test it with Python or C already”. Helllllll no! I didn’t make it all this way to have to mangle together some half-baked snake-oil code (in all fairness, the C code is quite nice to work with, and I did try it out before converting this **blush**).&lt;/p&gt;

&lt;p&gt;It’s time to pony it up and ride the open source winds into the sunset.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/2wfDH6nZQ58DS/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/2wfDH6nZQ58DS/giphy.gif" alt="Ride into the sunset"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fortunately, the &lt;a href="https://docs.ruby-lang.org/en/trunk/extension_rdoc.html"&gt;Ruby documentation on creating extension libraries&lt;/a&gt; is really spectacular. With a little fiddling, I was able to get a working multi-pin &lt;code&gt;GPIO.setup&lt;/code&gt; method, and &lt;a href="https://github.com/ClockVapor/rpi_gpio/pull/18"&gt;PR submitted&lt;/a&gt;.  Yay open source!&lt;/p&gt;

&lt;p&gt;Before the PR merged, I had to build the gem locally ( &lt;code&gt;rake compile&lt;/code&gt;) and reference it using the &lt;code&gt;gem “rpi_gpio", path: /path/to/local/rpi_gpio&lt;/code&gt; in my Gemfile.  I'll float by all the gripes I have with developing Ruby extensions and dive right into the goal: a real-life self-made majestic racing marquee!&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;So, that was a fun ride.  The creative corner of my brain came knocking through the wall like the Kool-aid man though.  I just &lt;em&gt;have&lt;/em&gt; to spin this drab loop into something a little more fun and, dare I say, &lt;em&gt;practical&lt;/em&gt;?&lt;/p&gt;

&lt;h3&gt;
  
  
  A Simple Binary Counter
&lt;/h3&gt;

&lt;p&gt;Ok, not the most amazingly-fantastic-best-idea-ever, but I'm looking for a &lt;em&gt;small twist&lt;/em&gt; to my existing example so I can escape the monotony of this textbook tutorial.  With our new lovely Ruby script, we can make some small tweaks and have our &lt;em&gt;LEDs&lt;/em&gt; count all the way to &lt;strong&gt;two hundred and fifty five&lt;/strong&gt; (&lt;a href="https://github.com/codenamev/ruby-pi/blob/master/binary_counter.rb"&gt;code here to save space&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6KV33Dot--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.codenamev.com/content/images/2019/09/raspberry-pi-binary-counter-min.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6KV33Dot--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.codenamev.com/content/images/2019/09/raspberry-pi-binary-counter-min.gif" alt="Ruby Driven LED Arrays"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Impressive, I know, but practical?  Well my creativity was oozing today (with this many twinkling lights how could it not!?) and discovered how I might be able to turn this into my new favorite desk toy.&lt;/p&gt;

&lt;h3&gt;
  
  
  To the Future and Beyond
&lt;/h3&gt;

&lt;p&gt;I'm a pretty big fan of the &lt;a href="https://francescocirillo.com/pages/pomodoro-technique"&gt;Pomodoro Technique&lt;/a&gt;, and since I now made something that can count, I'll likely jack this bad girl up and spin this sweet little counter into a meaningful meter for time spent.  A visual Pomodoro Meter if you will.&lt;/p&gt;

&lt;p&gt;Or maybe, instead of counting time, it could count the number of PRs I have open on GitHub.  So many possibilities!  &lt;/p&gt;

&lt;p&gt;Well that's all for now folks.  I hope you enjoyed the sunset.  If you decide to boldly clone this and make something of your own I'd love to hear about it :-)&lt;/p&gt;

&lt;p&gt;Tune in next week, where I venture into mutli-colored LED land and a slowly pulsing light show.&lt;/p&gt;

</description>
      <category>raspberrypi</category>
      <category>ruby</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Ruby driven Raspberry Pi buttons</title>
      <dc:creator>Valentino Stoll</dc:creator>
      <pubDate>Fri, 13 Sep 2019 21:00:00 +0000</pubDate>
      <link>https://dev.to/codenamev/ruby-driven-raspberry-pi-buttons-5344</link>
      <guid>https://dev.to/codenamev/ruby-driven-raspberry-pi-buttons-5344</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This is part 2 in my &lt;a href="https://blog.codenamev.com/tag/sunfounder-super-kit/" rel="noopener noreferrer"&gt;Sunfounder Superkit series&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Blinking an LED was too easy!  Let's make this piece interactive.  Buttons are exactly the magic I'm looking for.  Push it, and do &lt;em&gt;something.  ANYTHING&lt;/em&gt;!  Let's keep it simple and build off of our first simple LED hookup.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.codenamev.com%2Fcontent%2Fimages%2F2019%2F09%2Fraspberry-pi-button-led-1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.codenamev.com%2Fcontent%2Fimages%2F2019%2F09%2Fraspberry-pi-button-led-1.jpg" alt="Ruby driven Raspberry Pi buttons"&gt;&lt;/a&gt;Wiring a button to an LED on a Raspberry Pi B+&lt;/p&gt;

&lt;p&gt;With that in place, and a little Ruby script, we can loop in the button to join the LED blinking fun.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  The Great Ruby Takeaways
&lt;/h2&gt;

&lt;p&gt;Ok, so maybe the circuit is not &lt;em&gt;that&lt;/em&gt; exciting, but this is just the start!  With this we've gained some exposure to both listening in on and controlling the state of GPIO pins.  Writing this script also introduces us to some great aspects of working with Ruby programs from a lower level.&lt;/p&gt;

&lt;h3&gt;
  
  
  IO#flush and IO#sync
&lt;/h3&gt;

&lt;p&gt;Firstly, &lt;a href="https://ruby-doc.org/core-2.6.4/IO.html#method-i-flush" rel="noopener noreferrer"&gt;&lt;code&gt;STDOUT.flush&lt;/code&gt;&lt;/a&gt;.  This will clear any buffered data to standard out allowing future calls to &lt;code&gt;puts&lt;/code&gt; to replace what was there.  Little did I know there is &lt;a href="https://ruby-doc.org/core-2.6.4/IO.html#method-i-sync" rel="noopener noreferrer"&gt;a flag you can set on an IO instance&lt;/a&gt; to immediately flush the output after every call with: &lt;code&gt;STDOUT.sync = true&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Kernel#at_exit
&lt;/h3&gt;

&lt;p&gt;Ruby's Kernel comes with some great stuff for working with the command line.  The fine folks over at HoneyBadger have &lt;a href="https://www.honeybadger.io/blog/how-to-exit-a-ruby-program/" rel="noopener noreferrer"&gt;a great writeup on different ways to exit a Ruby program&lt;/a&gt;, and some best practices.  In this specific case, we can use the special &lt;a href="https://ruby-doc.org/core-2.6.4/Kernel.html#method-i-at_exit" rel="noopener noreferrer"&gt;&lt;code&gt;at_exit&lt;/code&gt;&lt;/a&gt; callback to perform some code to reset the state of our GPIO pins (so we make sure not to set any fires).&lt;/p&gt;

&lt;h3&gt;
  
  
  Interrupt and SignalException
&lt;/h3&gt;

&lt;p&gt;Lastly, because we want to ensure that our circuit resets itself whenever the program stops running, we need a way to catch both user-initiated interrupts (a.k.a &lt;a href="https://ruby-doc.org/core-2.6.4/Interrupt.html" rel="noopener noreferrer"&gt;&lt;code&gt;Interrupt&lt;/code&gt;&lt;/a&gt; caused by a ctrl+c) and system-initiated interrupts (a.k.a. &lt;a href="https://ruby-doc.org/core-2.6.4/SignalException.html" rel="noopener noreferrer"&gt;&lt;code&gt;SignalException&lt;/code&gt;&lt;/a&gt;).  While it may be more beneficial to &lt;a href="https://www.sitepoint.com/license-to-sigkill/" rel="noopener noreferrer"&gt;trap unix signals&lt;/a&gt;, I went with the quick and dirty.&lt;/p&gt;

&lt;p&gt;Hopefully you learned something today.  I know I did!  Tune in next time when I get serious with the breadboard and jam as many LEDs in it as I can (or have patience for).&lt;/p&gt;

</description>
      <category>raspberrypi</category>
      <category>ruby</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Setting up a Raspberry Pi For Ruby</title>
      <dc:creator>Valentino Stoll</dc:creator>
      <pubDate>Wed, 04 Sep 2019 15:01:00 +0000</pubDate>
      <link>https://dev.to/codenamev/setting-up-a-raspberry-pi-for-ruby-8j1</link>
      <guid>https://dev.to/codenamev/setting-up-a-raspberry-pi-for-ruby-8j1</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Updated&lt;/strong&gt; 9/6/19: This is &lt;em&gt;part 1&lt;/em&gt; of my &lt;a href="https://blog.codenamev.com/tag/sunfounder-super-kit/"&gt;Sunfounder Superkit Series&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E3xhJq9c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.codenamev.com/content/images/2019/08/raspberry-pi-sunfounder-kit--1-.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E3xhJq9c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.codenamev.com/content/images/2019/08/raspberry-pi-sunfounder-kit--1-.jpeg" alt="Setting up a Raspberry Pi For Ruby"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ruby comes pre-installed on Raspbian, but unfortunately is not the latest version. After a bit of headache, here’s what I learned and how to make it right.&lt;/p&gt;

&lt;p&gt;My dream is to make a split-flap display, but since I have near-zero experience working with microcontrollers I decided to pick up Sunfounder’s Superkit (v3). To be honest, it was cheap, but also comes with lots of different components to play with. Let’s see what kind of lit experiments we can build.&lt;/p&gt;

&lt;h1&gt;
  
  
  Flashing the SD card
&lt;/h1&gt;

&lt;p&gt;I decided to use the Raspbian OS (with desktop client), just to make the learning curve easier. After downloading &lt;a href="https://www.raspberrypi.org/downloads/"&gt;the latest image&lt;/a&gt;, I then installed &lt;a href="https://etcher.io/"&gt;Etcher&lt;/a&gt; (as recommended) and this was incredibly easy to burn the image onto the micro SD.&lt;/p&gt;

&lt;h1&gt;
  
  
  Booting Up &amp;amp; Configuration
&lt;/h1&gt;

&lt;p&gt;Booting up the Raspberry Pi couldn’t have been easier. Jammed the micro SD card delicately in, plugged the power cable and the HDMI, and ~1minute later I was ready to go.&lt;/p&gt;

&lt;p&gt;First thing’s first, change the system password (because security).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;passwd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;One nice thing about the B+ is that you can remotely control the GPIO (more on this later). Unfortunately, both this feature, and ssh, are turned off by default. So, let’s flip the table on those bad girls.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Launch &lt;code&gt;Raspberry Pi Configuration&lt;/code&gt; from the &lt;code&gt;Preferences&lt;/code&gt; menu&lt;/li&gt;
&lt;li&gt;Navigate to the &lt;code&gt;Interfaces&lt;/code&gt; tab&lt;/li&gt;
&lt;li&gt;Select &lt;code&gt;Enabled&lt;/code&gt; next to &lt;code&gt;SSH&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt; : I’ve started a &lt;a href="https://github.com/codenamev/ruby-pi"&gt;small repo for all my experiments&lt;/a&gt; that includes a &lt;a href="https://github.com/codenamev/ruby-pi/blob/master/bin/setup"&gt;handy script to automate the remaining setup&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For me, the latest &lt;code&gt;gpio&lt;/code&gt; software was out of date and was raising hell. Let’s start this puppy up fresh:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Boom. System configured, dependencies updated, and GPIO configured properly. Check out all the wonderful pins we get access to in the GPIO on a B+!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jp5YQAjl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.codenamev.com/content/images/2019/08/raspberry-pi-b-plus-gpio-table--1-.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jp5YQAjl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.codenamev.com/content/images/2019/08/raspberry-pi-b-plus-gpio-table--1-.png" alt="Setting up a Raspberry Pi For Ruby"&gt;&lt;/a&gt;Raspberry Pi B+ GPIO table&lt;/p&gt;

&lt;p&gt;Ok, now Ruby time!&lt;/p&gt;

&lt;h1&gt;
  
  
  Setting up Ruby
&lt;/h1&gt;

&lt;p&gt;As of today (Jun 2018), Raspbian comes with Ruby pre-installed! In order to get some of the gems with native-extensions to build properly, I just &lt;em&gt;had&lt;/em&gt; to get &lt;code&gt;ruby-dev&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install ruby-dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Finally Blinking a Damn LED
&lt;/h1&gt;

&lt;p&gt;After &lt;em&gt;all&lt;/em&gt; that, you should be ready to use that Pi that’s just been collecting dust all these years. Just for fun, let’s perform the staple of what to do with your shiny new micro-controller: &lt;em&gt;blinking an LED&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;With a couple jumpers, an LED, and a 220Ω resistor we can safely control the state of the LED:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oTVocIrR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.codenamev.com/content/images/2019/08/raspberry-pi-blinking-led--1-.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oTVocIrR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.codenamev.com/content/images/2019/08/raspberry-pi-blinking-led--1-.jpeg" alt="Setting up a Raspberry Pi For Ruby"&gt;&lt;/a&gt;Raspberry Pi B+ blinking LED with Ruby!&lt;/p&gt;

&lt;h1&gt;
  
  
  Wrapping It Up
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--056ZcGo6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.codenamev.com/content/images/2019/08/wrap-it-up.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--056ZcGo6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.codenamev.com/content/images/2019/08/wrap-it-up.gif" alt="Setting up a Raspberry Pi For Ruby"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alright, I get it, not &lt;em&gt;too&lt;/em&gt; exciting. But hey, with this same setup I can see altering the code to, say, light up the LED when my tests fail.&lt;/p&gt;

&lt;p&gt;Tune in for more of me documenting my dope ass crusade of micro-controlling justice.&lt;/p&gt;

</description>
      <category>raspberrypi</category>
      <category>ruby</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>The code behind GitHub's new Code Navigation</title>
      <dc:creator>Valentino Stoll</dc:creator>
      <pubDate>Thu, 22 Aug 2019 15:00:00 +0000</pubDate>
      <link>https://dev.to/codenamev/the-code-behind-github-s-new-code-navigation-c1n</link>
      <guid>https://dev.to/codenamev/the-code-behind-github-s-new-code-navigation-c1n</guid>
      <description>&lt;p&gt;GitHub &lt;a href="https://help.github.com/en/articles/navigating-code-on-github" rel="noopener noreferrer"&gt;recently announced two new code navigation features&lt;/a&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Jump to definition – quickly view the source for any given method.&lt;/li&gt;
&lt;li&gt;Find all references – Identify all references of a function within the same repo.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.codenamev.com%2Fcontent%2Fimages%2F2019%2F08%2Fjump-to-definition-tab.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.codenamev.com%2Fcontent%2Fimages%2F2019%2F08%2Fjump-to-definition-tab.png" alt="The code behind GitHub's new Code Navigation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have been waiting a long time for these features to surface, and best of all, the code behind all this is open source!&lt;/p&gt;

&lt;p&gt;From the top-level, they're using a Haskell library called &lt;a href="https://github.com/github/semantic" rel="noopener noreferrer"&gt;Semantic&lt;/a&gt;.  Semantic can &lt;em&gt;parse&lt;/em&gt;, &lt;em&gt;analyze&lt;/em&gt;, and &lt;em&gt;compare&lt;/em&gt; source code.  As of the last update to this post, it supports Ruby, JavaScript, TypeScript, Python, Go, PHP, Java, JSON, JSX, Haskell, and Markdown.&lt;/p&gt;

&lt;p&gt;For a full list of examples, check out the &lt;a href="https://github.com/github/semantic/blob/master/docs/examples.md" rel="noopener noreferrer"&gt;Semantic usage docs&lt;/a&gt;.  It comes with a great CLI that allows you to:&lt;/p&gt;

&lt;h3&gt;
  
  
  Generate parse trees
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ semantic parse test.A.py
(Statements
  (Annotation
    (Function
      (Identifier)
      (Identifier)
      (Return
        (Identifier)))
    (Empty))
  (Call
    (Identifier)
    (Call
      (Identifier)
      (TextElement)
      (Empty))
    (Empty)))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
Generate an abstract syntax tree (AST)





&lt;h3&gt;
  
  
  Generate syntax aware diffs
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ semantic diff test.A.py test.B.py
(Statements
  (Annotation
    (Function
    { (Identifier)
    -&amp;gt;(Identifier) }
      (Identifier)
      (Return
        (Identifier)))
    (Empty))
  (Call
    (Identifier)
    (Call
    { (Identifier)
    -&amp;gt;(Identifier) }
      (TextElement)
      (Empty))
    (Empty)))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Display import call graphs
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;semantic graph main.py | dot -Tsvg &amp;gt; main.html &amp;amp;&amp;amp; open main.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.codenamev.com%2Fcontent%2Fimages%2F2019%2F08%2Fimport_graph.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.codenamev.com%2Fcontent%2Fimages%2F2019%2F08%2Fimport_graph.svg" alt="The code behind GitHub's new Code Navigation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Display call graphs
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;semantic graph --calls main.py | dot -Tsvg &amp;gt; main.html &amp;amp;&amp;amp; open main.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.codenamev.com%2Fcontent%2Fimages%2F2019%2F08%2Fcall_graph.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.codenamev.com%2Fcontent%2Fimages%2F2019%2F08%2Fcall_graph.svg" alt="The code behind GitHub's new Code Navigation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Making Sense of Your Code
&lt;/h2&gt;

&lt;p&gt;The code parsing is done with the &lt;a href="https://github.com/tree-sitter/tree-sitter" rel="noopener noreferrer"&gt;tree-sitter&lt;/a&gt; library which appears to be C with a handful of language bindings (&lt;a href="https://github.com/tree-sitter/tree-sitter/tree/master/cli" rel="noopener noreferrer"&gt;the cli is in Rust&lt;/a&gt;!).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;[Tree-sitter] can build a concrete syntax tree for a source file and efficiently update the syntax tree as the source file is edited&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Languages are supported by writing language-specific parsers.  These parsers primarily consist of two parts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Grammar&lt;/strong&gt; –  contains various rules for how the language is formatted&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lexical Analysis&lt;/strong&gt; – patterning individual character groups (for &lt;a href="https://en.wikipedia.org/wiki/Lexical_analysis" rel="noopener noreferrer"&gt;lexing&lt;/a&gt;).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example Grammar for parsing simple ruby methods from &lt;a href="https://github.com/tree-sitter/tree-sitter-ruby" rel="noopener noreferrer"&gt;tree-sitter-ruby&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "ruby",
  "word": "identifier",
  "rules": {
    "method": {
      "type": "SEQ",
      "members": [
        {
          "type": "STRING",
          "value": "def"
        },
        {
          "type": "SYMBOL",
          "name": "_method_rest"
        }
      ]
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;a href="https://github.com/tree-sitter/tree-sitter-ruby/blob/master/src/grammar.json#L5-L46" rel="noopener noreferrer"&gt;https://github.com/tree-sitter/tree-sitter-ruby/blob/master/src/grammar.json&lt;/a&gt;





&lt;p&gt;Tree-sitter has &lt;a href="http://tree-sitter.github.io/tree-sitter/playground" rel="noopener noreferrer"&gt;an &lt;em&gt;awesome&lt;/em&gt; Playground&lt;/a&gt; where you can explore the parse trees it generates for any given code.&lt;/p&gt;

&lt;p&gt;When you feed code to the Semantic library, it generates parse trees using tree-sitter, and then uses the &lt;a href="https://github.com/github/semantic/blob/master/docs/grammar-development-guide.md" rel="noopener noreferrer"&gt;language's grammar&lt;/a&gt; (e.g. from tree-sitter-ruby) to parse the parse trees and map AST nodes  (many of which are already available from the library itself for: &lt;a href="https://github.com/github/semantic/blob/master/src/Data/Syntax/Literal.hs" rel="noopener noreferrer"&gt;literals&lt;/a&gt;, &lt;a href="https://github.com/github/semantic/blob/master/src/Data/Syntax/Expression.hs" rel="noopener noreferrer"&gt;expressions&lt;/a&gt;, &lt;a href="https://github.com/github/semantic/blob/master/src/Data/Syntax/Statement.hs" rel="noopener noreferrer"&gt;statements&lt;/a&gt;, and &lt;a href="https://github.com/github/semantic/blob/master/src/Data/Syntax/Type.hs" rel="noopener noreferrer"&gt;types&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;While they hope to &lt;a href="https://github.com/github/semantic/blob/master/docs/adding-new-languages.md#faqs" rel="noopener noreferrer"&gt;drop this step in the future&lt;/a&gt;, once the AST nodes are mapped, a second round of parsing is done to wrap them into data structures the library can comprehend (for more on this, &lt;a href="https://github.com/github/semantic/blob/master/docs/assignment.md" rel="noopener noreferrer"&gt;see the "Assignment" documentation&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;There are quite a few more things that happen to &lt;em&gt;analyze&lt;/em&gt; and &lt;em&gt;compare&lt;/em&gt; source code, but I'll leave the explanation it to their &lt;a href="https://github.com/github/semantic/blob/master/docs/program-analysis.md" rel="noopener noreferrer"&gt;great documentation on program analysis&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you GitHub ❤️  Keep up the solid work 😄&lt;/p&gt;

</description>
      <category>github</category>
      <category>devtools</category>
      <category>codeanalysis</category>
    </item>
    <item>
      <title>How to fix all Ruby "Failed to build gem native extension" Errors in OS X</title>
      <dc:creator>Valentino Stoll</dc:creator>
      <pubDate>Thu, 11 Jul 2019 21:00:00 +0000</pubDate>
      <link>https://dev.to/codenamev/how-to-fix-all-ruby-failed-to-build-gem-native-extension-errors-in-os-x-11n9</link>
      <guid>https://dev.to/codenamev/how-to-fix-all-ruby-failed-to-build-gem-native-extension-errors-in-os-x-11n9</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg ~/Desktop &amp;amp;&amp;amp; open ~/Desktop/macOS_SDK_headers_for_macOS_10.14.pkg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.codenamev.com%2Fcontent%2Fimages%2F2019%2F07%2Ffixed-it-1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.codenamev.com%2Fcontent%2Fimages%2F2019%2F07%2Ffixed-it-1.gif" alt="How to fix all Ruby"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Boom.  Now start removing all those pesky overrides you set in &lt;code&gt;~/.bundle/config&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;All credit goes to the amazing &lt;a href="https://github.com/silvae86" rel="noopener noreferrer"&gt;João Rocha da Silva&lt;/a&gt;.  Be sure to &lt;a href="https://silvae86.github.io/sysadmin/mac/osx/mojave/beta/libxml2/2018/07/05/fixing-missing-headers-for-homebrew-in-mac-osx-mojave/" rel="noopener noreferrer"&gt;check out his detailed write-up&lt;/a&gt; on why you need to do this.  TLDR; Mac OS X 10.14 no longer places the include libraries in the standard &lt;code&gt;/usr/include&lt;/code&gt; directory and locked by SIP.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>commonissues</category>
    </item>
    <item>
      <title>Custom Git Workflows with the latest git-reflow</title>
      <dc:creator>Valentino Stoll</dc:creator>
      <pubDate>Sat, 10 Nov 2018 21:16:06 +0000</pubDate>
      <link>https://dev.to/codenamev/custom-git-workflows-with-the-latest-git-reflow-42ie</link>
      <guid>https://dev.to/codenamev/custom-git-workflows-with-the-latest-git-reflow-42ie</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VKD6aTFm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.codenamev.com/content/images/2019/07/reflow-workflows-header.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VKD6aTFm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.codenamev.com/content/images/2019/07/reflow-workflows-header.jpeg" alt="New git-reflow release: Custom Git Workflows"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This release includes the culmination of several years of effort to allow you to customize our process to suit your specific needs. We’ve dropped a heavy dependency (&lt;code&gt;gli&lt;/code&gt;) and introduced a pretty slick DSL for creating new git commands or override our existing ones.&lt;/p&gt;

&lt;p&gt;I am really excited to announce the released version 0.9.0 of the &lt;a href="https://github.com/reenhanced/gitreflow"&gt;&lt;code&gt;git_reflow&lt;/code&gt; gem&lt;/a&gt;!&lt;/p&gt;

&lt;h3&gt;
  
  
  Custom Workflows
&lt;/h3&gt;

&lt;p&gt;Git-reflow’s default process isn’t meant to fit every team, which is why we’ve introduced &lt;code&gt;Workflows&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We’ve introduced a special file that can contain customizations to the default process. With this, you can:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add hooks to be run before, or after any command
&lt;/li&gt;
&lt;li&gt;Use one of our pre-configured workflows as a basis for your own
&lt;/li&gt;
&lt;li&gt;Override any of the default commands
&lt;/li&gt;
&lt;li&gt;Create new commands&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is an example showcasing all the various ways you can customize the process:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Use a pre-defined workflow&lt;/span&gt;
&lt;span class="n"&gt;use&lt;/span&gt; &lt;span class="s2"&gt;"FlatMergeWorkflow"&lt;/span&gt;

&lt;span class="c1"&gt;# Do something before the `start` command&lt;/span&gt;
&lt;span class="n"&gt;before&lt;/span&gt; &lt;span class="ss"&gt;:start&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;say&lt;/span&gt; &lt;span class="s2"&gt;"Booya! Started this bad girl."&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="c1"&gt;# Do something after the `deliver` command&lt;/span&gt;
&lt;span class="n"&gt;after&lt;/span&gt; &lt;span class="ss"&gt;:deliver&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="s2"&gt;"say 'Well done!'"&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="c1"&gt;# Override the `start` command to auto-name feature branches&lt;/span&gt;
&lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="ss"&gt;:start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;arguments: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;feature_branch: &lt;/span&gt;&lt;span class="kp"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="ss"&gt;flags: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;base: &lt;/span&gt;&lt;span class="s1"&gt;'dev'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="ss"&gt;switches: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;loud: &lt;/span&gt;&lt;span class="kp"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|**&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
  &lt;span class="n"&gt;base_branch&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:base&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="n"&gt;feature_branch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:feature_branch&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s2"&gt;"feature-&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="no"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"%Y-%m-%d"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

  &lt;span class="n"&gt;run_command_with_label&lt;/span&gt; &lt;span class="s2"&gt;"git checkout &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;base_branch&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="n"&gt;run_command_with_label&lt;/span&gt; &lt;span class="s2"&gt;"git pull origin &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;base_branch&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="n"&gt;run_command_with_label&lt;/span&gt; &lt;span class="s2"&gt;"git push origin &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;base_branch&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;:refs/heads/&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;feature_branch&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="n"&gt;run_command_with_label&lt;/span&gt; &lt;span class="s2"&gt;"git checkout --track -b &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;feature_branch&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; origin/&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;feature_branch&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;span class="c1"&gt;# Create a new command&lt;/span&gt;
&lt;span class="c1"&gt;# Makes `git reflow boom` available in the command line.&lt;/span&gt;
&lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="ss"&gt;:boom&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="no"&gt;GitReflow&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;say&lt;/span&gt; &lt;span class="s2"&gt;"Boom."&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can define a unique workflow for each of your projects simply by placing it in the root of your project, or by setting a special &lt;code&gt;reflow.workflow&lt;/code&gt; git-config setting with the full path of the file.&lt;/p&gt;

&lt;p&gt;The block that you pass to each of the git-reflow reserved commands (&lt;code&gt;use&lt;/code&gt;, &lt;code&gt;before&lt;/code&gt;, &lt;code&gt;after&lt;/code&gt;, &lt;code&gt;command&lt;/code&gt;) are executed in the context of our &lt;a href="https://github.com/reenhanced/gitreflow/blob/master/lib/git_reflow/workflows/core.rb"&gt;Core workflow class&lt;/a&gt;. This gives you the ability to use any code available to the &lt;code&gt;GitReflow&lt;/code&gt; module. We encourage you to use as much of GitReflow’s tooling as possible so that you can take full advantage of getting the current branch name, logging, exception-handling, colorized output, and several other features that are baked into GitReflow’s internals. For a full list of what’s available, see &lt;a href="https://github.com/reenhanced/gitreflow/wiki/Custom-Workflows#available-workflow-helpers"&gt;Available Workflow Helpers&lt;/a&gt; on our wiki.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ramping Up To 1.0
&lt;/h3&gt;

&lt;p&gt;With the re-workings of &lt;code&gt;Workflows&lt;/code&gt; in place, we’re getting ready for our first major release! Our current plans are to focus on:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Introduce Pivotal Tracker &amp;amp; Trello workflows&lt;/li&gt;
&lt;li&gt;Add GitLab integration&lt;/li&gt;
&lt;li&gt;Add an Open Source workflow&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We’re looking forward to some exciting times! We’d love to hear all the interesting ways you use these new workflows, so please don’t hesitate to let us know.&lt;/p&gt;

&lt;p&gt;Happy hacking!&lt;/p&gt;

</description>
      <category>git</category>
      <category>gitreflow</category>
      <category>workflows</category>
      <category>ruby</category>
    </item>
  </channel>
</rss>
