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
{ | |
anytime: [ | |
"There are two words which are light on the tongue, heavy on the scale, and loved by the Most Merciful: SubhanAllahi wa bihamdi, SubhanAllahi al-azeem (Glorified is Allah and praised is He, Glorified is Allah the Most Great)." | |
], | |
morning: [ | |
"Good morning, handsome!", | |
], | |
afternoon: [ | |
"Hello, beauty!", | |
], |
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
upstream websocket { | |
server localhost:3000; | |
} | |
server { | |
listen 80; | |
server_name localhost; | |
access_log /var/log/nginx/websocket.access.log main; |
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
from motor_driver import * # import motor_driver library | |
# Drive Motor | |
motor = motor_driver(16,17) # M2A = 16, M2B = 17 | |
motor.controlSpeed(50) # move forward at speed 50 | |
utime.sleep(5) # sleep 5 second | |
motor.brake() # brake the motor |
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
function humanize(num){ | |
var ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', | |
'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', | |
'seventeen', 'eighteen', 'nineteen']; | |
var tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', | |
'ninety']; | |
var numString = num.toString(); | |
if (num < 0) throw new Error('Negative numbers are not supported.'); |
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
// This is a sample of what the event object that gets | |
// passed to your connect route could look like. | |
// I've chosen to use an authorizer that will pass | |
// the userId so that I can store the connectionId with the userId | |
// in my database | |
interface APIGatewayWebsocketEvent { | |
methodArn: string; | |
queryStringParameters: { | |
token: string; |
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 { Action } from 'redux'; | |
interface User { | |
name: string; | |
age: number; | |
} | |
export interface LoadingState { | |
users: boolean; | |
} |
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 { User, LoadUsersRequest, LoadUsersSuccess, LoadUsersError } from './types'; | |
export const loadUsersRequest = (): LoadUsersRequest => ({ | |
type: 'loadUsersRequest', | |
}); | |
export const loadUsersSuccess = (users: User[]): LoadUsersSuccess => ({ | |
type: 'loadUsersSuccess', | |
users, | |
}); |
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 { ThunkAction } from 'redux-thunk'; | |
import { ApplicationState, ApplicationAction } from './types'; | |
import { loadUsersRequest, loadUsersSuccess, loadUsersError } from './actions'; | |
import * as userService from '../services/userService'; | |
type Effect = ThunkAction<any, ApplicationState, any, ApplicationAction>; | |
export const loadUsers = (): Effect => (dispatch, getState) => { | |
dispatch(loadUsersRequest()); | |
// assume userService.loadUsers returns a Promise<User[]> |
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 produce from 'immer'; | |
import { ApplicationState, ApplicationAction } from './types'; | |
export const initialState: ApplicationState = { | |
loading: { | |
users: false, | |
}, | |
users: [], | |
} |
NewerOlder