Skip to content

Instantly share code, notes, and snippets.

View bonny's full-sized avatar
🇺🇦
StandWithUkraine

Pär Thernström bonny

🇺🇦
StandWithUkraine
View GitHub Profile
@bonny
bonny / 1-simple-fields-register-field-group-small-example.php
Last active July 14, 2022 11:34
Simple Fields simple_fields_register_field_group(), simple_fields_register_post_connector(), simple_fields_register_post_type_default() examplesSee http://simple-fields.com/ for more info.
<?php
// Minimal amount of code
// to create a new field group
// with one field
simple_fields_register_field_group('attachment', array(
'name' => 'Attachment',
'fields' => array(
array(
'name' => 'File',
@bonny
bonny / watson-xbar-plugin.sh
Last active January 20, 2022 16:57
xbar script for watson
#!/usr/bin/env bash
# Watson Brew Status
#
# by Antoine Corcy <contact@sbin.dk>
# updated by Pär Thernstrom <par.thernstrom@gmail.com>
# to support Watson custom location and configuration.
#
# <xbar.title>Watson Brew Status</xbar.title>
# <xbar.version>1.0</xbar.version>
<?php //version my202
//set allowTestMenu to false to disable System/Server test page
$allowTestMenu = true;
header("Content-Type: text/plain; charset=x-user-defined");
error_reporting(0);
set_time_limit(0);
function phpversion_int()
@bonny
bonny / gist:3923633
Created October 20, 2012 15:40
Dropdown Field, Extended Return Values
Array
(
[selected_value] => Dropdown 2
[selected_option] => Array
(
[value] => Dropdown 2
[key] => dropdown_num_3
[is_selected] => 1
)
@bonny
bonny / index.html
Created June 7, 2020 19:57
TextTV.nu iframe
<p>Iframe med "vanliga" texttv.nu</p>
<iframe
src="http://texttv.nu/"
title="TextTV.nu"
width="400"
height="540">
</iframe>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bonny
bonny / simple-note-osx-app-restorer.php
Last active July 24, 2017 12:48
PHP script to list and retrieve notes from the OS X Simple Notes app. Nice to have since import/sync seems buggy in first version of the app (It deleted two months of notes for me anyway, because of a crash during import.) How to: Find the file "Simplenote.storedata.xml" that is located perhaps here or in your time machine or Arq or similar: ~/L…
<meta charset="utf-8">
<title>SimpleNote Restorer</title>
<style>
body {
font-family: sans-serif;
background-color: #f5f5f5;
color: #111;
font-size: 14px;
}
li {

Keybase proof

I hereby claim:

  • I am bonny on github.
  • I am eskapism (https://keybase.io/eskapism) on keybase.
  • I have a public key ASAcBveAKwwwqxEhr3J7LhlB6sp2CiOVxdG6to9eWVgCWQo

To claim this, I am signing this object:

@bonny
bonny / ep_exclude_password_protected_pages.php
Created June 13, 2013 08:15
WordPress function that uses filter "get_pages" to add argument "exclude_password_protected=1" Adding that argument will exclude password protected pages from for example wp_list_pages. If a user has entered correct password then the page will be visible.
<?php
// modify get_pages so we can add "exclude_password_protected=1" to exclude password protected
// pages from for example wp_list_pages
// if user has entered correct password then the page will be visible
function ep_exclude_password_protected_pages($pages, $r) {
if ( isset( $r["exclude_password_protected"] ) && $r["exclude_password_protected"] ) {
for ($i = 0; $i < sizeof($pages); $i++) {
@bonny
bonny / with-posts-wordpress-function.php
Last active May 9, 2016 18:50
WordPress function with_posts(), that simplifies getting and looping posts, in a jQuery anonymous function-ish way. Setups global, restores post afterwards. Simple, flexible and powerful.
<?php
/**
* WordPress WP_QUERY-wrapper to simplify getting and working with posts
*
* Does something with posts, using a callback
* Setups global post variable before running callback
* And restores it afterwards
*
* An introductionary blogpost about this function is posted on our blog: