Skip to content

Instantly share code, notes, and snippets.

View srinathweb's full-sized avatar

srinath madusanka srinathweb

View GitHub Profile
@srinathweb
srinathweb / twig
Created September 30, 2015 04:18
twig
http://stackoverflow.com/questions/9842342/building-a-site-with-twig-php-template-engine
If you're using several PHP files then it's wise to create template renderer class, which will bootstrap Twig classes, set options and take care of finding and rendering requested templates:
<?php
// Use correct path to Twig's autoloader file
require_once '/path/to/lib/Twig/Autoloader.php';
// Twig's autoloader will take care of loading required classes
Twig_Autoloader::register();
@srinathweb
srinathweb / Reload the page after ajax success
Created October 21, 2015 09:03
Reload the page after ajax success
$(document).ajaxStop(function(){
setTimeout("window.location = 'otherpage.html'",100);
});
@srinathweb
srinathweb / load more
Created October 22, 2015 03:34
load more
Have you heard about the jQuery Waypoint plugin.
Below is the simple way of calling a waypoints plugin and having the page load more Content once you reaches the bottom on scroll :
$(document).ready(function() {
var $loading = $("<div class='loading'><p>Loading more items&hellip;</p></div>"),
$footer = $('footer'),
opts = {
@srinathweb
srinathweb / bootsrap solution
Created October 22, 2015 08:33
bootsap solution
@media (min-width: 1200px) {
.container{
max-width: 970px;
}
}
@srinathweb
srinathweb / recover position fixed issue opera
Created October 22, 2015 11:00
recover position fixed width issue opera
.menufixed{
position: fixed;
top: 0;
z-index: 999;
margin: 0 auto;
width: 100%;
background: #fff;
left: 50%;
transform: translateX(-50%);
@srinathweb
srinathweb / url hash
Created October 22, 2015 12:15
url hash
if(window.location.hash) {
// Fragment exists
} else {
// Fragment doesn't exist
}
@srinathweb
srinathweb / download_and_upload.php
Created October 28, 2015 10:19 — forked from joseporiol/download_and_upload.php
Just Download & save a remote image on your server using PHP
$image = file_get_contents('http://www.url.com/image.jpg');
file_put_contents('/images/image.jpg', $image); //save the image on your server
@srinathweb
srinathweb / iframe width
Created November 4, 2015 10:34
iframe width
Add this to your <head> section
<script language="javascript" type="text/javascript">
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
</script>
And change your iframe to this:
@srinathweb
srinathweb / rotete
Created November 5, 2015 04:41
rotate
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.00000000, M12=1.00000000, M21=-1.00000000, M22=0.00000000,sizingMethod='auto expand')";
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.00000000, M12=1.00000000, M21=-1.00000000, M22=0.00000000,sizingMethod='auto expand');
-moz-transform: matrix(0.00000000, -1.00000000, 1.00000000, 0.00000000, 0, 0);
-webkit-transform: matrix(0.00000000, -1.00000000, 1.00000000, 0.00000000, 0, 0);
-o-transform: matrix(0.00000000, -1.00000000, 1.00000000, 0.00000000, 0, 0);
http://stackoverflow.com/questions/11900870/rotating-a-text-to-270-degrees-in-ie8
@srinathweb
srinathweb / opencart external
Created November 6, 2015 05:06
opencart external
How do I add a product to OpenCart from an external site?
up vote
0
down vote
favorite
I need to add a product to the shopping cart from a website to ocart. I was trying the following code. All I get is "shopping cart empty" after the user clicks the submit button.