Skip to content

Instantly share code, notes, and snippets.

View clintonb's full-sized avatar

Clinton Blackburn clintonb

View GitHub Profile
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
{
"settings": {
"index": {
"number_of_shards": 10,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"default": {
"type": "standard",
"tokenizer": "standard",
[2013-10-10 22:49:44,506][INFO ][request_json ] {"time":"2013-10-10T22:49:44.396Z","starttime":"2013-10-10T22:49:26.791Z","localaddr":"127.0.0.1","localport":9200,"remoteaddr":"127.0.0.1","remoteport":53360,"scheme":"http","method":"DELETE","path":"/reliant_268_capistrano","querystr":"-","code":200,"status":"OK","size":31,"duration":17605,"year":"2013","month":"10","day":"10","hour":"22","minute":"49","dow":"Thu","cluster":"data_search_dev"}
[2013-10-10 22:51:39,548][INFO ][request ] [dev-search] POST /reliant_268_capistrano/_import target=%2Ftmp%2Felasticsearch_deployment%2Freliant_268&timeout=1m 200 OK 11 36
[2013-10-10 22:51:39,549][INFO ][request_json ] {"time":"2013-10-10T22:51:39.548Z","starttime":"2013-10-10T22:51:39.512Z","localaddr":"127.0.0.1","localport":9200,"remoteaddr":"127.0.0.1","remoteport":53371,"scheme":"http","method":"POST","path":"/reliant_268_capistrano/_import","querystr":"target=%2Ftmp%2Felasticsearch_deployment%2Freliant_268&timeout=1m","code"
@clintonb
clintonb / etc-salt-cloud
Created November 5, 2013 05:16
Example salt-cloud config
# Set Salt master
minion:
master: eng-salt-master.example.com
providers:
ec2:
provider: ec2
ssh_username: ec2-user
ssh_interface: private_ips
@clintonb
clintonb / 0_reuse_code.js
Created February 2, 2014 04:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@clintonb
clintonb / courses.json
Created June 19, 2014 18:17
API HAL Response
// GET /api/edx.core/courses/edX+Open_DemoX+edx_demo_course
{
"course_id": "edX+Open_DemoX+edx_demo_course",
"name": "edX Demonstration Course",
"_links": {
"self": { "href": "/api/edx.core/courses/edX+Open_DemoX+edx_demo_course" },
"curies": [
{ "name": "edx.analytics", "href": "https://analytics-api.edx.org/docs/rels/{rel}", "templated": true },
{ "name": "edx.content", "href": "https://api.edx.org/api/edx.content/docs/rels/{rel}", "templated": true },
{ "name": "edx.videos", "href": "https://api.edx.org/api/edx.video/docs/rels/{rel}", "templated": true }
@clintonb
clintonb / backends.py
Last active May 2, 2022 16:26
python-social-auth OpenID Connect Backend
"""
This file contains Django authentication backends. For more information visit
https://docs.djangoproject.com/en/dev/topics/auth/customizing/.
"""
from calendar import timegm
from datetime import datetime
from django.conf import settings
import jwt
from social.backends.oauth import BaseOAuth2
@clintonb
clintonb / gist:0f022e148c718c44d87d
Last active August 29, 2015 14:05
Proposed Design for Permissions
"""
Workflow:
1. User authenticates and OIDC provider returns permissions as comma-delimited list of globs.
2. When user access a course page, call has_access() to verify permissions.
If no permissions, view should raise a 403 error. This can be accomplished with a mixin added to our existing views.
"""
# models.py
class UserCoursePermissons(models.Model):
user = models.ForeignKey(User, primary_key=True) # Unsure if foreign key can also be primary key
@clintonb
clintonb / print_course_ids.py
Created February 26, 2015 15:41
Script to print all course IDs and the instance type of the course ID
# Get the courses from modulestore
from xmodule.modulestore.django import modulestore
courses = modulestore().get_courses()
# Loop through the ids and print the IDs and types
for course in courses:
print "{}, {}".format(course.id, type(course.id))
@clintonb
clintonb / cs_credit.py
Created April 11, 2015 12:39
Issue credit via CyberSource SOAP API
"""
This is a basic script to issue a credit via the CyberSource API.
Requirements:
suds (https://fedorahosted.org/suds/) [Install via pip]
References
* http://www.cybersource.com/developers/integration_methods/simple_order_and_soap_toolkit_api/soap_api/SOAP_toolkits.pdf
* http://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_SO_API/Credit_Cards_SO_API.pdf
* http://pydoc.net/Python/merchant-gateways/0.0.1/merchant_gateways.billing.gateways.cybersource/