- GitHub Staff
- https://justinherrick.com/
- @jah2488
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
i = 0 | |
nums = [] | |
while i < 1000 | |
nums << i if i%3 == 0 or if i%5 == 0 | |
i+=1 | |
end | |
nums.inject{|sum,i| sum + i } |
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
//===================================================================================== | |
// Program Name: TicTacToe | |
// Author: Gonzales Cenelia | |
// Website: www.ai-programming.com | |
// | |
// This is a complete Tictactoe game, it include many functionalities, you can play games | |
// against another human, you can play against the computer, you can also even let the computer | |
// play against itself. The A.I is very good, actualy it is unbeatable, the most you can do is to | |
// draw the games. Also, the game include statistics (number of win, draw an lost games) for the |
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
(defn rainbow-print [msg] | |
(let [colors ["31m" "32m" "33m" "34m" "35m" "36m" "37m"] | |
costr (fn [color msg] (str "\033[" color msg "\033[m"))] | |
(println | |
(str (apply str (map #(costr (rand-nth colors) %) (clojure.string/split msg #"\d*"))))))) |
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
User = Struct.new :username, :password | |
user = User.new "Josh", "super" | |
user.instance_variables # => [] | |
user.public_methods(false) # => [:username, :username=, :password, :password=] |
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
" Ge off my lawn | |
nnoremap <Left> :echoe "Use h"<CR> | |
nnoremap <Right> :echoe "Use l"<CR> | |
nnoremap <Up> :echoe "Use k"<CR> | |
nnoremap <Down> :echoe "Use j"<CR> |
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
require 'rubygems' | |
require 'rspec' | |
module FakeIt | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
def mocks(class_name) | |
class_name.instance_methods(false).map { |method_name| define_method(method_name) { |*args| } } |
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
(declare rank-board) | |
(defn best-move [board player] | |
(let [moves (empty-cells board) | |
scores (zipmap moves (map #(rank-board (update-board board % player) player 1) moves)) | |
best-score (reduce max (vals scores)) | |
best-moves (filter #(= (scores %) best-score) moves)] | |
(rand-nth best-moves))) | |
(defn rank-board |
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
def self.by_name(query) | |
response = [""] | |
names = query.split | |
names.each do |value| | |
response[0] += names.last.equal?(value) ? "lower(name) LIKE '%'||?||'%'" : "lower(name) LIKE '%'||?||'%' AND " | |
response << value.downcase | |
end | |
find(:all, :conditions => response) | |
end |
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/env python | |
#=========================================================================================================================================== | |
# ---- Productivity Calculator for Erepublik Beta and V1 ---- | |
## Created by me | |
# | |
# Beta 0.3.5 -- October 25th 2008 | |
# | |
##Notes | |
# | |
## Fatal Occurs during Windows EXE. Something wrong with the SHELVE Module |
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
def changer(change) | |
[25,10,5,1].map do |coin| | |
rem = change / coin | |
change -= (rem * coin) | |
[coin] * rem | |
end.flatten | |
end | |
# Invocations = 5 | |
# Assignments = 2 (or 3 if you count the Array Literal) |