Skip to content

Instantly share code, notes, and snippets.

require 'date'
date = DateTime.now
jd = date.jd
t = (jd - 2_451_545.0) / 36_525.0
ma = [1287104.793048, 129596581.0481, - 0.5532, 0.000136, - 0.00001149]
@horner = lambda { |t, abc|
abc.each_with_index.reduce(0){|a, (e, i)| a + e * t**i}
}
require 'date'
include Math
D2R = PI / 180.0
R2D = 180.0 / PI
def jc(jd)
(jd - 2_451_545) / 36_525.0
end
require 'date'
include Math
D2R = PI / 180.0
R2D = 180.0 / PI
def gml_sun(jc)
(280.46646 + jc * (36_000.76983 + jc * 0.0003032)) % 360.0
end
@DouglasAllen
DouglasAllen / vowels_consonants_counter.c
Created February 11, 2017 11:46
C main program takes a string input and counts the number of vowels and consonants.
//**************************************
// Name: vowels_consonants_counter.c
// Description:
// Consonants and Vowels Counter in C
// A sample program that will ask the user to enter a work or
// a sentence and then the program will count how many consonants and
// vowels in a given word or sentence by the user.
// Take note I am using Turbo C 2.0 For DOS as my C compiler in this program.
//
@DouglasAllen
DouglasAllen / sunrise.cpp
Last active February 11, 2017 03:37
Qt Sunrise author unknown appears to be based upon the Wikipedia sunrise equation
#include <QtCore>
#include "sunrise.h"
Sunrise::Sunrise(double latitude_, double longitude_, double elevation_)
: latitude(latitude_)
, longitude(-longitude_)
, elevation(elevation_)
{
// Daniel Shiffman
// http://codingtra.in
// Mathematical Roses
// Video: https://youtu.be/f5QBExMNB1I
// Based on: https://en.wikipedia.org/wiki/Rose_(mathematics)
var d = 8;
var n = 5;
var sliderD;
var sliderN;
@DouglasAllen
DouglasAllen / simple_rose.rb
Created February 10, 2017 02:01
This will run in Ruby Shoes only. see... http://shoesrb.com/
# could be the start of a nice spirograpgh program
# require 'green_shoes'
Shoes.app height: 820, width: 1420, title: ' Roseland Revisited' do
background black
@center_y = height / 2
@center_x = width / 2
@radius = @center_x / @center_y * @center_x
para @radius.to_s
@DouglasAllen
DouglasAllen / SolarInfo.cs
Created October 14, 2016 00:29 — forked from cstrahan/SolarInfo.cs
A sunrise/sunset calculator.
using System;
using System.Diagnostics;
namespace SunriseCalculator
{
public class SolarInfo
{
public double SolarDeclination { get; private set; }
public TimeSpan EquationOfTime { get; private set; }
public DateTime Sunrise { get; private set; }
project :test => :shoulda, :renderer => :haml, :stylesheet => :sass, :script => :jquery, :orm => :activerecord
#default routes
APP_INIT = <<-APP
get "/" do
"Hello World!"
end
get :about, :map => '/about_us' do
render :haml, "%p This is a sample blog created to demonstrate the power of Padrino!"
# method_call.rb
def hello
"Hello there!"
end
hi = method :hello
def say mo
mo.call