Skip to content

Instantly share code, notes, and snippets.

@binarycrayon
binarycrayon / protobuf-ubuntu-20-04.md
Created June 6, 2024 18:03 — forked from jambonn/protobuf-ubuntu-20-04.md
How to Install Protobuf on Ubuntu 20.04
1. sudo apt-get install autoconf automake libtool curl make g++ unzip -y
2. Download the appropriate release here:
https://github.com/protocolbuffers/protobuf/releases/tag/v3.5.1 <protobuf-all-3.5.1.tar.gz
>
3. Unzip the folder
4. Enter the folder and run ./autogen.sh && ./configure && make
5. Then run these other commands. They should run without issues:
$ make check
$ sudo make install
@binarycrayon
binarycrayon / policy.md
Created February 14, 2018 01:32 — forked from pgolding/policy.md
s3 bucket policy for presigned URLs generated by serverless lambda functions

AWS Presigned URLs

Presigned URLs are useful for fine-grained access control to resources on s3.

For example, if storing larger text blocks than DynamoDB might allow with its 400KB size limits s3 is a useful option.

Ignoring various ACL methods and using presigned URLs, it's possible to create lambda functions that can generate the required upload and download URLs.

Using the default IAM roles and lambda proxy configuration of serverless, lambdas are assigned an IAM role for the application (so that a logical group of functions can share resources - e.g. for a CRUD REST API). Each function then assumes the IAM role via its own function name.

@binarycrayon
binarycrayon / curl.md
Created January 26, 2018 21:55 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

emacs --daemon to run in the background. emacsclient.emacs24 <filename/dirname> to open in terminal

NOTE: "M-m and SPC can be used interchangeably".

  • Undo - C-/
  • Redo - C-?
  • Change case: 1. Camel Case : M-c 2. Upper Case : M-u
  1. Lower Case : M-l
Provider Singleton Instantiable Configurable
Constant Yes No No
Value Yes No No
Service Yes No No
Factory Yes Yes No
Decorator Yes No? No
Provider Yes Yes Yes

Constant

@binarycrayon
binarycrayon / pool.py
Last active August 29, 2015 14:12 — forked from fordguo/pool.py
#-*- coding:utf-8 -*-
import Queue
from contextlib import contextmanager
class ObjectPool(object):
"""A simple object pool with thread safe"""
def __init__(self,objectFn,*args,**kwargs):
super(ObjectPool, self).__init__()
self.objectFn = objectFn
self.objectCls = None
import threading
# Based on tornado.ioloop.IOLoop.instance() approach.
# See https://github.com/facebook/tornado
class SingletonMixin(object):
__singleton_lock = threading.Lock()
__singleton_instance = None
@classmethod