Opengist

Explore

  • All gists
  • Topics
  • Users
Give feedback on the new UI Powered by Opengist ⋅ 45ms

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

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

all:systemctl search all fields

Login Register

All gists

All Recently liked Recently forked
Recently created Least recently created Recently updated Least recently updated
stuzer05

stuzer05 / PHP show all errors

Last active 3 months ago
0 0 1
1 ini_set('display_errors', 1);
2 ini_set('display_startup_errors', 1);
3 error_reporting(E_ALL);
stuzer05

stuzer05 / PHP build tree from sql result

Last active 3 months ago
0 0 1
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

stuzer05 / PHP create in-memory zip archive

Last active 3 months ago
0 0 1
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

stuzer05 / SQL tables to Go structs

Last active 3 months ago
0 0 3
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