Skip to content

Instantly share code, notes, and snippets.

@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>';
@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 / 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 / parse_newEgg.php
Created March 5, 2018 11:00
Parse JS object (not JSON) in PHP
class JsParserException extends Exception {}
function parse_jsobj($str, &$data) {
$str = trim($str);
if(strlen($str) < 1) return;
if($str{0} != '{') {
throw new JsParserException('The given string is not a JS object');
}
$str = substr($str, 1);
// print_r($str);
@ortodesign
ortodesign / modx-snippets.php
Created March 9, 2018 08:44 — forked from christianhanvey/modx-snippets.php
Useful snippets for MODX Revo
Snippet: [[SnippetName]]
Chunk: [[$ChunkName]]
System Setting: [[++SettingName]]
TV: [[*fieldName/TvName]]
Link tag: [[~PageId? &paramName=`value`]]
Placeholder: [[+PlaceholderName]]
<?php
@ortodesign
ortodesign / ys_functions.js
Created March 29, 2018 09:15
Эмуляция события etype на элементе el (pure js)
/**
* Эмуляция события etype на элементе el
* @param el
* @param etype
*/
function eventFire(el, etype){
if (el.fireEvent) {
el.fireEvent('on' + etype);
} else {
var evObj = document.createEvent('Events');
@ortodesign
ortodesign / my.cnf
Created March 30, 2018 14:13
mysql 5.7.21 utf-8 support
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
character-set-server = utf8
collation-server = utf8_unicode_ci
[client]
default-character-set = utf8
@ortodesign
ortodesign / readme.md
Created September 25, 2018 09:25 — forked from nonsintetic/readme.md
PHP - Get YouTube subscriber count with Youtube API v3

How to:

Here's a 'simple' way to get the YouTube subscriber number from Google's Youtube API v3:

  1. Go to https://console.developers.google.com/apis/library
  2. Log in with your Google account.
  3. Next to the logo click on 'Project' and 'Create project'. Name it whatever you want and click on 'Create'.
  4. Wait until the project is created, the page will switch to it by itself, it will take a couple of seconds up to a minute. Once it's done it will be selected next to the logo.
  5. Once it's created and selected, click on 'Credentials' from the menu on the left.
  6. Click on 'Create Credentials' and choose 'API Key'. You can restrict it to specific IPs, or types of requests (website, android, ios etc.) if you want, it's safer that way.
@ortodesign
ortodesign / DBsocialController.php
Created October 16, 2018 07:59
php get protected propety
function getProtectedValue($obj,$name) {
$array = (array)$obj;
$prefix = chr(0).'*'.chr(0);
return $array[$prefix.$name];
}
@ortodesign
ortodesign / jQueryToVanilla.js
Created February 25, 2019 09:07
Нативные аналоги jQuery
Нативные аналоги jQuery
Ниже приведены аналоги нативного исполнения jQuery методов, с поддержкой IE 8+
Поиск по селектору
// jQuery
var els = $('.el');
// Native
var els = document.querySelectorAll('.el');