Mary Dickson Diaz

Code, Life, Learning

Tag: javascript

how to use the wordpress rest api in rails

Folks, if you’re reading this over at www.marydickson.info, my Rails portfolio site, things are about to get real meta. Several weeks ago I RSVPed for a WordPress Developer’s meetup called Introduction to the REST API. I’ve used APIs with Rails, Angular, and in Twitterbots– an API (application program interface) is simply a way to transfer information from a server to a client, often using a format called JSON (JavaScript object notation). APIs are key to mobile apps that access the same database as a web based site. “REST” (representational state transfer) means that a system understands a set of standard verbs used to communicate over HTML, including: GET, POST, PUT, DELETE, etc. You can use an AJAX (asynchronous JavaScript and xml) call to transmit data via the REST verbs and either fetch data, post new data, update existing data, or delete a record, and the information will be persisted in a database somewhere behind the scenes.

That’s a lot of acronyms. Here have a picture:

how APIs work, sort of

Super! MARY, BUT WHY SHOULD WE CARE?

Long story short: I’ve had this WordPress blog since I started coding, and since then I’ve coded other web sites “from scratch,” including a professional portfolio site, that are much easier for me to customize and that add legitimacy to my claim of web developer. So that is what I want to share with potential employers but I also want them to see my awesome technical blog posts so they will think “She sounds cool and writes good. Let’s pay her money in exchange for her time!” UNTIL NOW the way to do that was to direct people to this site, marydickson.com, and hope that they will also go check out marydickson.info, or vice versa. Awkward.

The WordPress API allows me to import blog posts from marydickson.com and render them as a tab on marydickson.info. If you have any sort of non-WordPress site and you’d like to link to or display your blog posts, you can do that with the WordPress REST API. I’ll walk you through what I did to get this working in a Rails app:

Continue reading

where i’m from

where i'm from screenshot

I finished the first part of my #NaNoGenMo project, a “Where I’m From” poem generator.

click meeee for poetreeee

It’s nothing fancy, but I’m really pleased with how it turned out.

Some technical notes:

Continue reading

#nanogenmo

book-419589_1920

