This file contains hidden or 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 | |
| require 'win32ole' | |
| e=WIN32OLE::connect "Excel.Application" | |
| e.Sheets.Count.times do |n| | |
| sheet = e.Sheets(n + 1) | |
| v = sheet.UsedRange.Value2 | |
| puts "=== Sheet: #{sheet.Name}" | |
| v.each do |row| | |
| puts row.map {|x| x || ""}.join "\t" | |
| end |
This file contains hidden or 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 | |
| /bin/curl -k -F apikey=xxxxxxx -F application=Transmission -F event="Download Complete" -F description="$TR_TORRENT_NAME completed on $TR_TIME_LOCALTIME" https://api.prowlapp.com/publicapi/add |
This file contains hidden or 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 elixir | |
| # https://elixirquiz.github.io/2014-11-01-game-of-life.html | |
| defmodule Conway do | |
| defstruct lookup: HashDict.new, rows: 0, cols: 0 | |
| def run_file(filename) do | |
| case load_file(filename) do | |
| {:ok, initial_state} -> |
This file contains hidden or 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 'liquid' | |
| class SetClrCondition < Liquid::Tag | |
| include Liquid | |
| def initialize(tag_name, condition, tokens) | |
| super | |
| @condition = condition | |
| end |
This file contains hidden or 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 hand is a list of five with tuples {rank, color} | |
| defmodule Hand do | |
| @ranks 2..10 |> Enum.concat([:j, :q, :k, :a]) | |
| @consecutive_ranks (@ranks | |
| |> Stream.cycle | |
| |> Stream.chunk(2,1) | |
| |> Enum.take(13)) | |
| @rank_weight (@ranks | |
| |> Enum.with_index |
This file contains hidden or 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
| defmodule LineFollower do | |
| using Time.PLC | |
| # These may be extracted to a separate module | |
| # input and output are macros that generate something lacced 'optical' and 'pwm' | |
| # that somehow link to the signal 'objects'. Think Ruby 'attr' function | |
| # the physical addresses are linked to the actual hardware being used | |
| input :optical, "I3.0", desc: "Optical line sensor" | |
| output :pwm, "PIW100", desc: "Steering motor PWM input" | |
This file contains hidden or 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
| defmodule ConvexHull do | |
| @type coordinate :: {number, number} | |
| @type point_list :: [coordinate] | |
| @spec find(point_list) :: point_list | |
| def find(points) do | |
| sorted = points |> Enum.sort | |
| left = sorted |> do_half_calc | |
| right = sorted |> Enum.reverse |> do_half_calc | |
| [left, right] |> Enum.concat |
This file contains hidden or 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 'minitest/autorun' | |
| module ConvexHull | |
| class << self | |
| def find(points) | |
| sorted = points.sort.uniq | |
| reversed = sorted.reverse | |
| [sorted, reversed].map do |points| | |
| points. | |
| reduce([]) {|acc, p| add_to_convex_list p, acc }. |
This file contains hidden or 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
| defmodule Bubble do | |
| def sort(list) do | |
| do_sort list, {[], false} | |
| end | |
| defp do_sort([a, b | tail], {acc, _}) when b < a do | |
| do_sort [a | tail], {[b | acc], true} | |
| end | |
| defp do_sort([a | tail], {acc, swapped?}) do |
This file contains hidden or 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
| $ elixir tuplify.exs | |
| Returned from macro: | |
| def(tuplify_from_macro(x)) do | |
| {unquote(Macro.var(:x, nil))} | |
| end | |
| ** (CompileError) tuplify.exs:21: function x/0 undefined | |
| (stdlib) lists.erl:1336: :lists.foreach/2 | |
| tuplify.exs:14: (file) | |
| (elixir) lib/code.ex:307: Code.require_file/2 | |