Skip to content

Instantly share code, notes, and snippets.

View euperia's full-sized avatar

Andrew McCombe euperia

View GitHub Profile
@euperia
euperia / csvsplitter.php
Created May 26, 2017 08:05
Split a CSV file into chunks
#!/usr/bin/env php
<?php
function help() {
echo PHP_EOL . 'Usage: csvsplitter <input file> <number of lines>' . PHP_EOL;
exit();
}
if (!isset($argv[1])) {
echo PHP_EOL . "Please enter a csv filename";
@euperia
euperia / cleanup.sh
Created May 26, 2017 08:03
Remove files that are not what they appear to be
#!/bin/sh
# Some image files were fetched from an URL and not validated.
# Hence we have files that have '.jpg' extensions but are actually HTML files.
# Clean these out
# Remove the `-i` from the `rm` if you don't want to manually confirm deletion
for f in `find ./ -type f -iname "*.jpg"`;
do
file "$f" | grep -q HTML
if [ $? -eq 0 ] ; then
@euperia
euperia / vue2-table-example.html
Last active September 12, 2017 21:41
Sample Vue.js 2 table with rows
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue 2 table example</title>
</head>
<body>
<div id="app">
<table width="90%" border="1" cellpadding="2" cellspacing="2" v-show="sites.length > 0">
@euperia
euperia / gist:d17df77ff5f7cad5dd87fd61bccf36d3
Created August 17, 2016 14:30
How to use Group By on a Magento Collection
<?php
$collection = Mage::getModel('sales/order_item')->getCollection();
$collection
->addAttributeToFilter('updated_at', array('gt' => $this->reportStartDate))
->addAttributeToFilter('updated_at', array('lt' => $this->reportEndDate));
// this is where we add the group by
$collection->getSelect()->group('main_table.sku');
@euperia
euperia / foreach.js
Created May 12, 2016 07:26
Javascript: forEach over arrays and Objects
// forEach over Arrays
var items = ['fish', 'birds', 'dogs', 'cats'];
items.forEach(function(item, index) {
console.log(index + ': ' + item);
});
// forEach over Objects
var h2 = document.getElementsByTagName('h2');
Object.keys(h2).forEach(function(item){
Verifying that +euperia is my blockchain ID. https://onename.com/euperia
@euperia
euperia / debug-bootstrap.css
Created February 27, 2015 11:29
Boostrap responsive debugging CSS.
/**
* Use this to show which breakpoint the css is using
* when using Bootstrap responsive
*/
body::before {
content: "xs";
position: fixed;
top: 0;
left: 0;
@euperia
euperia / phantomgrab.js
Created February 23, 2015 16:15
Screengrab a website with phantom.js
/**
* Phantomgrab - take a screenshot of a webpage
*
* Run with:
* phantomjs --ssl-protocol=any --ignore-ssl-errors=true phantomgrab.js
*
*/
var page = require('webpage').create();