Skip to content

Instantly share code, notes, and snippets.

View kbariotis's full-sized avatar
🌏

Kostas Bariotis kbariotis

🌏
View GitHub Profile
@kbariotis
kbariotis / getProductsBuyers.sql
Last active August 29, 2015 14:13
Magento's Product Buyers
SELECT DISTINCT o.customer_id, ce.email FROM sales_flat_order_item i
JOIN sales_flat_order o ON o.entity_id = i.order_id
JOIN customer_entity ce ON ce.entity_id = o.customer_id
WHERE o.customer_id IS NOT NULL
AND i.sku = 'PRODUCT_SKU'
// --- Variables
// ---------------------------------------------------
// grid
$gutter: 10;
$max-width: 1100; // Max grid wrap width
$sm-column-count: 4;
$med-column-count: 6;
$lg-column-count: 12;
$mqs: 380; // small breakpoint
@kbariotis
kbariotis / pg.js
Last active August 29, 2015 14:17
Wrapper around node-postgres
var BPromise = require('bluebird'),
pg = require('pg');
function Postgres(opts) {
this.host = opts.host;
}
Postgres.prototype.query = function(sql) {
return new BPromise(function(resolve, reject){
@kbariotis
kbariotis / what-forces-layout.md
Last active September 19, 2015 20:12 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@kbariotis
kbariotis / Dockerfile
Created October 3, 2015 14:40 — forked from konklone/Dockerfile
Dockerfile for installing Ruby 2.0 and RVM
FROM ubuntu
MAINTAINER Eric Mill "eric@konklone.com"
# turn on universe packages
RUN echo "deb http://archive.ubuntu.com/ubuntu raring main universe" > /etc/apt/sources.list
RUN apt-get update
# basics
RUN apt-get install -y nginx openssh-server git-core openssh-client curl
RUN apt-get install -y nano
details {
decorator: url(#details-closed);
}
details[open] {
decorator: url(#details-open);
}
<h1>Flexible columns &mdash; fixed width gutter</h1>
<h2>Using a border as faux margin</h2>
<div class="flexwrapper">
<section></section>
<section></section>
<section></section>
<section></section>
</div>
@kbariotis
kbariotis / gist:7736356
Created December 1, 2013 16:31
PHP function to get distance between two geolocations.
<?php
function distance($lat1, $lon1, $lat2, $lon2, $unit) { //unit = "K" for km, "N" for radians
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$unit = strtoupper($unit);
@kbariotis
kbariotis / index.html
Created November 17, 2016 09:37 — forked from nimbupani/index.html
Showing latest post on home page with Jekyll
---
layout: default
---
<div class="blog-index">
{% assign post = site.posts.first %}
{% assign content = post.content %}
{% include post_detail.html %}
</div>
@kbariotis
kbariotis / main.js
Last active December 12, 2016 10:34
Flatten nested array using reduce
/**
* Takes a nested array and ftattens it
*
* @param {Array} val They input array
* @return {Array} val Flatten array
*/
function flatten(val) {
/*
* Recursively walk over the array and concat all elements back to the first level array