Skip to content

Instantly share code, notes, and snippets.

View betweenbrain's full-sized avatar
🎯
Focusing

Matt Thomas betweenbrain

🎯
Focusing
View GitHub Profile
@betweenbrain
betweenbrain / equal-split
Created July 16, 2014 05:50
PHP Split Array Into Somewhat Even Groups
<?php
/**
* File index.php
* Created 7/16/14 1:34 AM
* Author Matt Thomas | [email protected] | http://betweenbrain.com
* Support https://github.com/betweenbrain/
* Copyright Copyright (C) 2014 betweenbrain llc. All Rights Reserved.
* License GNU GPL v2 or later
*/
### Keybase proof
I hereby claim:
* I am betweenbrain on github.
* I am betweenbrain (https://keybase.io/betweenbrain) on keybase.
* I have a public key whose fingerprint is 54B6 C5FB C8B0 AB9A 1822 143F 8E98 4A78 99B5 F294
To claim this, I am signing this object:
<?php
$con = mysql_connect('localhost', 'dbUser', 'dbPassword');
$key = '1234567890123456';
$table = "CREATE TABLE people (
id INT NOT NULL AUTO_INCREMENT,
full_name VARCHAR(255),
ssn VARCHAR(255),
PRIMARY KEY (id)

Here is an example of write subquery in Joomla! 3 using JDatabase method.

<?php
// Initialize variables.
$db       = JFactory::getDbo();
$subQuery = $db->getQuery(true);
$query    = $db->getQuery(true);

// Create the base subQuery select statement.
@betweenbrain
betweenbrain / gist:11068237
Created April 18, 2014 23:20
MySQL Joomla GROUP_CONCAT Examples
// SQL
SELECT
`users`.`id`,
`users`.`name`,
(SELECT
GROUP_CONCAT(`k2`.`title`)
FROM
`jos_k2_items` AS `k2`
WHERE
`k2`.`created_by` = `users`.`id`
@betweenbrain
betweenbrain / gist:9239337
Created February 26, 2014 21:48
PHP PDO Fetch Array of Objects Indexed on Column Value
<?php
$sql = "SELECT id, name FROM `users`";
try
{
$query = $pdo->prepare($sql);
$query->execute();
}
@betweenbrain
betweenbrain / gist:8402480
Created January 13, 2014 15:43
PhpStorm SCSS File Watcher Settings for parallel SCSS and CSS directories

|-CSS

|-SCSS

Arguments: --no-cache --update $FileName$:$FileParentDir$/css/$FileNameWithoutExtension$.css Working directory: $FileDir$ Output paths to refresh: $FileParentDir$/css/$FileNameWithoutExtension$.css

NOTE: add --style compressed to Arguments for minified output

@betweenbrain
betweenbrain / gist:7798873
Created December 5, 2013 01:47
Disable VT-X in Vagrantfile
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--hwvirtex", "off"]
end
@betweenbrain
betweenbrain / gist:7763204
Created December 3, 2013 02:55
MySQL Find and Replace
update `jos_modules` set `params` = replace(`params`, 'getTemplate=Elsewhere articles','getTemplate=Elsewhere Articles') WHERE `module` = 'mod_k2_content';
update `jos_k2_items` set `fulltext` = replace(`fulltext`,'")','&rdquo;)');
JTable::getInstance - /libraries/joomla/table/table.php
JTableContent - /libraries/legacy/table/content.php