Skip to content

Instantly share code, notes, and snippets.

View iuridiniz's full-sized avatar

Iuri Diniz iuridiniz

View GitHub Profile
@iuridiniz
iuridiniz / README
Last active December 25, 2018 02:10
helloworld in various languages
# README
@iuridiniz
iuridiniz / test_socketio.js
Last active December 13, 2020 23:42
test socketio
function loadScript(src, cb) {
var script = document.createElement('script');
script.async = true;
script.src = src;
script.onerror = function() {
cb(new Error("Failed to load" + src));
};
script.onload = function() {
@iuridiniz
iuridiniz / python_tzname.py
Created April 4, 2018 18:54
Get python timezone name
import ctypes
libc = ctypes.CDLL('libc.so.6')
tzname = (ctypes.c_char_p * 2).in_dll(libc, 'tzname')
for n in tzname: print(n)
@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()