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 / 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 / flexslider.js
Last active December 11, 2015 19:28 — forked from dcatkins40/Flexslider to Change Background Image
[wp - forked] - Flexslider to Change Background Image
$(document).ready(function() {
var imgArr = new Array (
<?php
$total = count(get_field('field'));
$count = 1;
while(the_repeater_field('field', $pagenumber)): ?>
'<?php the_sub_field('sub_field'); ?>'<?php if($count < $total){echo ',';} $count++; ?>
<?php endwhile; ?>
);
var n = 0;
@ajmalafif
ajmalafif / blackandwhiteimages.php
Created January 27, 2013 21:21
[wp - forked] - Generate B + W images in WordPress
<?php
add_image_size('thumbnail-bw', 400, 0, false);
add_filter('wp_generate_attachment_metadata','bw_images_filter');
function bw_images_filter($meta) {
$file = wp_upload_dir();
$file = trailingslashit($file['path']).$meta['sizes']['thumbnail-bw']['file'];
list($orig_w, $orig_h, $orig_type) = @getimagesize($file);
$image = wp_load_image($file);
imagefilter($image, IMG_FILTER_GRAYSCALE);
@ajmalafif
ajmalafif / gitio
Created March 8, 2013 13:38 — forked from defunkt/gitio
#!/usr/bin/env ruby
# Usage: gitio URL [CODE]
#
# Turns a github.com URL
# into a git.io URL
#
# Copies the git.io URL to your clipboard.
url = ARGV[0]
code = ARGV[1]
<html>
<head>
<title>
Demo Cross Domain
</title>
<!-- Le styles -->
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
<style>
body {