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
@ulyssesv
ulyssesv / settings.py
Last active January 20, 2016 06:02
Using Honcho to load env vars from a .env file
# -*- coding: utf-8 -*-
import os
if os.environ.get('READ_ENV', False):
from honcho.command import Honcho
h = Honcho()
entries = h.read_env(type('obj', (object,), {'env': '.env', 'app_root': os.path.abspath(os.path.dirname(os.path.dirname(__file__)))})())
h.set_env(entries)
@ziadsawalha
ziadsawalha / config.py
Created December 19, 2013 19:38
Python module Generic to parse command-line, environment, keyring, and config file options dynamically
"""
Configuration Parser
Configurable parser that will parse config files, environment variables,
keyring, and command-line arguments.
Example test.ini file:
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active February 12, 2024 17:18
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@thomasfr
thomasfr / autossh.service
Last active May 9, 2024 16:59
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
@sebmarkbage
sebmarkbage / DeepImmutableMutation.js
Created May 30, 2014 23:35
Deep Immutable Mutation Using Spread Operator
// Mutative
company.users.push({ name: 'New User' });
return company;
// Immutable
return { ...company, users: [ ...company.users, { name: 'New User' } ] };
// Implicit identifier
@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.

@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}/>
@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>
@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)
@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