A Ruby on Rails configuration for RSpec Capybara testing with a postgres database.
rails new capyspecpsql -d postgres -T
import socket | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
ip = socket.gethostbyname('www.google.com') | |
print("Google's IP is: {}".format(ip)) | |
# My hostname | |
me = socket.gethostname() | |
print("My hostname is: {}".format(me)) |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
html { | |
box-sizing: border-box; | |
} | |
*, *:before, *:after { | |
box-sizing: inherit; | |
} |
def bubble_sort(arr): | |
for i, val in enumerate(arr, len(arr): | |
for j, pal in enumerate(arr, len(arr[:-1]): | |
neighbor = arr[j + 1] | |
if pal > neighbor: | |
arr[j+1] = arr[j] # swap | |
arr[j] = neighbor # swap | |
return arr |
name = "john joe doe dole" | |
names = name.split() | |
my_list = names | |
for item in names: | |
print(item) | |
# Generators are iterators but you can only iterate over them once, because they do not store all values in memory and generate the values on the fly |
from pathlib import Path | |
def check_types(suffix, path): | |
assert isinstance(suffix, str), 'Suffix must be a string' | |
assert isinstance(path, str), 'Path must be a string' | |
def find_files(suffix: str, path: str, dirs=False) -> list: | |
check_types(suffix, path) |
import React, { Component } from 'react'; | |
import { createStore } from 'redux' | |
import { render } from 'react-dom'; | |
import './style.css'; | |
const defaultState = { checked: false } | |
const reducer = (state = defaultState, action) => { | |
switch(action.type) { | |
case 'TOGGLE': | |
return { ...state, checked: !state.checked }; |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { createStore } from 'redux'; | |
import { Provider } from 'react-redux' | |
import App from './components/App'; | |
import './style.css'; | |
const defaultState = { | |
checked: false, |
import React, { Component } from 'react'; | |
import { connect } from 'react-redux'; | |
const mapStateToProps = state => ({ | |
appName: state.appName | |
}) | |
class App extends Component { | |
render() { |