Skip to content

Instantly share code, notes, and snippets.

aleiphoenix

Block or report user

Report or block aleiphoenix

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@aleiphoenix
aleiphoenix / ipconv.go
Created Apr 3, 2019
golang ipv4 string to uint32.
View ipconv.go
package ipconv
import (
"fmt"
"strconv"
"strings"
)
func Conv(ip string) (uint32, error) {
segs := strings.Split(ip, ".")
@aleiphoenix
aleiphoenix / local.py
Created Jun 29, 2016
run command in child process without
View local.py
# -*- coding: utf-8 -*-
import errno
import os
import fcntl
# !! License GPLv2 !!
# only work on Linux, MacOSX, may work on Windows, no tested.
# some syscall/flags not available on other OS(like Solaris), so not supported
@aleiphoenix
aleiphoenix / ddns_updater.py
Last active Aug 29, 2015
Update Dynamic DNS record when it's really needed.
View ddns_updater.py
#!/usr/bin/python2
# -*- coding: utf-8 -*-
import logging
import os
import re
import subprocess
import sys
import syslog
import dns.resolver
@aleiphoenix
aleiphoenix / drm-call-stack.md
Created May 30, 2015
Linux kernel, DRM and VGA_SWITCHEROO call stack
View drm-call-stack.md
radeon module
  __init radeon_init()    (radeon_device.c)
	=> radeon_kms_pci_driver.probe = radeon_pci_probe
    => if (radeon_modeset == 1)
			"radeon kernel modesetting enabled.\n"
			driver = &kms_driver
			pdriver = &radeon_kms_pci_driver
			radeon_register_atpx_handler()    (radeon_atpx_handler.c)
	=> drm_pci_init()    (drm_pci.c)
@aleiphoenix
aleiphoenix / app.py
Created Apr 24, 2015
Python garbage collection statistics...
View app.py
# -*- coding: utf-8 -*-
import gc
s = {}
for i in gc.get_objects():
_ = str(type(i))
if _ in s:
s[_] += 1
else:
@aleiphoenix
aleiphoenix / app.py
Created Apr 22, 2015
Native usage of Jinja2
View app.py
# -*- coding: utf-8 -*-
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates'))
t = env.get_template('test.jinja2')
print(t.render(name='world'))
@aleiphoenix
aleiphoenix / app.py
Created Apr 2, 2015
native SQLAlchemy ORM usage...
View app.py
# -*- coding: utf-8 -*-
import json
import logging
from sqlalchemy import create_engine
from sqlalchemy import types
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.sql.schema import MetaData, Table
from sqlalchemy import Column, Integer
@aleiphoenix
aleiphoenix / db.py
Created Apr 1, 2015
SQLAlchemy: change table schema, on the fly
View db.py
# -*- coding: utf-8; -*-
from tigger import app
app.ready()
from tigger import db
def decorate_timestamps():
from datetime import datetime
from sqlalchemy import TIMESTAMP, Column, text
@aleiphoenix
aleiphoenix / model.py.tpl
Created Mar 26, 2015
reflect and generate models code from database schema :)
View model.py.tpl
# -*- coding: utf-8 -*-
class {{ table.name }}:
__tablename__ = '{{ table.name }}'
{% for col in table.columns %}
{{ col.name }} = Column({{col.type}}{% if col.primary_key %}, primary_key=True{% endif%}{% if not col.nullable %}, nullable=False{% endif %})
{% endfor -%}
@aleiphoenix
aleiphoenix / git-shell.py
Created Mar 2, 2015
a simple script to simplify git hosting for personal usage.
View git-shell.py
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import re
import shlex
import sys
import subprocess
You can’t perform that action at this time.