Skip to content

Instantly share code, notes, and snippets.

View adamski's full-sized avatar

Adam Wilson adamski

  • CodeGarden / NodeAudio
  • Bristol UK
View GitHub Profile
@adamski
adamski / needsUpdate.m
Created October 13, 2021 09:09
Check if iOS app update available
// From https://stackoverflow.com/questions/6256748/check-if-my-app-has-a-new-version-on-appstore
-(BOOL) needsUpdate{
NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString* appID = infoDictionary[@"CFBundleIdentifier"];
NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?bundleId=%@", appID]];
NSData* data = [NSData dataWithContentsOfURL:url];
NSDictionary* lookup = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
if ([lookup[@"resultCount"] integerValue] == 1){
@adamski
adamski / Callable.hpp
Created September 14, 2020 15:59
Convert a std::function to a function pointer and context pointer, for use with C API callbacks.
/**
* Usage:
* ```
* std::function<void(int32)> callback; // This should be stored as e.g. class member
* ...
* addInt32Callback (wrapCallable<int32>(callback), &callback);
* ```
* @tparam T
* @tparam Callable
* @return function pointer
@adamski
adamski / NSURLUtils.h
Created June 22, 2020 21:47
JUCE NSURL Utilities
#pragma once
#include <JuceHeader.h>
#if JUCE_IOS
class NSURLUtils
{
public:
static URL URLfromBookmark (void* bookmark);
static void* bookmarkFromURL (URL& url);
@adamski
adamski / NSDataUtils.h
Last active June 22, 2020 15:43
JUCE NSData Utilities
#pragma once
#include <JuceHeader.h>
#if JUCE_IOS
class NSDataUtils
{
public:
static String toString(void* data);
static void* fromString(String dataAsString);
@adamski
adamski / OSXUIUtils.h
Last active September 27, 2019 14:53
OSXUIUtils
#pragma once
#ifdef __APPLE__
struct OSXUIUtils
{
static void setDarkTheme(void* view);
};
/*
==============================================================================
ButtonTooltipBubble.h
Created: 13 Aug 2019 2:51:47pm
Author: Adam Wilson
==============================================================================
This class is designed to add a tooltip to a Button or Button subclass.
@adamski
adamski / add_validation_doc.sh
Last active March 8, 2019 12:00
CouchDB validation docs
curl -g -X PUT http://username:password@127.0.0.1:5984/dbname/_design/validate_read_only -d \'{\"validate_doc_update\": \""$(tr -d '\n' < validate_doc_update.js | sed 's/"/\\"/g')"\"}\'
@adamski
adamski / PaddleSetup.cpp
Last active June 24, 2019 17:33
Cross-platform C++ wrapper for the Paddle licensing SDK
/*
==============================================================================
PaddleSetup.cpp
Created: 23 Sep 2017 9:15:20pm
Author: Adam Wilson
==============================================================================
*/
@adamski
adamski / MTCEmitter.cpp
Created December 9, 2017 21:12
JUCE MTC Classes
//
// MTCEmitter.cpp
// XDAT
//
// Created by Arvid Rosén on 2012-02-09.
// Copyright (c) 2012 Arvid Rosén. All rights reserved.
//
#include <iostream>
#include "MTCEmitter.h"
@adamski
adamski / CenteredEditableLabel.h
Last active November 4, 2021 14:56
JUCE Label with centred TextEditor (single line)
/*
==============================================================================
CenteredEditableLabel.h
Created: 4 May 2017 10:37:43am
Author: Adam Wilson
==============================================================================
*/