Skip to content

Instantly share code, notes, and snippets.

View malithmcr's full-sized avatar

Malith malithmcr

View GitHub Profile
@malithmcr
malithmcr / 0_reuse_code.js
Created November 26, 2015 15:36
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@malithmcr
malithmcr / media-query.scss
Created June 28, 2016 13:33
A CSS media query for high DPI aware devices.
@media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 1300px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 1300px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 1300px),
only screen and ( min-device-pixel-ratio: 2) and (min-width: 1300px),
only screen and ( min-resolution: 192dpi) and (min-width: 1300px),
only screen and ( min-resolution: 2dppx) and (min-width: 1300px) {
//code
@malithmcr
malithmcr / style.scss
Created July 1, 2016 10:30
Display inline-flex cross browsing
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
display: inline-flex;
@malithmcr
malithmcr / SCSS.md
Created August 26, 2016 10:15 — forked from jareware/SCSS.md
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@mixin responsive-font($responsive, $min, $max: false) {
$responsive-unitless: $responsive / ($responsive - $responsive + 1);
$dimension: if(unit($responsive) == 'vh', 'height', 'width');
$min-breakpoint: $min / $responsive-unitless * 100;
@media (max-#{$dimension}: #{$min-breakpoint}) {
font-size: $min;
}
@if $max {
@malithmcr
malithmcr / header.phtml
Last active November 13, 2017 22:39
Send Magento order confirmation email programmatically
<?php
$order = new Mage_Sales_Model_Order();
$incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order->loadByIncrementId($incrementId);
try {
$order->sendNewOrderEmail();
} catch (Exception $ex) { }
@malithmcr
malithmcr / throttle.js
Last active October 25, 2018 14:06
javascript throttle
/**
* throttle
* @param {fn} callback func
* @param {wait} number - wait time
* @public
*/
function throttle(fn, wait) {
var time = Date.now();
return function() {
@malithmcr
malithmcr / Deploy With Git
Created November 11, 2018 10:21 — forked from calebbrewer/Deploy With Git
Manage and deploy a website with Git. I am using Lunux CentOS for my server.
Video on this Gist: https://www.youtube.com/watch?v=zvpLDuRY4ss&feature=c4-overview&list=UUj8_147vA3FQ1quI_CjciIQ
#Initialize a bare repo on the webserver. This would preferably be outside of your public website dir but if you are on a shared host you may not have that option. I like to make a folder just outside of the live folder called git. So for me it would look like this…
$ cd /var/www
$ mkdir git && cd git
$ git init –-bare
#Now you need to create a post-receive hook that will check out the latest tree from the Git repo you just setup into the /var/www/html folder where you want your website to be. You can make this whatever folder you want your code to end up in.
#This will create a file called post-receive in the hooks dir of the git repo.
render() {
return(
<div className="App">
</div>
);
}
@malithmcr
malithmcr / custom-oop-wp.php
Created February 18, 2019 13:08
Wordpress OOP
namespace Wpse240042\Type;
use WP_Post;
interface Book {
/**
* @return string
*/
public function title();