All New

user:thomas gists created by user

title:mygist gists with given title

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

Register

Login


All New Register Login

All gists

Recently created
Least recently created
Recently updated
Least recently updated
stuzer05's Avatar

stuzer05 / PHP build tree from sql result

0 likes
0 forks
1 files
Last active 2 years ago
1 function buildTree(array $elements, $parentId = 0) {
2 $branch = array();
3
4 foreach ($elements as $element) {
5 if ($element['parent_id'] == $parentId) {
6 $children = buildTree($elements, $element['id']);
7 if ($children) {
8 $element['children'] = $children;
9 }
10 $branch[] = $element;
stuzer05's Avatar

stuzer05 / PHP create in-memory zip archive

0 likes
0 forks
1 files
Last active 2 years ago
1 $tmp_file = tmpfile();
2 $tmp_file_path = stream_get_meta_data($tmp_file)['uri'];
3
4 $zip = new ZipArchive;
5 $res = $zip->open($tmp_file_path, ZipArchive::CREATE);
6
7 foreach ($ptah_p7s->Signs as $i => $sign) {
8 $zip->addFromString("signature{$i}.p7s", base64_decode($sign));
9 }
stuzer05's Avatar

stuzer05 / SQL tables to Go structs

0 likes
0 forks
3 files
Last active 2 years ago
1 SELECT
2 'type ' || table_name || ' struct {' || CHR(10) || fields || CHR(10) || '}' AS models
3 FROM
4 (
5 SELECT
6 table_name,
7 REPLACE(RTRIM(XMLAGG(XMLELEMENT(E, CHR(9) || column_name || CHR(9) || type_info || CHR(9) || annotation || CHR(10))).EXTRACT('//text()').GETCLOBVAL(), CHR(10)), '"', '"') AS fields
8 FROM
9 (
10 SELECT
Newer Older

Powered by Opengist ⋅ Load: 107ms⋅

English
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文