View index_approach.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string = "This is a Ruby tutorial." | |
# This returns the index where the 1st instance of i occurs | |
string.index('i') | |
# This code returns 2 |
View scan_method.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string = "This is a Ruby tutorial." | |
# Here we will return an array containing each instance of i | |
string.scan('i') | |
# This code returns ["i", "i", "i"] |
View count_method.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string = 'This is a Ruby tutorial.' | |
string.count('i') | |
# This returns the integer 3 | |
# case sensitive example | |
string.count('r') | |
# This returns the integer 1 | |
string.count('r', + 'R') | |
# This returns the integer 2 |
View RollingDie.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package rollingdie; | |
import java.util.Random; | |
import java.util.Scanner; | |
import java.util.*; | |
import java.util.Arrays; |
View gist:2d576c294258fb5a22c4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rename "old" "new" * | |
# * means all files |
View permute_tri.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = [60, -60] | |
# 4 refers to number of 60s or -60s in each element of array | |
a = a.repeated_permutation(6).to_a | |
puts "The array contains #{a.length} elements." | |
#creates output file called permute.txt | |
out_file = File.new("permute_out.txt", "w") | |
View course_tracker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Purdue North Central doesn't have waitlists, but you can get notified of seat availability with this app | |
require 'rubygems' | |
require 'open-uri' | |
require 'hpricot' | |
require 'twilio-ruby' | |
availability = 0 | |
puts "Enter the CRN for the PNC course you would like to track:" | |
crn = gets.chomp.to_s |
View gist:6f0abd275e9f76484980
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
wp_reset_postdata(); | |
if(comments_open( ) || have_comments()) : ?> | |
<div class="comments-area"> | |
<?php if ( post_password_required() ) : ?> | |
<p><?php _e( 'This post is password protected. Enter the password to view any comments ', 'zeon' ); ?></p> | |
</div> | |
<?php | |
/* Stop the rest of comments.php from being processed, |
View step_and_time.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ruby 2.2.1p85 (2015-02-26 revision 49769) | |
#energies files must contain time on left column, energy on right, separated by space | |
#change paths on line 73 | |
energies = Dir.glob('*energies.txt') | |
energies = energies.pop | |
text = File.open(energies).read | |
text = text.to_s | |
array = text.split("\n") |
View name_sanitizer.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
#Prints out the name in a "sanitized" form of "First M. Last"; that is, first name, space, middle initial, period, space, last name. | |
#If there is no middle name, prints the letter X with no period following it. | |
#If there are multiple middle names, uses the initial of the first one. | |
my $name = "Melanie Aurelia Shebel"; |
NewerOlder