Skip to content

Instantly share code, notes, and snippets.

View khalib's full-sized avatar

Caleb Whang khalib

  • San Francisco Giants
  • San Francisco, CA
View GitHub Profile
import sys
from redis import StrictRedis
def pub():
player_code = sys.argv[1]
r = StrictRedis(host='localhost', port=6379, db=0)
p = r.pubsub()
<!-- Example of blocking the link -->
<a href="#">This link should be visible</a><br />
<?php if (!IPAuth::is_whitelisted()): ?>
<a href="#">This link should be hidden</a><br />
<?php endif ?>
<html>
<head>
<script src="https://dev.graphite.org/sites/graphite.org/libraries/csm/api-js/api.js?o85slp"></script>
<script>
var options = {
clientId: 'xxxxxxxxxxxxxxxxxxxxxx',
appId: 'xxxxxxxxxxxxxxxxxxxxxx',
host: 'http://localhost:3000'
};
class Node(object):
def __init__(self, value, dependencies):
self.value = value
self.dependencies = dependencies
def output_pattern(graph_root):
stack = [graph_root]
output = []
while len(stack):
import unittest
# Let's assume that this is mocking output from a microservice. The mock
# also maps each value to whether or not it is a pangram so that we can
# use it as a fixture for testing against.
MOCK_SOURCES = {
'The quick brown fox jumps.': False,
'Bright vixens jump; dozy fowl quack.': True,
'this is not a pangram': False,
@khalib
khalib / api_users.php
Last active April 26, 2016 22:47
Get users using the API driver
<?php
function get_users() {
// API object is globally set.
global $api;
// Request #1: returns request object with query defaults (limit: 15, page: 1, fields: <all>, sort: none).
$users = $api
->users()
->get();
@khalib
khalib / import.py
Last active April 22, 2016 07:00
Python script that imports JSON game data from the MLB Gameday API to a MS SQL database.
"""
JSON data importer to a MS SQL database.
NOTE: This code has not been tested and is for the sole purpose of showing example code
for a simple data import workflow using a non-optimized design without error handling.
"""
import json
import urllib
from os import getenv
@khalib
khalib / release-v6.3.sh
Created March 30, 2016 02:15
Release v6.3 Feature List after running reverts
Name Feature Status Version State
BEF Test Content bef_test_content Disabled 7.x-3.2
CSM Education csm_education_feature Enabled 7.x-5.0
CSM Field Bases csm_field_bases_feature Enabled 7.x-4.3
CSM Learning Ratings csm_learning_ratings_feature Enabled 7.x-6.3
CSM Migration Feature csm_migration_feature Enabled 7.x-3.8
CSM Schools csm_schools_feature Enabled 7.x-5.3
CSM Taxonomies Feature csm_taxonomies_feature Enabled 7.x-5.0
Date Migration Example date_migrate_example Disabled 7.x-2.9
Features Extra test feature features_extra_test Disabled
@khalib
khalib / qa-v6.3-rc10.sh
Created March 29, 2016 03:45
Dry Run Features List: qa-v6.3-rc10
Name Feature Status Version State
BEF Test Content bef_test_content Disabled 7.x-3.2
CSM Education csm_education_feature Enabled 7.x-5.0
CSM Field Bases csm_field_bases_feature Enabled 7.x-4.3
CSM Learning Ratings csm_learning_ratings_feature Enabled 7.x-6.3
CSM Migration Feature csm_migration_feature Enabled 7.x-3.8
CSM Schools csm_schools_feature Enabled 7.x-5.3
CSM Taxonomies Feature csm_taxonomies_feature Enabled 7.x-5.0
Date Migration Example date_migrate_example Disabled 7.x-2.9
Features Extra test feature features_extra_test Disabled
# Save incoming data.
user = User();
user.id = <id>
user.first_name = <firstName>
user.last_name = <lastName>
db.users.save(user)
# Output API data - get a list of users.
output = User.find({}, { limit: 15 })