Skip to content

Instantly share code, notes, and snippets.

@ostearn
ostearn / edit.php
Created May 25, 2018 09:23
Way to stop the anoying moodle login -> redirect to edit profile page (in user/edit.php)
require_once('../config.php');
require_once($CFG->libdir.'/gdlib.php');
require_once($CFG->dirroot.'/user/edit_form.php');
require_once($CFG->dirroot.'/user/editlib.php');
require_once($CFG->dirroot.'/user/profile/lib.php');
require_once($CFG->dirroot.'/user/lib.php');
$referer = get_local_referer(false);
if($referer == $CFG->httpswwwroot . '/login/index.php'){
redirect(new moodle_url($CFG->httpswwwroot . '/'));
function dotheenrols(){
global $OUTPUT, $USER, $DB;
$all_users = $DB->get_records_sql('SELECT * FROM mdl_user WHERE deleted = 0');
foreach ($all_users as $r_user){
//set all user table variables
if($r_user->id){$user_id = $r_user->id;}
if($user_id >27){
if ($record = $DB->get_record('badge_issued', array('badgeid' => 3, 'userid' => $user_id))) {
//they have the badge
@ostearn
ostearn / gist:3482c1cdea015f475945f632f364b7cc
Created August 29, 2017 22:46
Moodle login/index.php modification (redirect to last enrolled course)
//this should be added after $SESSION->wantsurl = null; (there are roughly 4 occurances, consider each individually)
if($student_course_arry = enrol_get_users_courses($USER->id, true, Null, 'visible DESC,sortorder DESC'))
{
foreach($student_course_arry as $value)
{
$SESSION->wantsurl = $CFG->httpswwwroot . '/course/view.php?id=' . $value->id;
}
$all_comp_courses = $DB->get_records_sql('SELECT * FROM {course_completion_crit_compl} WHERE userid = ?', array($USER->id));
$root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/';
foreach ($all_comp_courses as $comp_array) {
//$this->content->text .= "Course: ".$comp_array -> course;
$this->content->text .= '<script>
var coursetile = $(\'a[href$="'.$root.'course/view.php?id='.$comp_array -> course.'"]\').siblings(".panel-body").find(".cimbox").addClass("course_complete");
</script>';
// $this->content->items[] .= "<script>$(".coursebox-content").css("color", "red");</script>"
}
$("#my-awesome-dropzone").dropzone({
url: "upload-files.php",
maxFilesize: 2,
acceptedFiles: ".txt",
sending: function (file, xhr, formData) {
var sider = $("#side").val();
var deckName = $("#deckname").val();
formData.append("filename", deckName);
formData.append("side", sider);
},
(function() {
var data = String(window.location);
var isebay = data.indexOf("ebay");
var isquery = data.indexOf("?");
var ipg = data.indexOf("&_ipg=200");
if(isebay != -1 & isquery != -1 & ipg != -1){
$('.prRange').parents('.lvresult').hide();
console.log('All those annoying variable listings have been removed.');
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'jquery/jquery.min.js'
});
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
$('.prRange').parents('.lvresult').hide();
@ostearn
ostearn / manifest.json
Created May 6, 2017 17:28
Ebay Variations Go Away!
{
"name": "Ebay Variations Go Away!",
"version": "0.1",
"manifest_version": 2,
"description": "This extension is designed to completely rid ebay search results of those annoying variations listings which are commonly abused and destroy your ability to find the cheapest item.",
"homepage_url": "http://oliverstearn.com/projects?project=ebay_extension",
"permissions": [
"https://*/*",
"http://*/*",
"tabs"
<!DOCTYPE html>
<html>
<head>
<title>Advent of Code Day 1</title>
<script>
var input = "L2, L3, L3, L4, R1, R2, L3, R3, R3, L1, L3, R2, R3, L3, R4, R3, R3, L1, L4, R4, L2, R5, R1, L5, R1, R3, L5, R2, L2, R2, R1, L1, L3, L3, R4, R5, R4, L1, L189, L2, R2, L5, R5, R45, L3, R4, R77, L1, R1, R194, R2, L5, L3, L2, L1, R5, L3, L3, L5, L5, L5, R2, L1, L2, L3, R2, R5, R4, L2, R3, R5, L2, L2, R3, L3, L2, L1, L3, R5, R4, R3, R2, L1, R2, L5, R4, L5, L4, R4, L2, R5, L3, L2, R4, L1, L2, R2, R3, L2, L5, R1, R1, R3, R4, R1, R2, R4, R5, L3, L5, L3, L3, R5, R4, R1, L3, R1, L3, R3, R3, R3, L1, R3, R4, L5, L3, L1, L5, L4, R4, R1, L4, R3, R3, R5, R4, R3, R3, L1, L2, R1, L4, L4, L3, L4, L3, L5, R2, R4, L2";
var orientation = "N";
var coordinates= new Array();