Skip to content

Instantly share code, notes, and snippets.

View dumindu's full-sized avatar
🦄
One step closer...

Dumindu Madunuwan dumindu

🦄
One step closer...
View GitHub Profile
@dumindu
dumindu / uri.js
Last active October 26, 2015 06:51 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@dumindu
dumindu / gist:3359218
Created August 15, 2012 11:14 — forked from acconrad/gist:3350416
How to target mobile devices with CSS Media Queries
@media only screen and (-webkit-device-pixel-ratio: .75) {
/* CSS for Low-density Android screens goes here *
* Ex: HTC Evo, HTC Incredible, Nexus One */
}
@media only screen and (-webkit-device-pixel-ratio: 1) and (max-device-width: 768px) {
/* CSS for Medium-density Android screens goes here *
* Ex: Samsung Ace, Kindle Fire, Macbook Pro *
* max-device-width added so you don't target laptops and desktops */
}
@dumindu
dumindu / Backbone + Handlebars + backbone.layoutmanager
Created November 25, 2012 10:08
Backbone + Handlebars + backbone.layoutmanager
render: function() {
var source = $("#round").html();
var template = Handlebars.compile(source);
var context = JSON.parse(this.model.toJSON);
console.log(context);
var html = template(context);
$(this.el).html(html);
return this;
},
/* Glass effect */
.box {
background: none repeat scroll 0 0 rgba(255, 255, 255, 0.6);
border-radius: 3px;
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.4);
display: block;
margin: 10px 5px;
padding: 20px;
}
SELECT t.id, COUNT(r.id) AS redeemsCount, r.offerId, t.offerTypeId, r.price, t.discountPercentage, t.discount,
CASE
WHEN t.offerTypeId = 1
THEN SUM(r.price)
WHEN t.offerTypeId = 2
THEN SUM((r.price * t.discountPercentage) / 100)
ELSE SUM(t.discount) END
AS redeemsValue
FROM `Offer` `t`
LEFT JOIN `Redeem` r ON r.offerId = t.id
fn main() {
println!("Hello, world!");
}
├── Cargo.toml
└── src
└── main.rs
├── Cargo.toml
└── src
└── lib.rs
let a = true;
let b: bool = true;
let (x, y) = (1, 2);
let mut z = 5;
z = 6;
const N: i32 = 5;