Skip to content
View better_feedback.md

Better Feedback - 5 min? O.o

http://tinyurl.com/better-feedback

Feedback lets you understand what is happening, why things are what they are, and what is possible. It needs to be fast, easily accessible, and relevant.

View sql.xml
<?xml version="1.0" encoding="utf-8" ?>
<!-- SQL XML created by WWW SQL Designer, https://github.com/ondras/wwwsqldesigner/ -->
<!-- Active URL: http://ondras.zarovi.cz/sql/demo/ -->
<sql>
<datatypes db="mysql">
<group label="Numeric" color="rgb(238,238,170)">
<type label="Integer" length="0" sql="INTEGER" quote=""/>
<type label="TINYINT" length="0" sql="TINYINT" quote=""/>
<type label="SMALLINT" length="0" sql="SMALLINT" quote=""/>
<type label="MEDIUMINT" length="0" sql="MEDIUMINT" quote=""/>
View example_of_many_to_many_in_active_record.rb
# https://github.com/BrantDFaulkner/database_schema
require 'active_record'
require 'logger'
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
ActiveRecord::Base.logger = Logger.new $stdout
ActiveSupport::LogSubscriber.colorize_logging = false
ActiveRecord::Schema.define do
self.verbose = false
View fcc_map.rb
require 'nokogiri'
require 'rest-client'
require 'erb'
def get_html(url, filename)
one_hour = 1*60*60
stale_time = Time.now - one_hour
if File.exist?(filename) && stale_time < File.stat(filename).mtime
File.read filename
View Syntax.elm
-- In Ruby we can chain methods:
-- [1,2,3,4,5].map { |n| n * 2 }.reverse.take(3).reduce(0, :+)
--
-- Do functional languages have syntactic patterns which flow nicely like this?
--
-- Justin came up with Elm's `|>` operator, which is borrowed from F# and inspired by Unix pipes
-- https://twitter.com/JAH2488/status/724314816790159360
--
-- Li Husan also came up with a good idea for Haskell, but I haven't tried it yet (it's easier to play with Elm)
-- "You can do f = (a . b . c . d) in Haskell, although that's function composition."
View bits.rb
def eq!(a, b)
return true if a == b
message = "#{a.inspect} != #{b.inspect} @ #{caller[0].split(":")[1]}"
raise message
end
# ===== Basic =====
# List of truth tables and gate symbols @ http://www.allaboutcircuits.com/worksheets/basic-logic-gates/
def nand!(a, b) # Given
a_and_b = a&b
View gilded_rose1.rb
def update_quality(items)
items.each do |item|
if item.name != 'Aged Brie' && item.name != 'Backstage passes to a TAFKAL80ETC concert'
if item.quality > 0
if item.name != 'Sulfuras, Hand of Ragnaros'
item.quality -= 1
end
end
else
if item.quality < 50
View flyer_collage.rb
require 'set'
class Image
def self.box(name, colour:, w:, h:)
new name, Array.new(h) { Array.new w, [colour] }
end
attr_reader :name
def initialize(name, pixels)
View refactorings.md

You've already written several tests https://github.com/selfup/rejs/blob/7def485717b2adf52ad7662857d8eada828fd4b3/test/run_test.js, it's probably worth dropping them in a real test suite and adding some assertions so that it doesn't require interpreting the output.

https://github.com/selfup/rejs/blob/7def485717b2adf52ad7662857d8eada828fd4b3/re.js#L28 you can prob do the new syntax like ...props so that you can use multiple properties when selecting

The string interpolation on the id is probably not necessary. https://github.com/selfup/rejs/blob/7def485717b2adf52ad7662857d8eada828fd4b3/re.js#L33 ie whereTable[ids[i]] probably works.

https://github.com/selfup/rejs/blob/7def485717b2adf52ad7662857d8eada828fd4b3/re.js#L31-L32 seems to be a select and a map, looks like lodash has a "filter" method for that https://lodash.com/docs#filter and a map method https://lodash.com/docs#map

Actually, the map is only necessary b/c you want to work with the values instead of the ids, so ask for them instead of keys htt

View check-chars-iterating-from-beginning-to-middle.js
// https://www.freecodecamp.com/challenges/check-for-palindromes#?solution=function%20palindrome(str)%20%7B%0A%20%20str%20%3D%20str.toLowerCase().replace(%2F%5B%5Ea-z0-9%5D%2Fg%2C%20%22%22)%3B%0A%20%20for(var%20i%20%3D%200%3B%20i%20%3C%20str.length%2F2%3B%20%2B%2Bi)%20%0A%20%20%20%20if(str%5Bi%5D%20!%3D%3D%20str%5Bstr.length-i-1%5D)%0A%20%20%20%20%20%20return%20false%3B%0A%20%20return%20true%3B%0A%7D%0A%0A%0A%0Apalindrome(%22eye%22)%3B%0A
function palindrome(str) {
str = str.toLowerCase().replace(/[^a-z0-9]/g, "");
for(var i = 0; i < str.length/2; ++i) {
if(str[i] !== str[str.length-i-1]) {
return false;
}
}
return true;
}
Something went wrong with that request. Please try again.