Skip to content

Instantly share code, notes, and snippets.

Avatar

Petr Messner messa

View GitHub Profile
View .pythonrc.py
"""
Startup script for Python interactive mode
Add these two lines to .bashrc:
PYTHONSTARTUP="$HOME/.pythonrc.py"
export PYTHONSTARTUP
"""
import sys, os, readline, atexit
@LeZuse
LeZuse / detect.py
Created May 2, 2012
Flask browser detection
View detect.py
browser = request.user_agent.browser
version = request.user_agent.version and int(request.user_agent.version.split('.')[0])
platform = request.user_agent.platform
uas = request.user_agent.string
if browser and version:
if (browser == 'msie' and version < 9) \
or (browser == 'firefox' and version < 4) \
or (platform == 'android' and browser == 'safari' and version < 534) \
or (platform == 'iphone' and browser == 'safari' and version < 7000) \
@willurd
willurd / web-servers.md
Last active Oct 18, 2021
Big list of http static server one-liners
View web-servers.md

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@sloria
sloria / bobp-python.md
Last active Oct 19, 2021
A "Best of the Best Practices" (BOBP) guide to developing in Python.
View bobp-python.md

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@rxaviers
rxaviers / gist:7360908
Last active Oct 19, 2021
Complete list of github markdown emoji markup
View gist:7360908

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@messa
messa / asyncio_ssl_example.py
Created Jun 26, 2015
Python asyncio + SSL TCP client/server example
View asyncio_ssl_example.py
#!/usr/bin/env python3
import asyncio
import multiprocessing
import os
import ssl
from time import sleep
port = 9000
@bwbaugh
bwbaugh / logstash-guide.md
Last active Nov 26, 2020
Installing logstash server and client
View logstash-guide.md

Installing logstash

Server install

Install

Install the Java prerequisite:

@jimfb
jimfb / react-refs-must-have-owner.md
Last active Jul 13, 2019
addComponentAsRefTo Invariant Violation
View react-refs-must-have-owner.md

You are probably here because you got the following error messages:

addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's render method, or you have multiple copies of React loaded.

This usually means one of two things:

  • You are trying to add a ref to an element that is being created outside of a component's render() function.
  • You have multiple (conflicting) copies of React loaded (eg. due to a miss-configured NPM dependency)

Invalid Refs

@takeshixx
takeshixx / asyncio_ssl_example.py
Created May 12, 2016 — forked from messa/asyncio_ssl_example.py
Python asyncio + SSL TCP client/server example
View asyncio_ssl_example.py
#!/usr/bin/env python3
import asyncio
import multiprocessing
import os
import ssl
from time import sleep
port = 9000