Skip to content

Instantly share code, notes, and snippets.

(function(long_url,callback){
bi = new URL("https://api-ssl.bitly.com/v3/shorten?");
var params = [
"login=YOUR_USER_ID",
"domain=j.mp",
"apiKey=YOUR_API_KEY",
"longUrl="+ encodeURIComponent(long_url)
]
bi.search = "?"+params.join('&')
var xhr = new XMLHttpRequest();
@elephantsofneptune
elephantsofneptune / PigLatin.js
Created May 14, 2017 08:44 — forked from noshaf/PigLatin.js
Pig Latin Javascript
var translate = function(word) {
var array = word.split('');
var vowels = ['a','e','i','o','u'];
var newWord = '';
for(var i = 0; i < vowels.length-1; i++) {
for(var y = 0; y < word.length-1; y++) {
if(word[y] === vowels[i]) {
for(var x = y; x < word.length; x++){
newWord = newWord + word[x];
}
@elephantsofneptune
elephantsofneptune / pig-latin.js
Created May 14, 2017 08:43 — forked from benbuckman/pig-latin.js
Pig Latin Interpreter in javascript/node.js
/*
Pig Latin interpreter
by Ben Buckman, July 20 2012
Rules:
- All words beginning with a consonant have their first letter moved to the end of word followed by 'ay'.
Example: Hello -> Ellohay
- All words beginning with a vowel have their first letter moved to the end moved to the word followed by 'hay'.
Example: Another -> Notherahay
@elephantsofneptune
elephantsofneptune / ar-todo-overview.md
Created May 11, 2017 02:32 — forked from SamSamskies/ar-todo-overview.md
AR Todo DBC phase 1 challenge overview

The purpose of this document is to go over a couple different solutions for the AR Todos challenge from phase 1. First, I'm going to present a solution where most of the code is done in a single file. Then I'm going to present a solution using MVC and hopefully you'll be able to see the benefits of taking the time to separate your concerns.

Example 1: Non-MVC Solution

Many beginner programmers would probably approach the AR Todos challenge in a manner somewhat like this example if they were not given specific instructions on how to implement the solution. This solution is easier to write because you can just tackle each task systematically without thinking about new classes, how to organize separate files, etc.

What if you made this program for your job and another person needed to add more functionality or fix a bug? Do you think it would be easy for them to understand what you did? They could probably figure it out, but it wouldn't be as easy as it could be. It's important to make your program as clea

@elephantsofneptune
elephantsofneptune / part_one.rb
Created May 11, 2017 02:22 — forked from stungeye/part_one.rb
Challenge One Possible Solutions
# One Way To Solve The Problem
random_numbers = []
20.times do
random_numbers << rand(1..100)
end
random_numbers.each do |number|
puts number
end
rails s (start server)
rails console
rake about (app desc)
rake db:schema:dump (connecto db & export schema)
rake db:migrate:status
rake db:migrate (apply migrations to db)
rake db:migrate VERSION=0 (rollback)
rake db:migrate:(up/down/redo) VERSION=<version>
rake db:seed (populate db with test data from seeds.rb)
rake db:rollback (rollback the migration)
SCREEN SHOT: http://min.us/lbgppAeuKGPSk4
XML:
<?xml version="1.0" encoding="utf-8" ?>
<!-- SQL XML created by WWW SQL Designer, http://code.google.com/p/wwwsqldesigner/ -->
<!-- Active URL: http://socrates.devbootcamp.com/sql.html -->
<sql>
<datatypes db="mysql">
<group label="Numeric" color="rgb(238,238,170)">
INSERT INTO voters
(first_name, last_name, gender,party, party_duration, age, married, children_count, homeowner, employed,created_at, updated_at)
VALUES
('Jessi', 'Jow', 'female', 'Democrat', 8, 30, 0, 0, 1, 1, DATETIME('now'), DATETIME('now'));
INSERT INTO voters
(first_name, last_name, gender,party, party_duration, age, married, children_count, homeowner, employed,created_at, updated_at)
VALUES
('Joshua', 'Teng', 'male', 'Democrat', 5, 26, 0, 0, 1, 1, DATETIME('now'), DATETIME('now'));
# Solution for Challenge: DB Drill: Address Book Schema. Started 2013-07-09T21:32:24+00:00
http://min.us/l0GieGZ7cxACS
<?xml version="1.0" encoding="utf-8" ?>
<!-- SQL XML created by WWW SQL Designer, http://code.google.com/p/wwwsqldesigner/ -->
<!-- Active URL: http://socrates.devbootcamp.com/sql.html -->
<sql>
<datatypes db="mysql">
<group label="Numeric" color="rgb(238,238,170)">
<type label="Integer" length="0" sql="INTEGER" re="INT" quote=""/>
# Solution for Challenge: Student Roster DB from Schema. Started 2013-07-09T19:29:26+00:00
require 'sqlite3'
# If you want to overwrite your database you will need
# to delete it before running this file
$db = SQLite3::Database.new "students.db"
module StudentDB
def self.setup
$db.execute(