Skip to content

Instantly share code, notes, and snippets.

ImranCS / family.php
Last active Aug 29, 2015
parse tree from plain text notation and render using tables
View family.php
//see it in action:
//the input data is in the form of family.txt
//when parsed, it takes the form of family2.txt
public function renderInfo($people = false, $name = false)
$sub = $people !== false;
if (!$name) $name = $this->person->name;
if (!$people) $people = self::parse($this->family_info);
$father = false; $mother = false;
ImranCS / tree.php
Created Jun 10, 2015
Build tree from table with parent_id
View tree.php
//Similar to
$items= Yii::app()->db->createCommand('select id, name, parent_id from locations order by id')->queryAll();
$items = Formatter::arrayGroupBy($items, 'id', 'parent_id');
public static function arrayGroupBy($items, $key, $column)
return self::groupArray($items, $key, $column, '');
ImranCS / data.php
Created Jun 9, 2015
read geolocation and use jquery ajax to post back
View data.php
$name = $_POST["name"];
$lat = $_POST['latitude'];
$lon = $_POST['longitude'];
//TODO: Save to db
echo date('d M Y h:i:s');
View QGenLite.cs
static void Main()
var ofd = new OpenFileDialog { InitialDirectory = path };
if (ofd.ShowDialog() == DialogResult.Cancel)
MessageBox.Show("Nothing selected. exiting");
ImranCS / wordpress.php
Created Oct 25, 2013
Multiple Environment Configuration - configuring different frameworks for handling local / qa / prod configurations
View wordpress.php
// in the wp-config of wordpress, you can replace the usual define(DB_NAME) etc with this method (to configure the db)
// for varying the codebase per site, you can refer to the CS Sites plugin
// -
// this config is for 2 sets of sites (biblios + tg) on 2 environments, hence the siteNamesWeb
function site_db_config() {
$local = true;
$dbPrefix = ''; // in case you have a convention (wp_ for wordpress etc)
$siteNames = array(
ImranCS / wp-testimonials.php
Last active Dec 16, 2015
Tweaks to other wp-plugins
View wp-testimonials.php
// In the sfstst_showall function, add the do_shortcode line to this one below
if ($tstpage2->sfimgurl != '') { // check for image
$tstpage2->sfimgurl = do_shortcode($tstpage2->sfimgurl);
// Then in the testimonial Image url, you can use something like
// [link type=img src=testimonials/guy.jpg return=src]
// And this will we changed (via link shortcode of cs-companion) to