class BoggleBoard | |
def initialize(board) | |
@board = board | |
end | |
def create_word(*coords) | |
coords.map { |coord| @board[coord.first][coord.last]}.join("") | |
end | |
Patch mode allows you to stage parts of a changed file, instead of the entire file. This allows you to make concise, well-crafted commits that make for an easier to read history. This feature can improve the quality of the commits. It also makes it easy to remove parts of the changes in a file that were only there for debugging purposes - prior to the commit without having to go back to the editor.
It allows you to see the changes (delta) to the code that you are trying to add, and lets you add them (or not) separately from each other using an interactive prompt. Here's how to use it:
from the command line, either use
- git add -p
HTML templates decouple the UI definition (HTML markup) from the data. If you develop or plan to develop JavaScript applications, you should use a JavaScript client-side templating engine to keep your JavaScript and HTML sufficiently decoupled, which will allow you to manage your HTML and JS files reliably and easily.
Mustache is a logic-less template syntax. It can be used for HTML, config files, source code - anything. It works by expanding tags in a template using values provided in a hash or object.
We call it "logic-less" because there are no if statements, else clauses, or for loops. Instead there are only tags. Some tags are replaced with a value, some nothing, and others a series of values.
You pass your data as an object (a regular JavaScript object) to the Handlebars function. The data object is called the context. And this object can be comprised of arrays, strings, numbers, other objects, or a combination of all of these.
Most developers that are not aware of template systems create new chunks
{ | |
"auto_complete_commit_on_tab": true, | |
"auto_complete_delay": 0, | |
"bold_folder_labels": true, | |
"caret_style": "wide", |
lambda x: -683.923549636 | |
lambda x: -116.783533207 * (-(x[6] - -5.1676818541) if x[6] <= -5.41238626298 else 0 if x[6] >= -4.67412019866 else (-0.007619371398 * (x[6] - -4.67412019866) ** 2 + -0.61845994042 * (x[6] - -4.67412019866) ** 3)) | |
lambda x: -29.1588158614 * (0 if x[6] <= -0.137738977403 else (x[6] - 0.751892264604) if x[6] >= 1.25162817331 else (0.0569021591939 * (x[6] - -0.137738977403) ** 2 + 0.145377420148 * (x[6] - -0.137738977403) ** 3)) * (0 if x[6] <= -5.41238626298 else (x[6] - -5.1676818541) if x[6] >= -4.67412019866 else (1.36214458707 * (x[6] - -5.41238626298) ** 2 + -0.61845994042 * (x[6] - -5.41238626298) ** 3)) | |
lambda x: 28.2353765603 * (-(x[6] - 0.751892264604) if x[6] <= -0.137738977403 else 0 if x[6] >= 1.25162817331 else (0.662849995222 * (x[6] - 1.25162817331) ** 2 + 0.145377420148 * (x[6] - 1.25162817331) ** 3)) * (0 if x[6] <= -5.41238626298 else (x[6] - -5.1676818541) if x[6] >= -4.67412019866 else (1.36214458707 * (x[6] - -5.41238626298) ** 2 + -0.61845994042 * (x[6] - -5.412386 |
import unittest | |
def gap(g,m,n): | |
primes = [] | |
# finds primes in range | |
for num in xrange(m,n+1,1): # n to be included in range | |
x_half = num / 2 | |
is_prime = all(num % x != 0 for x in xrange(2,x_half+1,1)) | |
if is_prime == True: |
""" First attempt at Kaggle Digit Recognizer | https://www.kaggle.com/c/digit-recognizer/ | |
Basic approach w/ random trees results in 0.96486 accuracy | |
""" | |
import pandas as pd | |
import numpy as np | |
from numpy import savetxt | |
from sklearn.ensemble import RandomForestClassifier |
# written and discarded in favor of sqlalchemy methods - still a good example of how to dynamically create classes in Python | |
import glob | |
import sys | |
from sqlalchemy import Column, ForeignKey, Integer, String | |
from sqlalchemy.dialects.mysql import TIMESTAMP | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.orm import relationship | |
from sqlalchemy import create_engine | |
import pandas as pd |
<style> | |
html { | |
font-size: 62.5% !important; } | |
body { | |
font-size: 1.5em !important; /* currently ems cause chrome bug misinterpreting rems on body element */ | |
line-height: 1.6 !important; | |
font-weight: 400 !important; | |
font-family: "Raleway", "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif !important; | |
color: #222 !important; } |