Skip to content

Instantly share code, notes, and snippets.

View mamigot's full-sized avatar

Miguel Amigot mamigot

View GitHub Profile
@mamigot
mamigot / openedx.py
Last active July 14, 2023 13:05
Calling an Open edX API
# Open edX APIs often require an access token that is obtained through the OAuth2 protocol. Here are the general steps you would take:
# Request an access token: The first step is to request an access token. For this, you would send a POST request to the /oauth2/access_token endpoint with your client ID and secret. Here’s an example of how to do it with requests in Python:
import requests
import json
url = "https://your-open-edx-instance.com/oauth2/access_token"
headers = {
"Content-Type": "application/json"
}
@mamigot
mamigot / cnn-example
Created December 2, 2022 22:58
CNN in Python that you could use to predict your final grade in a course based on the grades you have received on various assessments:
import tensorflow as tf
# Define the input data
X = np.array([
[10], # grade on first assessment
[20], # grade on second assessment
[30] # grade on third assessment
])
# Define the target variable
@mamigot
mamigot / rnn-example
Created December 2, 2022 22:57
RNN in Python that you could use to predict your final grade in a course based on the grades you have received on various assessments:
import tensorflow as tf
# Define the input data
X = np.array([
[10], # grade on first assessment
[20], # grade on second assessment
[30] # grade on third assessment
])
# Define the target variable
@mamigot
mamigot / linear-regression-example
Last active December 2, 2022 22:47
Linear regression function in Python that you could use to predict your final grade in a course based on the grades you have received on various assessments:
import numpy as np
def linear_regression(X, y):
# Add a column of ones to X to represent the bias term
X = np.concatenate([np.ones((X.shape[0], 1)), X], axis=1)
# Compute the transpose of X
X_t = np.transpose(X)
# Compute the dot product of X_t and X
@mamigot
mamigot / edx_version.sh
Created November 15, 2017 16:52
See which version of the Open edX platform you're running
root@openedx:/edx/app/edxapp/edx-platform$ git tag | grep "open-release" | tail -1
open-release/ginkgo.1rc1
@mamigot
mamigot / docker-compose.yml
Created October 22, 2017 16:20
Ghost + Nginx + Let's Encrypt + Docker Compose
version: '2'
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
#!/usr/bin/env bash
#
# Script for installing Ansible and the edX configuration repostory
# onto a host to enable running ansible to complete configuration.
# This script can be used by Docker, Packer or any other system
# for building images that requires having ansible available.
#
# Can be run as follows:
#
@mamigot
mamigot / ubuntu_virtualbox.sh
Last active July 27, 2016 14:17
Basic initial configuration of Ubuntu 12.04 on VirtualBox
# wget $URL_OF_THIS_RAW_SCRIPT -O - | sudo bash
#############################################################################################
# Basic initial configuration of Ubuntu 12.04 on VirtualBox
# (execute after installing the relevant ISO on the VM through VirtualBox: http://releases.ubuntu.com/12.04/)
#
#
# In order to access the VM from your host (e.g. OS X), forward the relevant ports on VirtualBox:
# Network -> Adapter 1 (NAT) -> Port Forwarding (http://stackoverflow.com/a/10532299/2708484)
#

Barrier

Barrier.h

/*
  Barrier.h
 */

#include <mutex>
#include <condition_variable>
#include <iostream>
#include <mutex>
#include <map>
using namespace std;
// Map file paths to their respective files' mutexes
map<string, shared_ptr<mutex>> fileMutexes = {};
mutex fileMutexesAccess;