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
| var googleDirective = function(){ | |
| var d = {}; | |
| d.restrict = "E"; | |
| return d; | |
| }; | |
| angular.module("app", []) | |
| .directive("myGoogle", googleDirective); |
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
| <div ng-app="app"> | |
| <my-google>Chef Ramsay</my-google> | |
| </div> |
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
| - name: Set up the cron job | |
| cron: | |
| name: Purge Deleted Files | |
| state: present | |
| job: /var/app/myapp/purge_deletions.py | |
| user: www-data | |
| hour: "*/2" |
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
| - name: Set up the public user | |
| mysql_user: | |
| login_user: root | |
| login_password: "exampleRootPassword" | |
| name: public | |
| password: "examplePublicPassword" | |
| priv: "mydatabase.*: SELECT,INSERT" |
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
| # set up the connection to an account that has delete permissions. | |
| root_pw = parser["myapplication"]["root_password"] | |
| ct_string = "mysql+pymysql://root:{}@localhost/mydatabase".format(root_pw) | |
| eng = create_engine(ct_string) | |
| conn = eng.connect() | |
| # clear the learning resources | |
| query_string = """delete from resources where id in ( | |
| select resource_id from resource_deletions)""" | |
| conn.execute(query_string) |
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
| conn = eng.connect() | |
| user_id_parm = bindparam("user_id") | |
| query = select([resource_table])\ | |
| .where(and_(resource_table.c.user_id == user_id_parm, | |
| text("""resources.id not in | |
| (select resource_id from resource_deletions)"""))) | |
| result = conn.execute(query, user_id=user_id) |
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
| conn = eng.connect() | |
| resource_parm = bindparam("resource_id", type_=Integer) | |
| now = datetime.now() | |
| query = resource_deletion_table.insert()\ | |
| .values(resource_id=resource_parm, deletion_time=now) | |
| conn.execute(query, resource_id=resource_id) |
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
| import os | |
| from collections import Counter | |
| def pyfiles(): | |
| base_dir = "/home/username/blender-2.76b-linux-glibc211-x86_64/2.76/scripts" | |
| for dir_name, child_dirs, files in os.walk(base_dir): | |
| for file_name in files: | |
| if file_name.endswith(".py"): | |
| full_path = "{}{}{}".format(dir_name, os.path.sep, file_name) | |
| yield full_path |
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 collections import Counter | |
| counts = Counter(sorted(region_types)) | |
| for key, val in counts.items(): | |
| print("{}: {}".format(key, val)) |
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
| region_types = [] | |
| for pyfile in pyfiles(): | |
| for line in pick_lines(pyfile): | |
| _, region_type = line.split("=") | |
| region_type = region_type.replace("'", "") | |
| region_type = region_type.replace("\"", "") | |
| region_type = region_type.strip() | |
| region_types.append(region_type) |