Skip to content

Instantly share code, notes, and snippets.

View gutierri's full-sized avatar

Gutierri Barboza gutierri

View GitHub Profile
@attilaolah
attilaolah / batterymonitor.lua
Created July 18, 2013 00:00
Awesome WM battery monitor and CPU monitor widgets.
-- Hex converter, for RGB colors
function hex(inp)
return inp > 16 and string.format("%X", inp) or string.format("0%X", inp)
end
-- Battery monitor
mybattmon = widget({ type = "textbox", name = "mybattmon", align = "right" })
function battery_status ()
local output={} -- output buffer
local fd=io.popen("acpitool -b", "r") -- list present batteries
@magopian
magopian / fix_permissions.py
Created November 19, 2013 11:00
Django admin command to "fix permissions" (create them properly for proxy models). This is needed because of the following bug in Django (not fixed as of 1.6): https://code.djangoproject.com/ticket/11154
# -*- coding: utf-8 -*-
"""Add permissions for proxy model.
This is needed because of the bug https://code.djangoproject.com/ticket/11154
in Django (as of 1.6, it's not fixed).
When a permission is created for a proxy model, it actually creates if for it's
base model app_label (eg: for "article" instead of "about", for the About proxy
model).
@XVilka
XVilka / TrueColour.md
Last active April 27, 2025 10:17
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!

@justinklemm
justinklemm / Gruntfile.coffee
Created July 15, 2014 02:14
Grunt & Bower Configuration for WordPress Themes
module.exports = (grunt) ->
grunt.initConfig
# Copy Font Awesome files to /fonts directory
copy:
fonts:
files: [
expand: true
cwd: 'bower_components/font-awesome/fonts'
@skhaz
skhaz / main.cpp
Last active April 9, 2021 12:23
Steganography
#include <QtDebug>
#include <QImage>
#include <QString>
#include <QBitArray>
#include <QByteArray>
#include <QFile>
#include <QCommandLineParser>
namespace {
enum { headerSize = 32 };
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
@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`.
"""
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)
@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': [
@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)