Skip to content

Instantly share code, notes, and snippets.

Adhere strictly to Single Responsibility Principle for functions as well as classes - each function should do exactly one thing and do it well. Use function names that clearly describe their purpose, making comments often unnecessary. Strongly prefer a pipeline of small, focused functions over monolithic functions with multiple responsibilities. Aim for functions that are short enough to view without scrolling (typically under 20 lines).
Pull magic strings and magic numbers out into constants--don't embed them directly in the middle of functions.
Do not add comments that are self-explanatory (e.g., // Constants)--make function names self-explanatory.
Do not add comments as headers describing blocks of code. That's often an indicator that block of code should be a function named that thing you were describing. (e.g., "// print heading" should become printHeading())
TypeScript functions always need argument types and return types. If you don't know the type, go find out by looking at the function you get
@mikelovesrobots
mikelovesrobots / .gitignore
Created February 26, 2018 22:18
react-native gitignore
# OSX
#
.DS_Store
# React Native
#
/node_modules
/ios/kif_screenshots/
*.jsbundle*
local LCS = require 'LCS'
local System = require 'knife.system'
local drawImage = require 'systems.drawImage'
local drawBackgroundColor = require 'systems.drawBackgroundColor'
local fadeIn = require 'systems.fadeIn'
local colors = {
white = {255, 255, 255, 255},
lightGreen = {208, 231, 153, 255},
lightPink = {251, 239, 244, 255},
Shader "Hidden/RedOffsetShader" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
@mikelovesrobots
mikelovesrobots / drone.yml
Created July 25, 2017 23:30
one way of using yaml features to DRY up drone.yml
invalidate-cloudfront-common: &invalidate-cloudfront-common
image: cgswong/aws:aws
commands:
- aws configure set preview.cloudfront true
- aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "/*"
secrets: [AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY]
pipeline:
invalidate-cloudfront-dev:
<<: *invalidate-cloudfront-common
import { sample } from 'lodash'
export default class TitleGenerator {
static generate() {
return sample(this.phrases())
}
static phrases() {
return [
`${sample(this.gibberish())} the ${sample(this.adjectives())} aspect ${sample(this.rises())}. ${sample(this.gibberish())} ${sample(this.interrogations())}`,
@mikelovesrobots
mikelovesrobots / gist:abaf9e651652f480facf39a16395ea4a
Last active March 7, 2017 01:02
How Substantial keeps things going smoothly [outline]
Organizational Tools:
* Trello for prioritizing the most important thing to be working on next
(typically divided into backlog, doing, review and done columns)
* Github pull requests before merging code to master
(not just programmers: artists and other interested parties have a say too)
Regular Meetings:
* Morning team standups
@mikelovesrobots
mikelovesrobots / MikeBlindBot.rb
Created December 2, 2016 00:58
Rtanque Bot 2 - no longer so blind
class MikeBlindBot < RTanque::Bot::Brain
NAME = 'MikeBlindBot2'
include RTanque::Bot::BrainHelper
TURRET_FIRE_RANGE = RTanque::Heading::ONE_DEGREE * 1.0
def tick!
## main logic goes here
@direction_degrees ||= 0
if self.sensors.position.on_top_wall?
class MikeBlindBot < RTanque::Bot::Brain
NAME = 'MikeBlindBot'
include RTanque::Bot::BrainHelper
def tick!
## main logic goes here
@direction_degrees ||= 0
if self.sensors.position.on_top_wall?
@direction_degrees = -180
elsif self.sensors.position.on_bottom_wall?
using UnityEngine;
using System;
using System.Collections;
public class CheatActivator : MonoBehaviour {
private DateTime ClickedAt;
private const int MIN_SECONDS = 5;
private const string CHEAT_SCENE = "Cheats";
public void OnPress(bool isDown) {