Skip to content

Instantly share code, notes, and snippets.

View kierarad's full-sized avatar

Kiera Radman kierarad

View GitHub Profile
class Sudoku
attr_reader :position, :current_cell_value
def initialize(board_string)
@board = []
@board_string = board_string
@position = [7,6] #[row, col]
@board_string.split(//).each_slice(9) {|slice| @board << slice}
@current_cell_value = @board[@position[0]][@position[1]]
@box_coord_hash = { box1: [[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]],

##Initializing a new repo Type in what comes AFTER the $...do not type in the $

BASIC git initialization and repo creation:

$ git init

This command creates an empty git repository - basically a .git directory with subdirectories for objects, refs/heads, refs/tags, and template files. An initial HEAD file that references the HEAD of the master branch is also created.

class Computer_Board
attr_reader :board
def initialize
@ships = [%w[A A A A A], %w[B B B B], %w[C C C], %w[D D], %w[D D], %w[S S], %w[S S]]
@board = Array.new(10) {Array.new(10,'/')}
@mvmt = [ [-1, 0], #top
[0, 1], #right
@kierarad
kierarad / gist:6532987
Created September 12, 2013 04:14
repository url for active_record challenge
https://github.com/kierarad/ar-student-schema
@kierarad
kierarad / ajax date button
Created October 3, 2013 22:16
AJAX example
function displayGetResults(x){
$("#container").replaceWith(x);
};
function getNextDay(event) {
event.preventDefault();
var link = $("#nextDayLink").attr("href")+'/content';
$.get(link, displayGetResults);
};
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
A few things to note about AJAX and JQuery with Rails:
1- Rails ships with CoffeeScript (see coffeescript.org)
2- Jquery is officially bundled with the Rails (jquery-rails gem)
3- Rails uses Unobtrusive JavaScript (jquery_ujs library)
Unobtrusive JavaScript? What's that?
- ujs is a way to seperate your HTML, and CSS from your Javascript
So how do we do that? Here is an example of obtrusive javascript:
$(document).ready(function() {
$('#roller button.add').on('click', function() {
console.log("WAT")
$('.dice').append('<div class="die">0</div>');
});
$('#roller button.roll').on('click', function() {
$('.die').each(function(k, die) {
var value = Math.floor((Math.random()*6)+1);
$(die).text(value);
---
format_version: 3
environments:
internal:
pipelines:
- gocd-trial-launcher
- gocd-trial-installers
pipelines:
gocd-trial-launcher:
group: go-cd-contrib
environments:
default:
pipelines:
- repo2-pipeline
pipelines:
repo2-pipeline:
group: POC
materials:
foo-pipeline:
pipeline: Build-Test