Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View DanLipsitt's full-sized avatar

Dan Lipsitt DanLipsitt

  • Tempo Automation
  • United States
View GitHub Profile
"""A set of helpers for reversing urls, similar to Django ``reverse``.
Usage:
.. code:: python
@router.get("/class/{class_id}")
async def get_class(request: Request, class_id: int = Path(...)):
student_route = get_route(request.app, "list_students")
class_students_url = URLFactory(student_route).get_path(class_id=class_id)
from keras.layers import Conv2D, BatchNormalization, Input, GlobalAveragePooling2D, Dense
from keras.models import Model
from keras.layers.advanced_activations import LeakyReLU
# function for building the discriminator layers
def build_discriminator(start_filters, spatial_dim, filter_size):
# function for building a CNN block for downsampling the image
def add_discriminator_block(x, filters, filter_size):
x = Conv2D(filters, filter_size, padding='same')(x)
###########
# Checks if the given cask needs to be upgraded.
#
#!/bin/bash
set -o pipefail
source /etc/profile
if [ $# -eq 0 ]; then
ARGS=($(brew cask list))
else
@butla
butla / wait_for_tcp_port.py
Last active December 8, 2022 19:52
Waiting for a TCP port to start accepting connections (Python >=3.6)
"""
MIT License
Copyright (c) 2017 Michał Bultrowicz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@gwillem
gwillem / ansible-bootstrap-ubuntu-16.04.yml
Created June 16, 2016 21:59
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# gwillem@gmail.com
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@egdelwonk
egdelwonk / Talk notes.md
Last active May 12, 2017 22:02
es2015 for python devs

Imports

Python:

import <module>
from <module> import defaultMember
from <module> import *
import <module> as <name>
@camjackson
camjackson / login-form.js
Last active November 17, 2019 09:18
Basic stateless React.js form
/*
This is obviously a very basic example. It takes props to render the inputs with their values, and
to render any error state. It also takes props to update the state, or submit the form.
*/
const LoginForm = props => (
<form onSubmit={props.onSubmit}>
<input type="text" name="username" onChange={props.onChangeUsername} value={props.username}/>
{ props.userNameError && <span class="error">{ props.usernameError }</span> }
<input type="password" name="password" onChange={props.onChangePassword} value={props.password}/>
@drmalex07
drmalex07 / README-setup-socket-activated-systemd-service.md
Last active December 26, 2023 05:13
An example inetd-like socket-activated service. #systemd #inetd #systemd.socket

README

This is an example of a socket-activated per-connection service (which is usually referred to as inetd-like service). A thorough explanation can be found at http://0pointer.de/blog/projects/inetd.html.

Define a socket unit

The key point here is to specify Accept=yes, which will make the socket accept connections (behaving like inetd) and pass only the resulting connection socket to the service handler.