Skip to content

Instantly share code, notes, and snippets.

Imran ImranCS

Block or report user

Report or block ImranCS

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ImranCS
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: http://plus65.in/family/1
//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
ImranCS / tree.php
Created Jun 10, 2015
Build tree from table with parent_id
View tree.php
//Similar to http://cselian.com/blog/tech/snippets/displaying-tree-info/
//Controller
$items= Yii::app()->db->createCommand('select id, name, parent_id from locations order by id')->queryAll();
$items = Formatter::arrayGroupBy($items, 'id', 'parent_id');
//Formatter
public static function arrayGroupBy($items, $key, $column)
{
return self::groupArray($items, $key, $column, '');
@ImranCS
ImranCS / data.php
Created Jun 9, 2015
read geolocation and use jquery ajax to post back
View data.php
<?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()
{
start:
var ofd = new OpenFileDialog { InitialDirectory = path };
if (ofd.ShowDialog() == DialogResult.Cancel)
{
MessageBox.Show("Nothing selected. exiting");
return;
}
@ImranCS
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
// - https://github.com/ImranCS/wp-cselian/tree/master/cs-sites
// 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
ImranCS / wp-testimonials.php
Last active Dec 16, 2015
Tweaks to other wp-plugins
View wp-testimonials.php
<?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
// http://tg.cselian.com/assets/images/testimonials/guy.jpg
?>
You can’t perform that action at this time.