Skip to content

Instantly share code, notes, and snippets.

View a0x's full-sized avatar
:shipit:
happy hacking

AmadeusQ a0x

:shipit:
happy hacking
View GitHub Profile
@jwo
jwo / registrations_controller.rb
Created September 30, 2011 23:11
API JSON authentication with Devise
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
@niwinz
niwinz / gist:3198204
Created July 29, 2012 12:02
Django model hooks

Django Model Hooks (prototype)

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
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 22, 2024 23:19
Useful PostgreSQL Queries and Commands
-- 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%'
@yesmeck
yesmeck / git-flow.md
Created December 9, 2012 14:53
Git 开发流程

Git 协作流程

master 分支

master 永远处于稳定状态,这个分支代码可以随时用来部署。不允许在该分支直接提交代码。

develop 分支

开发分支,包含了项目最新的功能和代码,所有开发都在 develop 上进行。一般情况下小的修改直接在这个分支上提交代码。

@dblock
dblock / api_logger.rb
Created December 10, 2012 01:43
API logger with Grape under Rails
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
@staltz
staltz / introrx.md
Last active July 22, 2024 09:31
The introduction to Reactive Programming you've been missing
@adamnew123456
adamnew123456 / pyc.py
Last active June 10, 2024 07:12
Using Inline C Code In Python Programs
"""
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
@ilyaigpetrov
ilyaigpetrov / retrieve-.pyc-grammar-from-marshal.c.md
Last active January 26, 2020 14:58
Retrieve .pyc Grammar from Python's Sources | by https://git.io/ilyaigpetrov

Retrieve .pyc Grammar from Python's Sources

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

The problem story

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

@schminitz
schminitz / schminitz.zsh-theme
Created September 2, 2015 13:55
Another oh-my-zsh theme with background vim recognize
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]%} ➦"
@evantoli
evantoli / GitConfigHttpProxy.md
Last active July 20, 2024 03:29
Configure Git to use a proxy

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like: