Skip to content

Instantly share code, notes, and snippets.

View gutierri's full-sized avatar

Gutierri Barboza gutierri

View GitHub Profile
@felipeborges
felipeborges / google.py
Created June 15, 2017 14:22
Get Google API credentials from GNOME Online Accounts
import gi
gi.require_version('Goa', '1.0')
from gi.repository import Goa
def main(args):
client = Goa.Client.new_sync (None)
accounts = client.get_accounts ()
@mosquito
mosquito / README.md
Last active June 22, 2025 08:16
Add doker-compose as a systemd unit

Docker compose as a systemd unit

Create file /etc/systemd/system/[email protected]. SystemD calling binaries using an absolute path. In my case is prefixed by /usr/local/bin, you should use paths specific for your environment.

[Unit]
Description=%i service with docker compose
PartOf=docker.service
After=docker.service
@antirez
antirez / lmdb.tcl
Created April 28, 2017 15:40
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <[email protected]>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
@EdnaldoNeimeg
EdnaldoNeimeg / bootstrap4-editable.js
Last active March 25, 2021 08:54
Fix x-editable for Bootstrap 4 - Using Tether
/*! X-editable - v1.5.1
* In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
* http://github.com/vitalets/x-editable
* Copyright (c) 2013 Vitaliy Potapov; Licensed MIT */
/**
Form with single input element, two buttons and two states: normal/loading.
Applied as jQuery method to DIV tag (not to form tag!). This is because form can be in loading state when spinner shown.
Editableform is linked with one of input types, e.g. 'text', 'select' etc.
@class editableform
@harrisont
harrisont / example.py
Created February 25, 2017 22:03
Python asyncio exception, cancellation, and KeyboardInterrupt handling
import asyncio
import logging
import time
async def do_work(i):
print('start', i)
# Work
time.sleep(1)
@maurobaraldi
maurobaraldi / app.py
Created December 29, 2016 11:22
API rest para resultados da loteria
#!/usr/bin/env python
from random import sample
from flask import Flask, jsonify
app = Flask(__name__)
db = {
'lotofacil': {
'resultados': [
import sys
import os
from gi.repository import Gtk, Gdk, WebKit
class Browser(Gtk.Window):
def __init__(self, *args, **kwargs):
super(Browser, self).__init__(*args, **kwargs)
@harrisont
harrisont / as_completed_with_max_concurrent.py
Last active April 13, 2020 12:10
as_completed_with_max_concurrent: similar to asyncio.as_completed, but limits the concurrently running futures
import asyncio
import itertools
def as_completed_with_max_concurrent(futures, max_concurrent, loop=None, timeout=None):
"""Tweaked version of `asyncio.as_completed` with the addition of the `max_concurrent` param.
The main change is to only queue (`_queue_future`) the first `max_concurrent` futures initially.
The rest will be queued in `_on_completion`.
"""
Python 3.4.3 (default, Mar 26 2015, 22:03:40)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> class Pessoa:
... pass
...
>>> type(Pessoa)
<class 'type'>
>>> class Pessoa2(object):
... pass