Skip to content

Instantly share code, notes, and snippets.

⌨️
Coding

Ryan Castner audiolion

⌨️
Coding
Block or report user

Report or block audiolion

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@audiolion
audiolion / device-setup.js
Last active Jan 21, 2019
show code that is producing twilio client error
View device-setup.js
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'
View default-export-example.tsx
// App.tsx
export const App = () => (
<BrowserRouter>
<Route path="/users" component={UsersConnector} />
</BrowserRouter>
);
// UsersConnector.tsx
export const UsersConnector: React.SFC<RouteComponentProps> = (props) => (
<Query query={UsersList}>
View yolo.js
/**
*
* 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.
*
*/
View window-size.js
import React from "react";
let hasWindow = typeof window !== "undefined";
class WindowSize extends React.Component {
state = {
width: hasWindow && window.innerWidth,
height: hasWindow && window.innerHeight,
};
@audiolion
audiolion / sentry_error_handler.py
Created May 4, 2018 — forked from danigosa/sentry_error_handler.py
Sentry Logger Event Hook for Python API Star 0.5+ (tested on 0.5.10)
View sentry_error_handler.py
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 = {
@audiolion
audiolion / example.py
Last active Oct 12, 2017
pytest assert vs self.assertEqual
View example.py
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'
@audiolion
audiolion / TodosList.jsx
Created Jun 30, 2017
trouble a brewin' in some reactive waters, redux!
View TodosList.jsx
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,
};
View api.py
# 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
@audiolion
audiolion / loop.py
Created Oct 17, 2016
loop through items and perform an action at a specified count
View loop.py
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
View nodeImpurity.py
###
# Attribute Branching Impurity Calculator
# Zachary Friss
# CSCI 420
# Written for Python 3.4
###
from statistics import *
from math import *
You can’t perform that action at this time.