This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ModelBase(object): | |
@declared_attr | |
def __tablename__(cls): | |
return cls.__name__.lower() | |
def get_fields(self, view): | |
"""Retrieves the fields list defined for the specified view. | |
""" | |
if view == 'list_view': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cd { | |
builtin cd "$@" | |
if [ -f "bin/activate" ] ; then | |
source bin/activate | |
fi | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Script to record and tag spotify tracks, by Lloyd Moore *) | |
tell application "Spotify" | |
set currentTrack to (current track) | |
set trackName to (name of currentTrack) | |
tell application "Audio Hijack Pro" | |
set theSession to my getSession() | |
end tell | |
repeat | |
if trackName is not equal to (name of currentTrack) then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_user_by_email(email): | |
user = g.db.query(User).filter_by(email=email).first() | |
return user | |
def check_auth(email, password): | |
"""This function is called to check if a username / | |
password combination is valid. | |
""" | |
user = get_user_by_email(email) | |
if not user: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"html/template" | |
"io/ioutil" | |
"net/http" | |
"regexp" | |
) | |
type Page struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import | |
from flask import Blueprint, g, request, Response | |
from administrate.utils.jsonify import jsonify | |
from administrate.utils.create_filter import create_filter | |
from administrate.models.mapping import get_model_from_map | |
from administrate.models.crm.contact import Contact | |
from administrate.models.system.company import Company |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git pull --rebase origin <yourbranch> | |
... some merge conflict. Let's say the file is called foo/lika.py | |
git co --theirs foo/lika.py | |
git add foo/lika.py | |
git rebase --continue | |
That's it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$a = array("a" => "one", "two", "three"); | |
$b = array("b" => "two", "three", "four"); | |
$c = array("c" => "three", "four", "five"); | |
$result = array_intersect($a, $b, $c); | |
print_r($result); | |
?> | |
Array | |
( | |
[1] => three |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File "/project/s/lib/python2.6/site-packages/sqlalchemy/orm/query.py", line 115, in __init__ | |
2 self._set_entities(entities) | |
3 File "/project/s/lib/python2.6/site-packages/sqlalchemy/orm/query.py", line 124, in _set_entities | |
4 self._set_entity_selectables(self._entities) | |
5 File "/project/s/lib/python2.6/site-packages/sqlalchemy/orm/query.py", line 157, in _set_entity_selectables | |
6 ent.setup_entity(*d[entity]) | |
7 File "/project/s/lib/python2.6/site-packages/sqlalchemy/orm/query.py", line 2861, in setup_entity | |
8 self._with_polymorphic = ext_info.with_polymorphic_mappers | |
9 File "/project/s/lib/python2.6/site-packages/sqlalchemy/util/langhelpers.py", line 612, in __get__ | |
10 obj.__dict__[self.__name__] = result = self.fget(obj) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pprint import pprint | |
from string import split, strip | |
def getMappings(x): | |
""" | |
add any tables which have a different name or different | |
column names in the new database. | |
Example: | |
the table 'foo' in the legacy database is called booyaka in |