Skip to content

Instantly share code, notes, and snippets.

View anderskristo's full-sized avatar
👶
Focusing

Anders Kristoffersson anderskristo

👶
Focusing
View GitHub Profile
/**
* Mobile swipe
*/
var swipeFunc = {
touches: {
"touchstart": {"x": -1, "y": -1},
"touchmove": {"x": -1, "y": -1},
"touchend": false,
"direction": "undetermined"
},
@anderskristo
anderskristo / ng-countUp.js
Created April 3, 2015 19:21
ng-countUp.js directive
<ng-count-up from="0" to="2500" decimals="1" duration="2" delay="500" options="options"></ng-count-up>
@anderskristo
anderskristo / array-sortbykey.js
Created March 31, 2015 06:42
Array sortByKey
function sortByKey(array, key) {
return array.sort(function(a, b) {
var x = a[key]; var y = b[key];
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
});
}
@anderskristo
anderskristo / gist:89bf9fb9069aa630e8b9
Last active August 29, 2015 14:16
Launch Iphone 6 simulator from command line
xcrun instruments -w "iPhone 6 Plus (8.1 Simulator) [131B0452-EF78-4DC3-958E-88BB38DF479A]"
xcrun instruments -w "Resizable iPad (8.1 Simulator) [D412049F-CC28-41E5-904C-00D9E8BCAC4E]"
xcrun instruments -w "Resizable iPhone (8.1 Simulator) [5CBE2A07-2444-4B0F-B784-844135DA6276]"
xcrun instruments -w "iPad 2 (8.1 Simulator) [11E7311B-C808-4C3A-BBA2-C0C8C02C4E97]"
xcrun instruments -w "iPad Air (8.1 Simulator) [6F48D344-ADF7-433D-96D2-0AF429F73E5E]"
xcrun instruments -w "iPad Retina (8.1 Simulator) [AD15675B-75A6-4C55-B955-6407141811EF]"
xcrun instruments -w "iPhone 4s (8.1 Simulator) [405848FD-3551-48A4-A02F-FE07F3C9EE38]"
xcrun instruments -w "iPhone 5 (8.1 Simulator) [C6ABF7B4-C8B9-4923-9AF2-CF919FCA44CE]"
xcrun instruments -w "iPhone 5s (8.1 Simulator) [A47D3115-A86E-4826-BF9D-661C63D8CFE7]"
xcrun instruments -w "iPhone 6 (8.1 Simulator) [A0FBE72B-E8AE-475F-84F1-545DB3F29AFA]"
@anderskristo
anderskristo / files-in-directory-to-json-script
Created February 22, 2015 00:24
files in directory to json script
#!/usr/bin/env python
import os
import errno
def path_hierarchy(path):
hierarchy = {
'name': os.path.basename(path),
'icon': path,
}
@anderskristo
anderskristo / magento-get-attribute-value
Last active August 29, 2015 14:14
Magento get attribute value
<?php
$productModel = Mage::getModel('catalog/product');
$int_attr_id = 1337; // Get attr by ID
$attr = Mage::getModel('catalog/resource_eav_attribute')->load($int_attr_id);
$attributeValue = $_product->getResource()->getAttribute($attr->getAttributeCode())->getFrontend()->getValue($_product);
var_dump($attributeValue);
?>