Skip to content

Instantly share code, notes, and snippets.

View davidpede's full-sized avatar

David Pede davidpede

View GitHub Profile
@davidpede
davidpede / mp4Box - Apple iOS Subtitles
Last active August 29, 2015 13:56
Commands for muxing Apple iOS compatible soft subtiles into MP4 files using mp4Box
# Add subtitle track
-add "input.mp4" -add "english-subs.srt:hdlr=sbtl:group=2:layer=-1:lang=en:name=English" -new "output.mp4"
# Add multiple subtitle tracks
-add "input.mp4" -add "english-subs.srt:hdlr=sbtl:group=2:layer=-1:lang=en:name=English" -add "french-subs.srt:hdlr=sbtl:group=2:layer=-1:lang=fr:disabled:name=French" -new "output.mp4"
@davidpede
davidpede / Clear Field on Focus
Last active August 29, 2015 13:56
Clear the content of a text input field when on focus
# Option One
<script type="text/javascript">
$(document).ready(function() {
$("input:text").each(function () {
var v = this.value; // store default value
$(this).blur(function () {
if (this.value.length == 0) this.value = v; // if input is empty, reset value to default
})
.focus(function () {
this.value = ""; // when input is focused, clear its contents
<div style="absolute;top:0;left:0;width:100%">
[^qt^] - Query Time - Shows how long MODx took talking to the database<br/>
[^q^] - Query Count -Shows how many database queries MODx made<br/>
[^p^] - Parse Time - Shows how long MODx took to parse the page<br/>
[^t^] - Total Time - Shows the total time taken to parse/ render the page<br/>
[^s^] - Source - Shows the source of page, whether is database or cache.
</div>
<!-- MySQL: [^qt^], [^q^] request(s), PHP: [^p^], Total: [^t^], document retrieved from [^s^]. -->
[[pdoResources?
&parents=`537`
&limit=`0`
&showHidden=`0`
&hideContainers=`1`
&sortby=`longtitle`
&sortdir=`ASC`
&tplWrapper=`@INLINE N/A==na||[[+output]]`
&tpl=`@INLINE [[+longtitle]]==[[+id]]||`
&tplLast=`@INLINE [[+longtitle]]==[[+id]]`
@davidpede
davidpede / git-pr-commands
Last active March 31, 2016 09:14
GitHub PR management and merge example
MERGE PR - Have issued pr to upstream branch:
1. Open target repo in cmd
2. git checkout develop
3. git checkout -b test-branch-name develop
*create and switch to a new branch, from develop to test the pr changes
4. git pull https://github.com/account/fork-repo.git pr-branch-name
*pull the whole pr branch into test branch
5. Review changes in test branch
6. git checkout develop
@davidpede
davidpede / gist:a3cff92bf44dfd821499bc8f0c7b68b2
Created July 10, 2017 23:47
Add custom json data to modObjectGetListProcessor
public function process() {
$beforeQuery = $this->beforeQuery();
if ($beforeQuery !== true) {
return $this->failure($beforeQuery);
}
$data = $this->getData();
$list = $this->iterate($data);
$datetime = new DateTime('Europe/London');
$curtime = $datetime->format('Y\-m\-d\ H:i:s');
@davidpede
davidpede / gist:38bcdc9783edfe74bb910d2485d3b446
Created July 11, 2017 10:01
Print_r from processors to error log
$this->modx->log(xPDO::LOG_LEVEL_ERROR,'Label: ' . print_r($my_output, true));
@davidpede
davidpede / gist:89ea36465147074e32210bba5a4e7f10
Created July 14, 2017 11:07
Load lexicons in controller examples
public function render() {
//$this->modx->controller->addLexiconTopic('core:dashboard');
$this->controller->addJavascript($this->modx->getOption('manager_url').'assets/modext/widgets/security/modx.grid.user.online.js');
$this->controller->addHtml('
<script type="text/javascript">
Ext.applyIf(MODx.lang, '. $this->modx->toJSON($this->modx->lexicon->loadCache('core', 'dashboard')) .');
Ext.onReady(function() {
MODx.load({
xtype: "modx-grid-user-online"
$query = $this->modx->newQuery('modUser');
//checks
$query->where(array(
'active' => 1,
'Profile.blocked' => 0
));
//by usergroup
$query->where(array('primary_group:IN' => array(1,2,3)));
//by id
$query->where(array('id:IN' => array(1,2,3)),xPDOQuery::SQL_OR); //<-- uses OR condition
$query = $this->modx->newQuery('modUser');
$query->innerJoin('modUserProfile','Profile');
//Select ALL fields from both tables
$query->select(array('modUser.*, Profile.*'));
---
$query->select(array('modUser.*'));
$query->select($this->modx->getSelectColumns('modUserProfile','Profile','profile_'));
//Select SPECIFIC fields from both tables