Skip to content

Instantly share code, notes, and snippets.

View shazron's full-sized avatar
😆

Shazron Abdullah shazron

😆
View GitHub Profile
@shazron
shazron / anchor_tag_replace_inappbrowser.js
Last active September 17, 2020 17:58
Anchor tag link replace for InAppBrowser (Apache Cordova)
// warning, jQuery code below
$(document).ready(function() {
var $a = $("a");
$a.click(function(x) {
x.preventDefault();
var url = $(this).attr('href');
launchUrl(url); // where launchUrl is your function that calls window.open, etc
});
@shazron
shazron / get_file_entry.js
Created February 11, 2013 23:47
Get a FileEntry
function getFileEntry(localFileSystem, filePath, onGetFileWin, onGetFileFail)
{
var onFSWin = function(fileSystem) {
fileSystem.root.getFile(filePath, {create: true, exclusive: false}, onGetFileWin, onGetFileFail);
}
var onFSFail = function(evt) {
console.log(evt.target.error.code);
}
@shazron
shazron / Upgrading_a_Cordova_Project.txt
Created March 25, 2013 23:35
Upgrading a Cordova Project
1. Create a new project
2. Copy in your www assets (keep the cordova.js that is in the new)
3. Update your .html pages that reference the cordova.js to the new one
4. Copy in your Plugin source files into the Plugins group in Xcode
5. Update config.xml with your plugin mappings, access tags (whitelist), and application preferences
6. Copy in any [App]-Info.plist settings that you had before (99.99999% of the cases you can just copy it over if you created the new project with the same settings)
7. localization files - copy those folder over and register them in XCode - as we have the app in 4 languages
8. icons - overwrite the cordova ones and re-register them in XCode
9. splashscreens - ditto
@shazron
shazron / index.html
Created May 23, 2013 22:01
RequireJS with Cordova example (index.html)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
<body>
@shazron
shazron / app.js
Created May 23, 2013 22:03
RequireJS with Cordova example (app.js)
requirejs(['cordova.js'],
function () {
// start of require
// cordova is now available globally
var exec = cordova.require('cordova/exec');
var app = {
// Application Constructor
#if __has_feature(objc_arc)
AudioServicesCreateSystemSoundID((__bridge CFURLRef)audioPath, &completeSound);
#else
AudioServicesCreateSystemSoundID((CFURLRef)audioPath, &completeSound);
#endif
<div class="wrap">
<input type="checkbox" id="s1" />
<label class="slider-v1" for="s1"></label>
<input type="checkbox" id="s2" checked="" />
<label class="slider-v1" for="s2"></label>
</div><!--/wrap-->
<div class="wrap">
@shazron
shazron / list_app_ids_in_provisioning_profiles.sh
Last active December 20, 2015 07:29
List app ids contained in Provisioning Profiles installed on your system. So you can grep for a bundle id.
#!/bin/bash
# You could also launch Xcode Organizer directly to the Provisioning Profiles section (to check for validity) by running:
# open ~/Library/MobileDevice/Provisioning\ Profiles/*
#
# In Xcode 5, you can't get a whole list anymore in Xcode Organizer - you will need to download the iPhone Configuration Utility.
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
@shazron
shazron / get_bundle_id.sh
Last active August 24, 2021 12:31
Get the bundle id of an Xcode project. Run this in the same location of your .xcodeproj file
#!/bin/bash
# Run this in the same location as your .xcodeproj file
plutil -convert json -r -o - `xcodebuild -showBuildSettings | grep PRODUCT_SETTINGS_PATH | awk -F ' = ' '{print $2}'` | grep CFBundleIdentifier | awk -F ' : ' '{print $2}' | cut -d'"' -f2
@shazron
shazron / list_iphone_certs.sh
Created July 27, 2013 08:13
List the iOS Developer certs in your keychain.
#!/bin/bash
security find-identity | sed -n 's/.*\("[^"]*"\).*/\1/p' | grep 'iPhone'