Skip to content

Instantly share code, notes, and snippets.

View zaigham's full-sized avatar
🌏

Zaigham R. zaigham

🌏
View GitHub Profile
@zaigham
zaigham / youtube_id_regex.php
Created August 29, 2018 16:08 — forked from ghalusa/youtube_id_regex.php
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@zaigham
zaigham / modx-content-search-and-replace.php
Created December 15, 2017 09:43 — forked from christianhanvey/modx-content-search-and-replace.php
MODX utility snippet: replace absolute formed links in site content eg www.xxx.com/99 -> [[~99]] note: backing up modx_site_content table is a good idea before running this :) (original author: BobRay)
<?php
$docs = $modx->getCollection('modDocument');
$pattern = '/www.xxx.com/(\d+)/';
$replacement = '[[~$1]]';
$count = 0;
foreach ($docs as $doc) {
$content = $doc->getContent();
$hash1 = sha1($content);

Keybase proof

I hereby claim:

  • I am zaigham on github.
  • I am zaigham (https://keybase.io/zaigham) on keybase.
  • I have a public key ASC9GHD4HGay74R4HPu6TY_2fHeFhkSILheH4bGoOSJERwo

To claim this, I am signing this object:

@zaigham
zaigham / bootstrap-breakpoints.sass
Created August 7, 2016 11:53 — forked from webinfinita/bootstrap-breakpoints.sass
Variables for responsive design in bootstrap with sass
@mixin breakpoint($point)
@if $point == lg
@media (min-width: 1200px)
@content
@else if $point == md
@media (min-width: 992px) and (max-width: 1199px)
@content
@else if $point == sm
@zaigham
zaigham / reactjsnotes.md
Last active June 2, 2016 06:26
ReactJS Notes

Everything is a component.

Keypoints

  • One of the first things you’ll notice in React is that you’ll be writing markup in JS, not in HTML.
  • Do not use class. Instead, use className. It’s because JSX gets translated to JS, and class is a keyword in the newest version of JS.
  • If you use <br> instead of <br/>, it won’t work. Make sure to put / on self-closing tags.

Workflow

@zaigham
zaigham / versionx-hhvm.txt
Last active August 29, 2015 14:21
versionx-install-hhvm-error
Below is the error I could catch... in /var/log/hhvm/error.log
The Manager CMP for VersionX are installed and working fine. but new tables are not created.
===========================
\nFatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S02] [1146] Table 'modx23xhhvm.modx_versionx_resource' doesn't exist' in :\nStack trace:\n#0 /home/vagrant/modx/23x/core/xpdo/xpdo.class.php(2500): PDO->query()\n#1 /home/vagrant/modx/23x/core/xpdo/om/mysql/xpdomanager.class.php(131): xPDO->query()\n#2 /home/vagrant/modx/23x/core/packages/versionx-2.1.2-pl/modCategory/c7c31abcbb1216d62f8deff18301a6d9.tables.resolver.resolver(40): xPDOManager_mysql->createObjectContainer()\n#3 /home/vagrant/modx/23x/core/xpdo/transport/xpdovehicle.class.php(226): include()\n#4 /home/vagrant/modx/23x/core/xpdo/transport/xpdoobjectvehicle.class.php(227): xPDOVehicle->resolve()\n#5 /home/vagrant/modx/23x/core/xpdo/transport/xpdoobjectvehicle.class.php(88): xPDOObjectVehicle->_installObject()\n#6 /home/vagrant/modx/23x/core/
<?php
/**
* SessionManager
* A script that can be used for easy control over your session variables.
* Put this script in your core/components/ folder, inside a sessionman/ subdirectory.
*
* Load this one in your snippets/plugins like;
*
* $sessman = $modx->getService('session','SessionManager', $modx->getOption('sessman.core_path',null,$modx->getOption('core_path').'components/sessionman/'), $scriptProperties);
* if(!($sessman instanceof SessionManager)) { $modx->log(modX::LOG_LEVEL_ERROR, 'Session manager could not be loaded..'); return ''; }
@zaigham
zaigham / gist:c639c61b8b60c16f37fe
Created October 17, 2014 17:53
modDevTools download error log
[2014-10-17 22:42:56] (ERROR @ C:\Ampps\...\core\model\modx\transport\modtransportprovider.class.php : 232) PHP warning: array_merge(): Argument #1 is not an array
[2014-10-17 22:42:56] (ERROR @ C:\Ampps\...\core\model\modx\transport\modtransportprovider.class.php : 357) Recoverable error: Argument 2 passed to modTransportProvider::arg() must be of the type array, null given, called in C:\Ampps\...\core\model\modx\transport\modtransportprovider.class.php on line 232 and defined
[2014-10-17 22:42:56] (ERROR @ C:\Ampps\...\core\model\modx\transport\modtransportprovider.class.php : 365) Recoverable error: Argument 1 passed to modTransportProvider::args() must be of the type array, null given, called in C:\Ampps\...\core\model\modx\transport\modtransportprovider.class.php on line 359 and defined
[2014-10-17 22:42:56] (ERROR @ C:\Ampps\...\core\model\modx\transport\modtransportprovider.class.php : 379) PHP warning: array_merge(): Argument #2 is not an array
[2014-10-17 22:42:56] (ERROR @ C:\Ampps\...\core\model\mo
protected void Page_PreRender(object sender, EventArgs e)
{
int temp = Convert.ToInt32(leftnav.Count);
if (count == 0 && Convert.ToInt32(leftnav.Count) == 0)
{
contentright.Attributes["class"] = "center-part";
}
else if (count == 0 && Convert.ToInt32(leftnav.Count) != 0)
@zaigham
zaigham / modx-themes-tpl.html
Last active October 5, 2016 19:47
MODX Themes details from ThemeForest JSON API
<article class="col-sm-6 col-md-6 col-lg-6">
<div><a href="[[+url]]?ref=[[+ref]]"><img class="img-responsive" src="[[+live_preview_url]]" alt="[[+item]]"></a></div>
<div style="min-height: 6em;"><h4><a href="[[+url]]?ref=[[+ref]]">[[+item]]<br/><small>USD$[[+cost]]</small></h4></a></div>
</article>