Skip to content

Instantly share code, notes, and snippets.


Ryan Sobol ryansobol

View GitHub Profile
ryansobol / Array+Permutations.swift
Last active Aug 12, 2021
Generate the permutations of a Swift array
View Array+Permutations.swift
extension Array {
func chopped() -> (Element, [Element])? {
guard let x = self.first else { return nil }
return (x, Array(self.suffix(from: 1)))
print([1, 2, 3].chopped())
// Optional((1, [2, 3]))
View response.json
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 445
Content-Type: application/json; charset=utf-8
Date: Wed, 05 Jul 2017 04:22:10 GMT
Server: openresty
X-Cache-Key: /data/2.5/weather?APPID=cc4654c8e15f6d08b13954b915a0d0b1&q=seattle
ryansobol /
Last active Sep 25, 2018 — forked from IanSmith89/
Galvanize Bookshelf Validations

Server-side Validations for Galvanize Bookshelf

Change into your project directory.

cd galvanize-bookshelf

Ensure the staging area of the master branch is clean. Then, create and checkout a new feature branch.

View gist:3f86ee63034e321c14d4
// Load required module
var http = require('http');
var fs = require('fs');
var url = require('url');
http.createServer(function(request, response) {
var pathname = __dirname + url.parse(request.url).pathname;
fs.exists(pathname, function(exists) {
if (exists) {

Keybase proof

I hereby claim:

  • I am ryansobol on github.
  • I am ryansobol ( on keybase.
  • I have a public key whose fingerprint is 796F F213 9A11 4FB9 2921 5DE7 34D6 FF00 1F05 B945

To claim this, I am signing this object:

View gist:e1957de59a581b0c460f
document.getElementById("todo").addEventListener("keypress", function(event) {
if (event.keyCode == 13) {
function addToDo() {
var newEl = document.createElement("li");
var parentEl = document.getElementById("list");
var firstEl = parentEl.firstChild;
View gist:f25b5103ba37e044d792
TARGET="/c/Program Files (x86)/Git/bin/subl"
echo '#!/bin/sh' > $TARGET
echo '"C:\Program Files\Sublime Text 2\sublime_text.exe" "$1" &' >> $TARGET
ryansobol /
Last active Apr 7, 2022
Hashes in Ruby

What's a Hash and why is it important?

A Hash is a collection of key-value pairs. To add, fetch, modify, and delete a value from a Hash, you refer to it with a unique key.

While an Array is indexed by Integers only, a Hash is keyed by any object -- Strings, Integers, etc.

In other programming languages, a Hash might be known as an 'associative array', 'dictionary', or 'HashMap'.

What does a Hash look like?

ryansobol /
Last active May 6, 2022
Symbols in Ruby

What's a Symbol and why is it imporant?

In Ruby, a Symbol is the most efficient way, in terms of time and memory, to represent a set of characters.

What does a Symbol look like?

Most commonly, a Symbol is a single word prefixed by a colon:


Good etiquette in class can help you make the most of your education.

You're an adult; act like one.

If you're in Code Fellows, you're likely at least 18 years old—the age at which you're legally considered an adult. You may not feel like a responsible grown-up yet, but your instructors will assume that you are. So act likewise.

Before you say or do anything in the classroom, ask yourself "How would a mature, well-adjusted, courteous adult act?" I promise that doing so will save you from embarrassment and engender the respect of your classmates and instructors.

Present yourself well.