Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Everyday Programming for Everyday Problems

Everyday Programming for Everyday Problems

Tyler L

June 10, 2017
Tweet

More Decks by Tyler L

Other Decks in Programming

Transcript

  1. $ whois tylerjl • Infrastructure engineering/devops at Elastic ◦ Elasticsearch

    puppet module ◦ Lots of web properties ◦ Shell jockey • Other interests ◦ Linux package maintainer, functional programming, my dog Morty
  2. High-Level Tools • Ruby, Python, Node, etc. all have useful,

    expansive libraries • Plenty of open and free APIs Why This is Easier Than it’s Ever Been Cheap Computing • VPS providers offer cheap, easy-to-use Linux servers • Raspberry Pi/other SBCs Pre-built Frontends • Chat bots make for easy interfaces • Lots of web tools (wikis, dashboards like Kibana, etc.)
  3. Case Study: The Angry Tweeter Why? • Measurable: verify that

    paid speeds are being met • Recorded: proof of historical bandwidth provided • Accurate: “internet is slow” != ISP behaving badly
  4. Case Study: The Angry Tweeter How? Answer the relevant questions:

    • How will you measure bandwidth? ◦ Google: “python bandwidth test” (first hit)
  5. Case Study: The Angry Tweeter How? Answer the relevant questions:

    • Where will you put the measured bandwidth? ◦ Storing lots of numbers (timeseries data) is its own can of worms ◦ tl;dr whatever works for you graphite, ganglia, elasticsearch, kairosdb, influxdb, prometheus, hawkular, etc….
  6. Case Study: The Angry Tweeter How? Answer the relevant questions:

    • How will you view your bandwidth? ◦ Largely dependent on where you store your bandwidth ◦ Tried and true solutions like Kibana/Grafana are good options
  7. Case Study: The Angry Tweeter How? Just some python, plus

    some plumbing: from pyspeedtest import SpeedTest from elasticsearch import Elasticsearch tester = SpeedTest() es = Elasticsearch() while sleep(900): es.index(index=’bw’, type=’bw’, body={‘down’:tester.download()})
  8. Case Study: Printers (╯°□°)╯︵ ┻━┻ Alternative: Build It Yourself! •

    Print server ◦ Raspberry Pi + cups • Wireless printing (smartphones, too!) ◦ Avahi + 1 config file Zero client config, secure, configurable, stable
  9. Case Study: Bots Why? • Low barrier to entry for

    simple UX • Very high-level libraries • Slack makes private chat channels easy (i.e., no IRC bouncer) • Code in whatever you want!
  10. Case Study: Bots Simple commands Easy to make a chat

    interface for anything you can come up with: require 'slack-ruby-bot' class MyBot < SlackRubyBot::Bot command ‘day’ do |client, data, match| client.say(text: Time.now.strftime('%A'), channel: data.channel) end end MyBot.run
  11. Case Study: Media Archiving Options • By hand ◦ Handbrake

    buttons + copy/paste + etc. = waaaay too long • Buy digital copies ◦ Haha • Send them somewhere for conversion ◦ I’m not about to admit defeat
  12. Case Study: Media Archiving Results • Entire process is: ◦

    Insert DVD, remove DVD after ~1 hour ◦ Media handling is another system (NAS + Kodi) • In total, maybe 50 lines of code and config files ◦ Just shell scripts + systemd configs • Custom format, compression, subtitles, etc. • Event flow is easy to grok with systemd
  13. • Whatever gels with your brain • Ruby/Python/Node/Perl are all

    high-level languages with powerful libraries • Run it on Linux? ◦ Easy scheduling ◦ Cheap servers ◦ Strongest tooling Considerations: • What do I use? • How do I write it? • Where do I run it?
  14. • Try starting low-level to understand, then move up (i.e.,

    command line) • At least an editor (vim/emacs/atom) • IDEs can be extra helpful (PyCharm/Rubymine/ Eclipse/etc.) Considerations: • What do I use? • How do I write it? • Where do I run it?
  15. Considerations: • What do I use? • How do I

    write it? • Where do I run it? • One time? ◦ Just run it locally • All the time? ◦ Any computer that runs all the time • All-in? ◦ Little Linux server ◦ (this is easier and safer than you think) ◦ Or, just buy a VPS • Self-hosting is now sub-$25
  16. Where to go From Here? • Zero programming experience? ◦

    Get started with a tutorial about $x • Looking for something to solve? ◦ Pick something annoying • Can’t figure out how to solve it? ◦ Lucky you, you’re at SELF • Solved something cool? ◦ Blog about it and tell us!
  17. Thank you! github.com/tylerjl irc/twitter: leothrix tjll.net Additional Information: • speakerdeck.com/tylerjl

    • Corner me anytime this conference ◦ (I’ll be at the Elastic booth after)