Skip to content

Instantly share code, notes, and snippets.

Ahnita / posts.js
Last active Aug 1, 2016
To create posts using JS
View posts.js
var main =function() {
$('.btn').click(function() {
var post = $('status-box').val();
$('.status-box').keyup(function() {
var postLength = $(this).val().length;
var charactersLeft = 140 - postLength;
Ahnita / cat.rb
Last active Aug 29, 2015
Object Oriented Programming I and II
View cat.rb
class Cat
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
def feed(food)
puts "Mmmmm, " + food + "!"
Ahnita / Each.rb
Last active Aug 29, 2015
Data Structures
View Each.rb
def fav_foods
food_array = []
3.times do
puts "Name a favorite food."
food_array << gets.chomp
p food_array
puts "Your favorite foods are #{food_array.join(",")}."
food_array.each do |food|
puts "I like #{food} too!"
Ahnita / case.rb
Last active Aug 29, 2015
Control Flow in Ruby
View case.rb
def choose
puts "Do you like programming? Yes or no please."
choice = gets.chomp
case choice.downcase
when "yes"
puts "That\'s great!"
when "no"
puts "That\'s too bad!"
when "maybe"
puts "Glad you are giving it a chance!"
Ahnita / Modal script.js
Last active Aug 29, 2015
Updates July 17
View Modal script.js
$(document).ready(function() {
View program.rb
def greeting #here we say def to define a method and put the name of our method
puts "Please enter your name:"
name = gets.chomp
puts "hello" + " " + name #here's the code inside our method
end #and here we end or close our method
View navbar.css
/* Nav Bar */
nav li ul {
float: right;
width: 100%;
position: fixed;
letter-spacing: 0.05em;
font-family: 'Josefin Sans', serif;
color: #FAFFFF;
z-index: 6;
display: inline-block;
View MapBuilder Script
google.maps.event.addDomListener(window, 'load', init);
var map;
function init() {
var mapOptions = {
center: new google.maps.LatLng(MY COORDINATES),
zoom: 15,
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.DEFAULT,
View kitties.js
var myKitties = [ { title: "Moderne Manila", pic: "" },
{ title: "Second Project", pic: "" },
{ title: "Third Project", pic: "" },
for (var i=0; i<myKitties.length; ++i) {
$("#" + i).css("background-image", "url(" + myKitties[i].pic + ")");
View Custom Media Screen FAQ
.nav ul li {
display: inline-block;
padding: 20px 10px 20px;
.nav ul li a {
text-transform: uppercase;
letter-spacing: 0.05em;
font-family: 'Josefin Sans', serif;
color: #FAFFFF;