Skip to content

Instantly share code, notes, and snippets.

View ajmalafif's full-sized avatar
💻

Ajmal Afif ajmalafif

💻
View GitHub Profile
@ajmalafif
ajmalafif / posterous-octopress.rb
Created March 5, 2012 09:05 — forked from rmurphey/posterous-octopress.rb
[ruby] - Generate Octopress posts from Posterous XML
#!/usr/bin/env ruby
require 'xmlsimple'
require 'active_support/inflector'
require 'yaml'
require 'json'
require 'fileutils'
require 'date'
class Post
@ajmalafif
ajmalafif / schneems.md
Last active October 7, 2015 14:48 — forked from schneems/gist:2968840
[rails] - Databases and Rails Recap Quiz for Week 2

Week 3 Quiz

1) What does ORM stand for?

Object Relational Mapper

2) What are the four functions of persistent storage? (hint: CRUD)

@ajmalafif
ajmalafif / smiley.rb
Created September 17, 2012 04:52
[Bloc.io] Happy or Sad
def smiley(feel = {mood: "happy", mood: "sad", mood: "weird"})
if
feel == {"mood" => "happy"}
":)"
elsif
feel == {"mood" => "sad"}
":("
else
feel == {"mood" => "weird"}
":|"
@ajmalafif
ajmalafif / fun_tricks.rb
Last active October 10, 2015 20:58 — forked from bushymark/gist:173565
[ruby] - Ruby tricks by Nick Quaranto
stupid ruby tricks
Posted by Nick Quaranto
# Over the past few months of slinging Ruby here at Thoughtbot, I’ve picked up quite a
# few stupid ruby tricks smart ruby techniques that really help out your code.
# If you’ve got your own, feel free to leave a comment.
# Destructuring yielded arrays
def touch_down
@ajmalafif
ajmalafif / print_grid.rb
Created October 4, 2012 20:09
[Bloc - ruby weekly] Print a 5 x 5 grid
# Define a method and accept an unspecified number of arguments and insert them into an
# array called coords. The array is created with the "*".
def print_grid_1a(*coords)
# Create an array called grid consisting of 5 elements each with a string
# consisting of 5 O's
grid = Array.new(5) {"O" * 5}
# Assign the variable x to the first element of the coords array and y to the second
x, y = coords
# Change the O to an X in the x indexed character inside the string ("OOOOO")
# that is in the y element of the grid array
@ajmalafif
ajmalafif / learn.rb
Last active October 11, 2015 13:38
[ruby] - Classes, initialize method, instance variable
# http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_classes.html
class Learn
def initialize(*arguments)
@var1, @var2 = arguments
end
def method
"#{@var1} #{@var2}"
end
@ajmalafif
ajmalafif / shapes.rb
Created October 11, 2012 02:54
Bloc Shape Challenge
class Shape
attr_reader :color
def initialize(color)
@color = color
end
def can_fit?(shape)
self.area < shape.area ? true : false
end
@ajmalafif
ajmalafif / rails.md
Last active December 11, 2015 07:39
[Rails 3] - useful and default starter gems
@ajmalafif
ajmalafif / roots.md
Last active December 11, 2015 08:09
[WP] - Roots Theme common file edits