Skip to content

Instantly share code, notes, and snippets.

@mkolb
mkolb / var_dump-log.php
Last active January 3, 2023 14:53
var_dump into error log
<?php
ob_start();
var_dump($this);
error_log(ob_get_clean());
?>
@mkolb
mkolb / gist:2701188
Created May 15, 2012 11:56
feature/defect workflow
<mkolb> so here's what i want to do for workflow re branches [07:48]
<mkolb> e.g.
<mkolb> Rob gets the idea that he wants to have a chicken separator included
in engage. [07:49]
<hernan43> mechanical or electronic?
@mkolb
mkolb / password-salt.el
Created May 21, 2012 16:11
A function for generating a password salt in moodle, useful for first-time creation of config.php
(defun insert-password-salt ()
"Insert a string of length 31 suitable for a new password salt in moodle."
(interactive)
(let ((mycharset "1234567890abcdefghijklmnopqrstyvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()"))
(dotimes (i 31)
(insert (elt mycharset (random (length mycharset)))))))
@mkolb
mkolb / gist:2845056
Created May 31, 2012 17:53
emacs stuff i can't remember
M-x diff-buffer-with-file
@mkolb
mkolb / gist:2910308
Created June 11, 2012 14:24
git stuff I can't remember
# clean up your own junk
git remote prune public
# create a branch based of off a commit
git branch branchname <sha1-of-commit>
# wack a remote branch
git push origin :the_remote_branch
# wack a remote tag
@mkolb
mkolb / gist:2926284
Created June 13, 2012 20:24
pop up in YUI
<script type="text/javascript">// <![CDATA[
YUI().use('node', function(Y) {
function init() {
// The DOM is ready, lets say hello!
say_hello();
}
Y.on("domready", init);
});
@mkolb
mkolb / gist:2960777
Created June 20, 2012 16:26
queries to fix engage 1.3 migration
drop table mdl_deltak_terms, mdl_deltak_programs, mdl_deltak_master_courses, mdl_deltak_course_mappings, mdl_deltak_section_mappings, mdl_extras;
delete from mdl_capabilities where name='mod/extras:manage_extras';
insert into mdl_capabilities (name,captype,contextlevel,component) values('mod/extras:manage_extras','read','70','mod_extras');
@mkolb
mkolb / gist:3054048
Created July 5, 2012 14:32
changing permissions/ownership in postgres
for tbl in`psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" YOUR_DB`; do psql -c "alter table $tbl owner to NEW_OWNER" YOUR_DB ; done
for tbl in`psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" YOUR_DB`; do psql -c "alter table $tbl owner to NEW_OWNER" YOUR_DB ; done
for tbl in`psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" YOUR_DB`; do psql -c "alter table $tbl owner to NEW_OWNER" YOUR_DB ; done
@mkolb
mkolb / gist:3143416
Created July 19, 2012 12:08
mike's queries
select distinct mc.shortname as course_id, mr.shortname as role, mu.username as loginname, mcon.contextlevel
from mdl_user_enrolments mue
join mdl_enrol me on mue.enrolid=me.id
join mdl_user mu on mue.userid=mu.id
join mdl_course mc on me.courseid=mc.id
join mdl_role_assignments mra on mu.id=mra.userid
join mdl_role mr on mra.roleid=mr.id
join mdl_context mcon on mcon.instanceid=mc.id where mr.shortname='student' order by mc.shortname and mu.username=’craigl’;
-- yields
@mkolb
mkolb / navigationlib.php
Created October 25, 2012 13:49
groups + blogs fix
if (has_capability('moodle/course:viewparticipants', $this->page->context)) {
$participants = $coursenode->add(get_string('participants'), new moodle_url('/user/index.php?id='.$course->id), self::TYPE_CONTAINER, get_string('participants'), 'participants');
$currentgroup = groups_get_course_group($course, true);
if ($course->id == SITEID) {
$blogparams = array('courseid' => '');
} else if ($course->id && !$currentgroup) {
$blogparams = array('courseid' => clean_param($course->id, PARAM_INT));
} else {
$blogparams = array('group' => clean_param($currentgroup, PARAM_INT));
}