Skip to content

Instantly share code, notes, and snippets.

SELECT T.value FROM (
SELECT DISTINCT TRIM(SUBSTRING_INDEX(SUBSTRING_INDEX(t.ingredients, ',', n.n), ',', -1)) value
FROM ProductsHaveMetadata t CROSS JOIN
(
SELECT a.N + b.N * 10 + 1 n
FROM
(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) a
,(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) b
ORDER BY n
) n
csplit --digits=2 --prefix=table-nr- mydumpname.sql "/-- Table structure for table/+1" "{*}"
@nini
nini / react-async-poll.js
Created November 14, 2017 09:06
react-async-poll.js
import React from 'react';
import 'whatwg-fetch'; // https://www.npmjs.com/package/whatwg-fetch
import asyncPoll from 'react-async-poll';
import ReactDOM from "react-dom";
const Status = props => {
let text = '';
const {inProgress, isSuccessful, isFailed, stopPolling} = props;
console.log(props);
@nini
nini / enforce-utf8.php
Created July 24, 2017 09:28
Enforce UTF8
<?php
\UConverter::transcode('content', 'UTF-8', 'UTF-8')
@nini
nini / .bashrc
Last active July 12, 2017 08:20
Run php cli with xdebug enabled
alias xphp='XDEBUG_CONFIG="idekey=x" php -dzend_extension=xdebug.so'
@nini
nini / pdo-spot-postgres.php
Last active July 12, 2017 06:54
Postgres/Spot2/DBAL BLOB read/write
<?php
//read
$conn = $this->getMapper()->connection();
$first = $this->getMapper()->first();
$db = $conn->getWrappedConnection(); //pdo
$conn->beginTransaction();
$stream = $db->pgsqlLOBOpen($first->getContent(), 'r');
$i = 0;
@nini
nini / Indexes as SQL.sql
Last active November 16, 2016 20:36
Get complete index list for particular table as SQL
select pg_get_indexdef(idx.oid)||';'
from pg_index ind
join pg_class idx on idx.oid = ind.indexrelid
join pg_class tbl on tbl.oid = ind.indrelid
left join pg_namespace ns on ns.oid = tbl.relnamespace
where tbl.relname = 'mytablename'
and ns.nspname = 'public';
@nini
nini / node.pp
Created May 18, 2016 17:25
Print string on puppet run
notify{"The string value is: ${string}": }
set $target_path /vagrant/public;
if (!-d $target_path) {
set $target_path /vagrant/public;
}
root $target_path;
location /css/ {
root /vagrant;
try_files /ecommerce/config/assets/$uri /ecommerce/config/assets/$uri/ /public/$uri /public/$uri/ @rewrite;
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
git flow feature start "$(pbpaste | tr -c '[:alnum:]' '-' | tr -s '-' '-')"