How can I achieve a self-referencing many-to-many relationship on the SQLAlchemy ORM back referencing to the same attribute?

Here’s the UNION approach I hinted at on the mailing list earlier today. from sqlalchemy import Integer, Table, Column, ForeignKey, \ create_engine, String, select from sqlalchemy.orm import Session, relationship from sqlalchemy.ext.declarative import declarative_base Base= declarative_base() friendship = Table( ‘friendships’, Base.metadata, Column(‘friend_a_id’, Integer, ForeignKey(‘users.id’), primary_key=True), Column(‘friend_b_id’, Integer, ForeignKey(‘users.id’), primary_key=True) ) class User(Base): __tablename__ = ‘users’ id … Read more

How to get path to the current vimscript being executed

” Relative path of script file: let s:path = expand(‘<sfile>’) ” Absolute path of script file: let s:path = expand(‘<sfile>:p’) ” Absolute path of script file with symbolic links resolved: let s:path = resolve(expand(‘<sfile>:p’)) ” Folder in which script resides: (not safe for symlinks) let s:path = expand(‘<sfile>:p:h’) ” If you’re using a symlink to … Read more

DLL unloading itself

As I understand it, it CAN be done and is MEANT to be done sometimes (for example in case of dll injection by CreateRemoteThread and other methods). So, FreeLibraryAndExitThread(hModule, 0) will do precisely that. On the other hand, calling FreeLibrary(hModule) will not do here – from MSDN: “If they were to call FreeLibrary and ExitThread … Read more

R self reference

Try package data.table and its := operator. It’s very fast and very short. DT[col1==something, col2:=col3+1] The first part col1==something is the subset. You can put anything here and use the column names as if they are variables; i.e., no need to use $. Then the second part col2:=col3+1 assigns the RHS to the LHS within … Read more