Skip to content

Instantly share code, notes, and snippets.

View adriaanbd's full-sized avatar
💭
I may be slow to respond.

Adriaan Beiertz adriaanbd

💭
I may be slow to respond.
View GitHub Profile
@adriaanbd
adriaanbd / main.py
Created January 7, 2019 00:37
sockets created by adriaanbd - https://repl.it/@adriaanbd/sockets
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
@adriaanbd
adriaanbd / generators.py
Last active August 12, 2019 04:28
generators created by adriaanbd - https://repl.it/@adriaanbd/generators
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
@adriaanbd
adriaanbd / ror-cap-spec.md
Last active August 14, 2019 00:18
RAILS RSPEC CAPYBARA PSQL CONFIG ROR

RSPEC CAPYBARA PSQL ROR CONFIG

A Ruby on Rails configuration for RSpec Capybara testing with a postgres database.

Create app

Postgres, and skip test files:

rails new capyspecpsql -d postgres -T
@adriaanbd
adriaanbd / find_files.py
Created December 20, 2019 16:52
Find all files in a directory
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() {