Skip to content

Instantly share code, notes, and snippets.

@nusco
nusco / programming.rb
Last active April 23, 2020 09:27
A (hypothetical) example of how programming works, as opposed to ML
enemy = get_nearest_enemy()
if enemy.distance() < 100:
decelerate()
if enemy.is_shooting():
raise_shield()
else:
if health() > 0.25:
shoot()
else:
rotate_away_from(enemy)
@nusco
nusco / gradient_multiple_variables.py
Created April 17, 2020 13:47
From "Programming Machine Learning": gradient calculation with multiple input variables
# The gradient with multile input variables
def gradient(X, Y, w):
return 2 * np.matmul(X.T, (predict(X, w) - Y)) / X.shape[0]
@nusco
nusco / cheating_classifier.py
Created March 4, 2020 10:52
A classifier that cheats.
def classify(image):
return False
@nusco
nusco / complex_sentences.txt
Last active August 29, 2015 14:00
A few complex sentences that you can refactor
1. Attempts were made on the part of the President’s aides to assert his immunity from a Congressional subpoena.
2. The author’s analysis of our data omits any citation of sources that would provide support for his criticism of our argument.
3. The agreement by the participants on the program was based on the assumption that there was a promise of federal funds.
4. The board’s rejection of our proposal was a disappointment but not a surprise because of our expectation that a decision had already been made in regard to a delay of any new initiatives.
5. Once deeply understood, the process of true transformation reveals a capability of blending an organization‘s own genetic code with agile DNA, thus allowing for the evolution of a new species of organization. Further learning can be stimulated through the use of external coaching to reach the levels of self-awareness required in an organization to achieve higher levels of efficiency and innovation.
@nusco
nusco / style.md
Last active April 8, 2017 23:13
Joseph William's Style Suggestions from Lesson 3

Diagnosis

Ignoring short introductory phrases ("In the meantime," "Although," etc.), underline the first seven or eight words in each sentence.

Look for three characteristics:

  1. Sentences that begin not with characters, but abstract nouns.
  2. Sentences that take more than six or seven words to get to a verb.
  3. Verbs that are less specific than the actions buried in the nouns around them.
@nusco
nusco / refinement_wrapper.rb
Created March 4, 2014 16:53
Spell: Refinement Wrapper
# =========================
# Spell: Refinement Wrapper
# =========================
# Call an unrefined method from its refinement.
module StringRefinement
refine String do
def reverse
"x#{super}x"
@nusco
nusco / refinement.rb
Created March 4, 2014 16:51
Spell: Refinement
# =================
# Spell: Refinement
# =================
# Patch a class until the end of the file, or (from Ruby 2.1) until the end of the including module.
module MyRefinement
refine String do
def reverse
"my reverse"
@nusco
nusco / prepended_wrapper.rb
Created March 4, 2014 16:49
Spell: Prepended Wrapper
# ========================
# Spell: Prepended Wrapper
# ========================
# Call a method from its prepended override.
module M
def reverse
"x#{super}x"
end
lambda {
setups = []
events = {}
Kernel.send :define_method, :event do |name, &block|
events[name] = block
end
Kernel.send :define_method, :setup do |&block|
setups << block
@nusco
nusco / gist:3323981
Created August 11, 2012 11:40
What Good Error Messages Look Like
~$ brew doctor
Warning: Some keg-only formula are linked into the Cellar.
Linking a keg-only formula, such as gettext, into the cellar with
`brew link f` will cause other formulae to detect them during the
`./configure` step. This may cause problems when compiling those
other formulae.
Binaries provided by keg-only formulae may override system binaries
with other strange results.