Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew McCombe euperia

View GitHub Profile
@euperia
euperia / csvsplitter.php
Created May 26, 2017
Split a CSV file into chunks
View csvsplitter.php
#!/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
Remove files that are not what they appear to be
View cleanup.sh
#!/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 Sep 12, 2017
Sample Vue.js 2 table with rows
View vue2-table-example.html
<!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 Aug 17, 2016
How to use Group By on a Magento Collection
View gist:d17df77ff5f7cad5dd87fd61bccf36d3
<?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
Javascript: forEach over arrays and Objects
View foreach.js
// 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){
View gist:05470f9807f750efaf16
Verifying that +euperia is my blockchain ID. https://onename.com/euperia
@euperia
euperia / debug-bootstrap.css
Created Feb 27, 2015
Boostrap responsive debugging CSS.
View debug-bootstrap.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 Feb 23, 2015
Screengrab a website with phantom.js
View phantomgrab.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();
You can’t perform that action at this time.