November kicked off the third installment–and my first–of National Novel Generation Month (#NaNoGenMo), with a stated goal to “Spend the month of November writing code that generates a novel of 50k+ words.”

I’ve been excited to play with natural language processing tools, so I dove right in! Procedural note: Darius has requested that participants open an issue on the shared Github repo and update from there, so that link is where I’ve been writing and tracking progress. The repo is here.

Here’s my inspiration poem. In my teaching years, this poem made the rounds — it’s great for teaching memoir and descriptive writing, and easy and satisfying for students to emulate in order to create their own “Where I’m From” poems.

Continue reading

watch someone code something weird

Last week Darius Kazemi made a twitter bot via live-code. It’s really fun to see his thought process and trial/error. He plays with RiTa for JavaScript, a natural language processor (which ironically, might be exactly what I need for a non-bot project… stay tuned!).

He uses Node, JavaScript, and something called “grunt” to initiate the project (starts at 7 mins in if you want to skip ahead).

Josh walked in while I was watching and commented “Darius is such a great teacher.” He is! Love to see this live coding.

Maybe I will attempt a live-code (or record-code) session. Could be a good way to get over my fear of video and also impose a strict “make something in an hour” timeline.

I have a month to play (more on that to come as well) so this is all timely. 🙂 Enjoy!

p.s. this post is for Jessie, my favorite/only reader.

two down, one to go

20150624_175232

View from the plane over Greenland.

Now I remember.

After I spent an intense month learning about html/css/javascript/jquery the plan was to keep working on www.marythought.com so I’d have an opportunity to keep practicing with it. Remember that? The plan? The plan to look out for Future Mary?

Right, so, that didn’t happen, and consequentially I spent a lot of time this weekend re-learning (googling) how to do stuff with jquery. But readers, *I MADE A THING.*

I made two things for you, actually.

First, my very favorite thing: books! I made you a library in Ruby. It needs a bunch of work still, but if you know what you’re doing, you can add books to your library and put them on shelves by genre (or whatever). Given more time and resources I would go ALL OUT with this assignment (alphabetizing is my favorite meditation technique), but I am trying to keep it simple. If I have more time before it needs to get submitted, I’ll add authors and ID #s to the books to increase sorting abilities and functionality. I’ll also add a “librarian” function to walk you through all the stuff you can do in the library. What’s holding me back from the latter is figuring out how to generate and keep track of new Class instances within a function when I need it to be able to do stuff before knowing what the instance variables are going to be. Clear as mud?

And second, I dredged up enough knowledge about html/css/javascript/jquery (why hasn’t anyone come up with a catchy nickname for this language crew yet. HCJJ?) to make a simple to-do list. Here you can go play with it if you’d like: simple html to-do list. It is certainly the worst to-do list I’ve ever encountered, and has all sorts of usability issues, but it does meet the stated criteria and I think it’s probably best to keep expectations low in this category. Lower. Lower. There you go.

The last mini-project I’m working on is a Rails application. I’ve yet to tackle the Rails part of Ruby on Rails, so this will be an adventure. Last week I got everything installed, so I’ll probably re-start my Treehouse subscription for a tutorial this week, and focus on getting that done and tweaking everything else.

Stuff is starting to come together in exciting ways.

Some links! Not code related, sorry!

  • #blacklivesmatter protestors go to Chicago and film the Mike Brown gallery exhibit. Must watch. Curious what my legit artsy friends think about this (what you will probably say is there are bad galleries and bad artists and this is both, and then some).
  • “F*ck that,” a guided meditation for our times. <–you need this. I need this. The world needs this.
  • I’m generally wary of “I did TFA and it sucked so TFA sucks” stories, so I wasn’t putting much stock in “Teach For America: Counter-Narratives” until the organization went and published a “response” to the alumni authors of the book before the dang thing has even been published. So now of course I want to buy 10 copies. Their response, which I will not link to, says “In particular, a small group of former corps members involved in the book have chosen to focus on past experiences that are not in line with how we operate. … It’s not productive to address in this space every critique in this book, but here’s what we have to say about some of the contributors’ bigger misconceptions.” I repeat: the book. is not. out. yet. They have not been provided an advance copy. (UPDATE: on July 27 TFA clarified that they received a copy from the publisher on July 8. Why they couldn’t just say that when first questioned…) The editor of the book doesn’t even have his copy yet. Just more PR spin and refusal to listen (read) from an org whose #1 critical feedback from alumni is that they are too focused on PR and they don’t listen.
  • Uhhh… I am probably hella guilty of this, but I’m trying (from xkcd). 

mission unlocked

Hey friends,

After compiling all these great twitter bot resources I’ve been on a bot kick, creating two new ones in the past few days. I should probably diversify my projects some more, but in the meantime it’s such a great way to learn and practice code, git, and tools to deploy.

CHALLENGE #1: Can you do it in JavaScript?

answer = #achievementunlocked

Darius Kazemi is something of a legend in botland (he’s the creator of the Harry Potter sorting bot, among others), and has posted a tutorial for a simple example bot that re-tweets a hashtag once an hour.  I have, in my pile of unfinished projects, big plans for the twitter handle *unlock achievemt* but I got stuck awhile back when I couldn’t figure out how to auto upload pictures. So in the meantime, I’ve set it to re-tweet something from the #achievementunlocked hashtag once an hour, with pretty great results:

Screen Shot 2015-04-18 at 12.36.49 AM

Continue reading

the toggle button that wasn’t

HEAR YE, HEAR YE: I made a thing in which I practice using jQuery and mix my literary metaphors: Rabbit, Run!

If anyone knows how to make the toggle button actually, you know, toggle… please share. Until then it *says* “toggle bunnicula” but what it actually does is “click here for bunnicula forever.”

Related, this exchange with Josh (my partner, a professional game designer):

Continue reading

“Your bill is NaN”

Just checking in to share that I finished the garsh-darn JavaScript tutorial (kicking and screaming the last 3 miles) and attended my first Code Fellows class yesterday!

The instructor successfully articulated a point I was trying to make in my last post, the difference between paths and sandboxes (or, as I prefer to pluralize it, sandboxen). Learning paths include things like online tutorials: they are consumptive, they lead you down a specific path to completion. Sandboxes (eff it) sandboxen are more autonomous, exploratory learning experiences, driven by learner interest, that generally lead to greater understanding. The majority of our class time will be spent playing with sandboxen.

sandboxen
Oxen on the beach in Colva Beach | Goa, Colva (Trip Advisor photo by raumati1: Mar 2010)

Adorable!

I was trying to complete the first assignment, a simple guessing game, by converting one of my working python games to JavaScript. I wasn’t able to make that work (v. frustrating), but I was able to build on the instructor’s demo to make a game I’m proud of. The original game asked a player to guess a number between 1 and 10, with 2 options: 1. you win! and 2. you lose. I expanded the range, added a way to keep track of the high and low guesses, and built-in exclusions for guesses that are NaN (not a number) or out of range. Try it!

A warning: this game, built-in JavaScript and saved as an html file, operates entirely through pop-up windows. I promise you it does not reset your browser’s search engine to Yahoo! (when I find the program that is doing that there will be many strongly worded tweets), but otherwise the interface is a bit annoying and I hope it is not the only way that JavaScript knows how to talk to the world.

Click me, click meeeeeee!

f.read()

Bletchley Park Commemorative Badge

Bookmarked this week:

  1. Emotional reunion after 70 years for Bletchley Park veterans – I haven’t seen Imitation Game yet, but I did watch (and enjoy) Bletchley Circle. So inspiring to see the real Wrens here reunited and as sharp as ever. Click through the image above to peek at the Roll of Honour. (Also, that looks like it might make a great Twitterbot project… hmmm…)
  2. Retiring Python as a Teaching Language — James Hague makes a case for learning JavaScript first. I can commiserate with the sentiment of “but what can I doooo with Python” — I’m trying to figure out a way to get my neat-o credit card program onto this webpage in an interactive format. I started playing around with django, which I think will let me do that? But there could probably be an easier way.
  3. 10 things you need to know before applying to a code school — and if you’re in Seattle, you might want to attend “A glimpse into disruptive web development education” next Tuesday evening, with representatives from General Assembly, Code Fellows, and Ada Developers Academy, including instructors, students, and business development partners from the hiring side, discussing their respective education models.” It’s like they planned it *for me*. Do not miss!
  4. Programing doesn’t belong to men (it belongs to me) – by Julia Evans. Get it, girl.

© 2023 Mary Dickson Diaz

Theme by Anders NorenUp ↑