Skip to content

Instantly share code, notes, and snippets.

View pcote's full-sized avatar
🏠
Working from home

Emma Cote pcote

🏠
Working from home
View GitHub Profile
var googleDirective = function(){
var d = {};
d.restrict = "E";
return d;
};
angular.module("app", [])
.directive("myGoogle", googleDirective);
<div ng-app="app">
<my-google>Chef Ramsay</my-google>
</div>
- 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"
- name: Set up the public user
mysql_user:
login_user: root
login_password: "exampleRootPassword"
name: public
password: "examplePublicPassword"
priv: "mydatabase.*: SELECT,INSERT"
# 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)
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)
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)
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
from collections import Counter
counts = Counter(sorted(region_types))
for key, val in counts.items():
print("{}: {}".format(key, val))
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)