Skip to content

Instantly share code, notes, and snippets.

View wiesys's full-sized avatar

Viesturs Knopkens wiesys

View GitHub Profile
@hoyelam
hoyelam / share_sheet_swiftui_example.swift
Created January 26, 2021 19:07
Share Sheet UIActivityViewController within SwiftUI
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Text("Hello, world!")
.padding()
.shareSheet(items: ["Hello world!"])
Text("Hello, world!")
SELECT todo_lists.id AS id,
todo_lists.name,
jsonb_agg(to_jsonb(todo_items) - 'todo_list_id') AS items
FROM todo_lists
LEFT JOIN todo_items ON todo_items.todo_list_id = todo_lists.id
GROUP BY todo_lists.id;
@bdaley
bdaley / woocommerce-settings-tab-demo.php
Created January 20, 2018 00:48 — forked from BFTrick/woocommerce-settings-tab-demo.php
A plugin demonstrating how to add a WooCommerce settings tab.
<?php
/**
* Plugin Name: WooCommerce Settings Tab Demo
* Plugin URI: https://gist.github.com/BFTrick/b5e3afa6f4f83ba2e54a
* Description: A plugin demonstrating how to add a WooCommerce settings tab.
* Author: Patrick Rauland
* Author URI: http://speakinginbytes.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
@tmaclean-LV
tmaclean-LV / index.js
Last active September 23, 2021 14:16
Control user access to models in Keystone.js
// Place this with the other middleware inclusion in routes/index.js
keystone.pre('admin', middleware.enforcePermissions);
@pierrejoubert73
pierrejoubert73 / psql-import-db-dump.md
Last active March 12, 2024 06:06
How to import a dump file in PSQL.

Open terminal.

Connect to psql:

psql -p 5433

I find it easier to delete and recreate the DB to which you want to import. So ensure the databse you want to delete is listed:

\l

@ethaizone
ethaizone / redirect_mobile_to_app_store.php
Last active May 24, 2022 17:56
[PHP] Auto redirect to app store. (Android/IOS)
<?php
// android store
if (preg_match('#android#i', $_SERVER ['HTTP_USER_AGENT'])) {
header('Location: market://details?id=com.google.android.apps.maps');
exit;
}
// ios
if (preg_match('#(iPad|iPhone|iPod)#i', $_SERVER ['HTTP_USER_AGENT'])) {
@nazroll
nazroll / gsutil_cron_example.sh
Last active October 13, 2022 21:20
A shell script example to run "gsutil" as a cronjob
#! /bin/bash
# Replace "/path/to/gsutil/" with the path of your gsutil installation.
PATH="$PATH":/path/to/gsutil/
# Replace "/home/username/" with the path of your home directory in Linux/Mac.
# The ".boto" file contains the settings that helps you connect to Google Cloud Storage.
export BOTO_CONFIG="/home/username/.boto"
# A simple gsutil command that returns a list of files/folders in your bucket.
@atomtigerzoo
atomtigerzoo / wordpress-split-content-at-more-shortcode.php
Last active August 30, 2023 05:41
Wordpress: split the_content into parts at more-shortcode
function atz_split_content_at_more(){
// Split the content
$content_parts = preg_split('/<span id="more-\d+"><\/span>/i', get_the_content());
// Grab first part of content and apply filters
$result['intro'] = apply_filters('the_content', array_shift($content_parts));;
// Content has a more part?
if(!empty($content_parts)):
$result['more'] = apply_filters('the_content', implode($content_parts));
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Xcode-ish</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@bmcalister
bmcalister / wordpress-nested-nav.php
Last active March 6, 2023 13:07
One dimensional wordpress nav object to nested array
<?php
class Nested_nav {
public $wp_nav;
public $nested_nav;
function __construct($menu, $args = null) {
$this->wp_nav = wp_get_nav_menu_items($menu, $args);
$this->nested_nav = $this->buildTree( $this->wp_nav );