Skip to content

Instantly share code, notes, and snippets.

Avatar

Dirk Uys dirkcuys

View GitHub Profile
@dirkcuys
dirkcuys / SAResources.md
Last active Apr 8, 2021 — forked from dalenunns/SAResources.md
List of SA Resources
View SAResources.md
@dirkcuys
dirkcuys / tasks.py
Created May 27, 2019
Sending logic
View tasks.py
# ...
def send_facilitator_survey(study_group):
""" send survey to all facilitators two days before their second to last meeting """
now = timezone.now()
end_of_window = now.replace(minute=0, second=0, microsecond=0)
start_of_window = end_of_window - datetime.timedelta(hours=1)
last_two_meetings = study_group.meeting_set.active().order_by('-meeting_date', '-meeting_time')[:2]
time_to_send = None
View docker-compose.yml
version: '3'
services:
wordpress:
image: wordpress
ports:
- 8081:80
environment:
- WORDPRESS_DB_USER=root
- WORDPRESS_DB_PASSWORD=password
- WORDPRESS_DB_HOST=mysql
View top100.js
function top100(){
var data = [
{x:0, y:0, r:310, label:'Daft Punk'},
{x:0, y:0, r:246, label:'Radiohead'},
{x:0, y:0, r:236, label:'The Beatles'},
{x:0, y:0, r:206, label:'Pink Floyd'},
{x:0, y:0, r:204, label:'Kanye West'},
{x:0, y:0, r:143, label:'Michael Jackson'},
{x:0, y:0, r:143, label:'Coldplay'},
{x:0, y:0, r:140, label:'Avicii'},
View create_user_graph.js
function create_user_graph(){
var data = [
{ label: 'CAIULQS142220300AC', links: [{index:6, weight:49.86258}]},
{ label: 'CAFQYWK142076ABC30', links: [{index:9, weight:37.25206},{index:38, weight:37.249912},{index:57, weight:37.082634},{index:58, weight:37.252235},{index:6, weight:37.083},{index:52, weight:37.250137}]},
{ label: 'CAMIKAH142077C0AFA', links: [{index:18, weight:200.77112},{index:39, weight:468.27472},{index:48, weight:197.95068},{index:79, weight:200.42961}]},
{ label: 'CAWZWYA141E76A0D47', links: [{index:44, weight:40.042473},{index:13, weight:39.989433},{index:63, weight:122.36953},{index:71, weight:40.04311},{index:27, weight:39.308483},{index:32, weight:39.990208},{index:46, weight:40.0435},{index:40, weight:122.37107},{index:42, weight:40.04289},{index:68, weight:40.249256},{index:75, weight:40.042088},{index:78, weight:122.36919}]},
{ label: 'CAXPHSA142072B84AF', links: [{index:59, weight:79.54525},{index:41, weight:80.098045}]},
{ label: 'CALRJFZ142077A5280', links: [{inde
View create_echonest_graph.py
def create_echonest_graph():
""" Build a dictionary with the distances between all taste profiles """
"""
{
'<profile_id>': {'name': '<profile_name>', 'suggest': {'<profile_id>': <score>, '<profile_id>': <score>, ...} },
'<profile_id>': {'name': '<profile_name>', 'suggest': {'<profile_id>': <score>, '<profile_id>': <score>, ...} },
...
'<profile_id>': {'name': '<profile_name>', 'suggest': {'<profile_id>': <score>, '<profile_id>': <score>, ...} },
}
"""
View create_taste_profiles.py
def create_taste_profiles(signups):
""" Create EchoNest taste profiles for every signup in a sequence """
config.ECHO_NEST_API_KEY = settings.ECHONEST_API_KEY
for signup_index, signup in enumerate(signups):
artists = list(set([ signup['questions'].get('artist{0}'.format(i)) for i in range(1,6) ]))
artists.sort()
print("Updating profile {0} of {1}".format(signup_index+1, len(signups)))
taste_profile = None
try:
@dirkcuys
dirkcuys / Faster query
Created Jan 7, 2013
Refactored SQL query
View Faster query
SELECT
`relationships_relationship`.`id`,
`relationships_relationship`.`source_id`,
`relationships_relationship`.`target_user_id`,
`relationships_relationship`.`target_project_id`,
`relationships_relationship`.`created_on`,
`relationships_relationship`.`deleted`
FROM
`relationships_relationship`
INNER JOIN