Skip to content

Instantly share code, notes, and snippets.

View code-review-for-the-worlds-best-method-naming-scheme
// Unless this is being accessed beyond this class
// and by packages outside of the scope of this project,
// e.g. This project being imported as a library, you
// should make this private.
public int countX(String str) {
return getNumOfX(str, 0);
}
// Rather than having two separate methods
// take advantage of Java polymorphism and use
View Mr-Robot.js
let ejsdata = {
"debug":0,
"clock":{
"current":false,
"on_air":false,
"off_air":false,
"remaining":false,
"interstitial":[],
"interval":false,
View Bad Lambda
const pg = require('pg')
const connectionString = '...' // Commented out for security
module.exports.query = (event, context, callback) => {
const client = new pg.Client(connectionString)
client.connect()
client.query('select * from users limit 1', (err, res) => {
if (err) {
console.log(err)
View polymorphism-notes.clj
;; Abstractions with multimethods, protocols, records
;; multimethods
;; useful for overloading based on dispatching
;; vnice
(ns ware-creatures)
(defmulti full-moon-behavior (fn [were-creature] (:were-type were-creature)))
;; Typical multimethods look like so...
(defmethod full-moon-behavior :wolf ;; dispatching value is a keyword
@admay
admay / automata.html
Last active Sep 12, 2016
CSS + JS to create a cellular automata
View automata.html
<!DOCTYPE html>
<html>
<head>
<style>
.row div {
height: 8px;
display: inline-block;
width: 8px;
}