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 / 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>
@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 / equalheight-columns.js
Last active December 15, 2015 16:49
A quick solution for same height columns.
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
var max = 0;
$(".col").each(function(){
if ($(this).height() > max) {
max = $(this).height();
}
});
@zaigham
zaigham / gist:4612852
Last active December 11, 2015 14:18
Hack to stop Chrome from downloading phpthumb images on every transition in slider
<?php
// AROUND LINE 3909 in phpthumb.class.php: added >>>> header('Cache-Control:'); <<<< to the logic.
if (function_exists('ImageTypes')) {
$imagetypes = ImageTypes();
if ($imagetypes & IMG_PNG) {
header('Content-Type: image/png');
header('Cache-Control:');
ImagePNG($gdimg_error);
jQuery(document).ready(function ($) {
var $tagcloudArticles = $('#tagcloudArticles');
$tagcloudArticles.imagesLoaded(function(){
$tagcloudArticles.masonry({
// options
itemSelector : '.brick',
columnWidth : 230
});
var $container = $('#container');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector : '.item',
columnWidth : 240
});
});