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 script to solve Euler Problem 22 | |
# names.txt d/l'd from http://projecteuler.net/project/names.txt | |
nf = File.open("names.txt", 'r') | |
names = nf.gets.scan(/\w+/).sort | |
total = 0 | |
names.each_with_index do |n,i| | |
tmp = 0 |
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/ruby | |
sum = 0 | |
x = (1..1000).to_a | |
x.each do |n| | |
sum += n**n | |
end | |
puts sum |
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/ruby | |
foo = "a bitch" | |
problems = (1..99).to_a | |
sum = 0 | |
problems.each do |x| | |
if x == foo | |
next | |
else | |
sum += 1 |
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
origParse = Date.parse | |
Date.parse = (date) -> | |
timestamp = origParse(date) | |
if isNaN(timestamp) && date.match(/^\d{4}-\d{2}-\d{2}/) | |
dary = date.split('-') | |
timestamp = origParse(dary[1] + '/' + dary[2] + '/' + dary[0]) | |
return timestamp |
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
DNS Info: | |
Whois Server Version 2.0 | |
Domain names in the .com and .net domains can now be registered | |
with many different competing registrars. Go to http://www.internic.net | |
for detailed information. | |
Domain Name: FUNNYJUNK.COM | |
Registrar: MONIKER ONLINE SERVICES, INC. |
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
#!/bin/sh | |
# | |
# init.d script for single or multiple unicorn installations. Expects at least one .conf | |
# file in /etc/unicorn | |
# | |
# Modified by [email protected] http://github.com/jaygooby | |
# based on http://gist.github.com/308216 by http://github.com/mguterl | |
# | |
## A sample /etc/unicorn/my_app.conf | |
## |
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 ruby | |
file = File.read(__FILE__) | |
name = "quinebunny-#{Time.now.to_s.gsub(/\s/, '')}.rb" | |
io = File.new(name, 'w') | |
io.write(file) | |
io.close | |
%x(ruby #{name}) |
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
;; solution to Fibonacci Sequence | |
;; https://4clojure.com/problem/26 | |
(fn [n] (take n (map first (iterate (fn [[a b]] (vector b (+ a b))) [1 1]))))) |
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
# In the controller: | |
private | |
def maybe(param) | |
if params[param] | |
{param => params[param]} | |
end | |
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
class Issue < ActiveRecord::Base | |
named_scope :tasks, :conditions => {:tracker_id => 7} # if the id of the Tasks tracker is 7, natch | |
named_scope :open, :conditions => {:status_id => 1} # assuming 'Open' == 1 | |
end | |
# Then in your controller action: |
OlderNewer