Skip to content

Instantly share code, notes, and snippets.

View iuridiniz's full-sized avatar

Iuri Diniz iuridiniz

View GitHub Profile
@iuridiniz
iuridiniz / detect_gevent_eventlet.py
Created February 23, 2018 18:18
detect gevent/eventlet -- copied from kombu/kombu/syn.py
"""
kombu.syn
=========
:copyright: (c) 2009 - 2012 by Ask Solem.
:license: BSD, see LICENSE for more details.
"""
from __future__ import absolute_import
#! /usr/bin/perl
use strict;
use warnings;
my @fgColors = (
'default', 'bold', 'black', 'red', 'blue', 'yellow', 'green',
'majenta', 'cyan', 'white', 'bold black', 'bold red', 'bold blue',
'bold yellow', 'bold green', 'bold majenta', 'bold cyan', 'bold white');
@iuridiniz
iuridiniz / NOTES.txt
Last active July 16, 2018 20:52
mysql-mirror start script debian
# install initd script
update-rc.d mysql-mirror defaults
# create user for mirror (avoid mirror use main server and vice-versa)
useradd -s /usr/sbin/nologin -r -M mysql-mirror
# create the run directory
install -m 755 -o mysql-mirror -g root -d /var/run/mysqld-mirror
# create the log directory
@iuridiniz
iuridiniz / runcs.sh
Created May 29, 2017 14:03
run cs through wine (installed by warzone installed)
#!/bin/bash
# http://cswarzone.com/
# TODO: change the paths
cd /home/iuri/.local/share/wineprefixes/cs1.6/drive_c/Program\ Files\ \(x86\)/Counter-Strike/
WINEPREFIX=/home/iuri/.local/share/wineprefixes/cs1.6/ exec \
wine ./hl.exe \
-steam \
-game cstrike \
/************************************************************/
/* DAR 10 para todo professor/aluno */
var NOTA=10;
var selects = document.querySelectorAll("select[name^=p_]");
for (var i=0; i < selects.length; i++) {
var s = selects[i];
s.value = NOTA;
}
/* DAR 7 para todo professor/aluno */
def getattrfull(path):
"""
Obtem um atributo (objeto) de um caminho separado por '.', simulando um 'from xyz import y'
Exemplo para simular um 'from os import name as sistema':
>>> sistema = getattrfull('os.name')
>>> sistema
'posix'
Funciona para funcoes/classes/etc:
from sqlalchemy import create_engine, Column, types
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.sql import functions, expression, func
from sqlalchemy.ext.compiler import compiles
from datetime import datetime
Base = declarative_base()
var page = require('webpage').create();
page.viewportSize = { width: 1280, height: 768};
page.open('http://github.com/', function() {
page.render('github.png');
phantom.exit();
});
"use strict";
var page = require('webpage').create(),
system = require('system'),
address, output, size, pageWidth, pageHeight;
if (system.args.length < 3 || system.args.length > 5) {
console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]');
console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"');
console.log(' image (png/jpg output) examples: "1920px" entire page, window width 1920px');
console.log(' "800px*600px" window, clipped to 800x600');
from __future__ import print_function
import sys
import inspect
def func(a, b, c, *args, **kwargs):
frame = inspect.currentframe()
args_names, _, _, locals_ = inspect.getargvalues(frame)
args = [locals_[i] for i in args_names]
kwargs = dict(zip(args_names, args))
print ("kwargs: %r" %kwargs)