Skip to content

Instantly share code, notes, and snippets.

View Atlas7's full-sized avatar

Johnny Chan Atlas7

View GitHub Profile
@Atlas7
Atlas7 / cpadTDDMochaChaiBasics.js
Created October 14, 2016 22:23
cpadTDDMochaChaiBasics.js
const Mocha = require ('mocha')
const assert = require('chai').assert
const mocha = new Mocha ({ui: 'bdd'})
mocha.suite.emit('pre-require', this, 'solution', mocha)
describe('Test suite', () => {
it('should work', () => {
assert(true)
})
@Atlas7
Atlas7 / composition.md
Last active October 13, 2016 12:28
Use composition over inheritance

Composition over Inheritance

"Inheritance encourages you to build this taxonomy of objects very early on in the project. And you are most likely going to make big design mistakes while doing that. Because humans cannot predict the future."

"I think it's just better to use composition from the start. It's more flexible, it's more powerful, and it's really easy to do."

-- Mattias P Johansson, @mpjme

FunFunFunction - Composition over Inheritance

@Atlas7
Atlas7 / coderpad_tdd_test_suites.js
Last active April 25, 2021 23:02
CoderPad - Mocha Chai Assert TDD Test Suite
// ***** Requirements
// Implement function sequence, which returns new n-size Array filled according to pattern.
//
// pattern may be:
// - a function that takes two: (element, index), one: (element) or any arguments (similar to map function), then filled running this function, in other words: function describes sequence,
// - number, string or any other object, then filled by copying, this object n-times.
//
// ****** Solution
@Atlas7
Atlas7 / sas_count_number_of_columns_with_array.md
Last active May 12, 2016 11:49
SAS - count number of colums with array

Say you have a dataset. You wish to find out the number of character columns, numerical columns, and total columns.

One way to do this is to use the SAS array in conjunction with dim() function.

I've created the following code demo to illustrate this - inspired by this SAS blog forum.

data all_chars;
	var1 = "hello";
	var2 = "world";
@Atlas7
Atlas7 / hello_world.sas
Created March 13, 2016 14:27
hello_world.sas
data hello_world;
put "hello world";
run;
@Atlas7
Atlas7 / gist_sas_syntax_highlighting_test.md
Created March 13, 2016 14:26
Gist SAS Syntax Highlighting Test

This is a SAS Code:

data junk;
  put "hello world";
run;

Any syntax highlighting?

@Atlas7
Atlas7 / git_stash_only_one_files_out_of_multiple_files_that_have_changed.md
Created March 2, 2016 09:56
Git - Stash only one file out of multiple files that have changed with Git?

Say I have 5 files: (file1, file2, ... file5).

All have been commited.

Say now all 5 files have been changed.

When you issue git status, all 5 files should be shown as (red) unstaged status.

Say I am happy with the changes in file1 to file4, but not file5 (i.e. I'd like to revert file5 to the last committed stage).

@Atlas7
Atlas7 / rails_model_association_and_migration.md
Last active March 1, 2016 11:41
Rails - Model Association and Migration

Say we have two models like this:

class Supplier < ActiveRecord::Base
  has_one :account
end

class Account < ActiveRecord::Base
  belongs_to :supplier
end
@Atlas7
Atlas7 / rails_console_basics_new_save_puts.md
Last active October 10, 2020 20:23
Rails Console - Basics - new, save, and puts

# Models

After issuing:

rails g model Supplier
rails g model Account
@Atlas7
Atlas7 / remove_postgres_on_mac_os.md
Last active March 23, 2023 13:02
Note - How completely uninstall PostgreSQL 9.X on Mac OSX

This blog post has helped me clean up my postgres development environment on Mac. So making a copy!

How completely uninstall PostgreSQL 9.X on Mac OSX

This article is referenced from stackoverflow:

If installed PostgreSQL with homebrew , enter brew uninstall postgresql

If you used the EnterpriseDB installer , follow the following step.