This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# Attribute Branching Impurity Calculator | |
# Zachary Friss | |
# CSCI 420 | |
# Written for Python 3.4 | |
### | |
from statistics import * | |
from math import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
divisor = 100 | |
company_names = ['ALP','FORRESTER','GE Aero', ... ] | |
for index, company_name in enumerate(company_names): | |
if index % divisor == 0 and index != 0: | |
# perform action on each 100 count | |
# perform normal actions outside of tallying 100 if applicable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# refactored code | |
# -*- coding: utf-8 -*- | |
"""API Endpoints for the Calendar | |
Endpoints designed to be called with AJAX requests and retrieve the events | |
that should populate the webpage's calendar. | |
""" | |
from django.utils.html import strip_tags | |
from django.http import HttpResponse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { connect } from 'react-redux'; | |
export class TodosList extends Component { | |
static propTypes = { | |
todos: PropTypes.arrayOf(todoPropTypes).isRequired, | |
isLoading: PropTypes.bool.isRequired, | |
hasErrored: PropTypes.bool, | |
dispatch: PropTypes.func.isRequired, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestSomething(TestCase): | |
def test_something(self): | |
assert something['message'] == 'Asserting that a very long message statement is as expected in this test case here, the issue is that its all on one line with no easy way to conform to PEP-8 besides adding "\" to continue the one line statement in python.' | |
self.assertEqual( | |
something['message'], | |
('Asserting that a very long message statement is as expected' | |
' in this test case here, the issue is that its all on one line' | |
' with no easy way to conform to PEP-8 besides adding "\" to' | |
' continue the one line statement in python.' | |
' With assertEqual and the function structure we can easily' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from os import environ | |
import logging | |
from apistar import http | |
from raven import Client | |
from apistar import App | |
from apistar.test import TestClient | |
from apistar import Route | |
settings = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
let hasWindow = typeof window !== "undefined"; | |
class WindowSize extends React.Component { | |
state = { | |
width: hasWindow && window.innerWidth, | |
height: hasWindow && window.innerHeight, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* A very simple refactoring that eliminates the need for a comment "This is the first attempt". | |
* | |
* I am not going to go into the details of why code is better than comments, books like | |
* The Pragmatic Programmer and Fowler's Refactoring provide well-reasoned arguments as to why | |
* this is the case. | |
* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// App.tsx | |
export const App = () => ( | |
<BrowserRouter> | |
<Route path="/users" component={UsersConnector} /> | |
</BrowserRouter> | |
); | |
// UsersConnector.tsx | |
export const UsersConnector: React.SFC<RouteComponentProps> = (props) => ( | |
<Query query={UsersList}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
state = { | |
device: new Twilio.Device(); | |
}; | |
state.device = state.device.setup(token, { allowIncomingWhileBusy: true }); | |
resumeTwilioDevice = async () => { | |
if (state.device.audio && | |
state.device.audio._audioContext && | |
state.device.audio._audioContext.state === 'suspended' |
OlderNewer