Skip to content

Instantly share code, notes, and snippets.

@ortodesign
ortodesign / resetIDs.sql
Created February 7, 2018 16:59
Rearrange IDs
SET @count = 0;
UPDATE `Product` SET `Product`.`id` = @count:= @count + 1;
ALTER TABLE `Product` AUTO_INCREMENT = 1;
@ortodesign
ortodesign / json-to-csv.php
Created January 17, 2018 09:38 — forked from Kostanos/json-to-csv.php
Convert JSON array file to CSV. Use the array keys as the first row. Command line using: json-to-csv.php json.filename > csv.filename
#!/usr/bin/php
<?php
/*
* Convert JSON file to CSV and output it.
*
* JSON should be an array of objects, dictionaries with simple data structure
* and the same keys in each object.
* The order of keys it took from the first element.
*
* Example:
@ortodesign
ortodesign / showspreadsheet.php
Created December 23, 2017 09:03 — forked from pamelafox/showspreadsheet.php
PHP for parsing the JSON output a published Google spreadsheet and displaying columns from each row.
<?php
// Parsing this spreadsheet: https://spreadsheets.google.com/pub?key=0Ah0xU81penP1dFNLWk5YMW41dkcwa1JNQXk3YUJoOXc&hl=en&output=html
$url = 'http://spreadsheets.google.com/feeds/list/0Ah0xU81penP1dFNLWk5YMW41dkcwa1JNQXk3YUJoOXc/od6/public/values?alt=json';
$file= file_get_contents($url);
$json = json_decode($file);
$rows = $json->{'feed'}->{'entry'};
foreach($rows as $row) {
echo '<p>';