System hooks to insert raw sql.
References on django-developers google group:
* https://groups.google.com/forum/?fromgroups#!topic/django-developers/xN0aMzrmA1Y * https://groups.google.com/forum/?fromgroups#!topic/django-developers/KhsGj1b6rnU
class Api::RegistrationsController < Api::BaseController | |
respond_to :json | |
def create | |
user = User.new(params[:user]) | |
if user.save | |
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
return | |
else |
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
class ApiLogger < Grape::Middleware::Base | |
def before | |
Rails.logger.info "[api] Requested: #{request_log_data.to_json}\n" + | |
"[api] #{response_log_data[:description]} #{response_log_data[:source_file]}:#{response_log_data[:source_line]}" | |
end | |
private | |
def request_log_data |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
""" | |
Inserts C code directly into Python files, which can then be dynamically linked | |
in and called via ctypes. | |
""" | |
import atexit | |
import ctypes | |
import os | |
import shlex | |
import sys | |
import tempfile |
About my endeavor to automatically retrieve grammar of CPython
.pyc
-files bytecode from Python
's sources itself (success) and build parser on them (failed).
Most recent version of this article is always on GitHub
In 2011 as part of my diploma thesis I came up with an assembler language for .pyc
files and wrote a simple proof-of-concept assembler for it based on ANTLR3
parser generator. Back then I stumble upon the issue that CPython
bytecode is somewhat not stable and differs from version to version. I.e., as of Python
from 3.0
to 3.4
there are 28 incompatible bytecode versions (you may find all bytecode versions with their descriptions in Python34/Lib/importlib/_bootstrap.py
).
So, if we aim to devise an assembler or disassembler not for one bytecode version but for many, we face a routine of retrieving out these bytecode differences. This task strikingly
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[cyan]%}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}✘" | |
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}✔" | |
ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg[red]%}➦" | |
# ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[cyan]%} ✈" | |
# ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%} ✭" | |
# ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✗" | |
# ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%} ➦" |