Skip to content

Instantly share code, notes, and snippets.

View EddyVerbruggen's full-sized avatar
🔌
plugged in

Eddy Verbruggen EddyVerbruggen

🔌
plugged in
View GitHub Profile
@EddyVerbruggen
EddyVerbruggen / Tweet-a-selfie
Created April 13, 2015 06:01
Tweet a selfie with the Cordova SocialSharing plugin
navigator.camera.getPicture(
function(base64EncodedImg) {
// wrap in a timeout so the native view of SocialSharing doesn't collide with the one from the camera plugin
setTimeout(function() {
window.plugins.socialsharing.shareViaTwitter('Check my latest selfie. I\'m awesome!', 'data:image/jpg;base64,'+base64EncodedImg, null, null, null);
}, 500);
},
function(msg) {
alert("Error: " + msg);
},
@EddyVerbruggen
EddyVerbruggen / yourapp.plist
Last active September 11, 2015 19:03
Whitelist your server for iOS9 non-HTTPS communication
<!--
When building with XCode 7 (iOS9 SDK), Apple restricts communication to SSL servers only.
See https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/
You can override this if you need to.
If you know which servers your app talks to, look for 'NSExceptionDomains' on the page above.
But if you need to whitelist everything (not recommended) add this to your app's .plist:
-->
angular.module('sfViewCtrlDirective', [])
.directive('open', OpenDirective);
function OpenDirective() {
return {
restrict: 'A',
link: function($scope, $element, $attr) {
console.log('device is ready');
$element.on('click', function() {
Run this in your Mac Terminal (assuming you have the Ionic CLI):
----------------------------------------------------------------
ionic start wkwebviewpolyfilltest
cd wkwebviewpolyfilltest
ionic setup sass
ionic platform add ios
ionic plugin add https://github.com/EddyVerbruggen/cordova-plugin-wkwebview
ionic build
----------------------------------------------------------------
@EddyVerbruggen
EddyVerbruggen / app.js
Last active June 20, 2016 06:20
NativeScript 3D Touch shortcut icons
// Open your app's main js file and add this handler (delimited by 'START 3DTouch wiring' and 'END 3DTouch wiring').
// Then tweak the handling of 'shortcutItem.type' to your liking (here I'm deeplinking 'compose' to the 'compose' page and ignore other shortcut types).
var application = require("application");
application.cssFile = "./app.css";
application.mainModule = "main-page";
// START 3DTouch wiring
var MyDelegate = (function (_super) {
@ivanbuhov
ivanbuhov / app.css
Last active January 4, 2017 15:05
Proof of concept NativeScript app whcih is using HomeKit API
.title {
font-size: 30;
horizontal-align: center;
margin:20;
}
button {
font-size: 42;
horizontal-align: center;
}

A Very Rough Guide to Firebase and NativeScript

Create Plugin

  • mkdir nativescript-firebase
  • cd nativescript-firebase
  • npm init
  • tns init
  • mkdir -p platforms/ios
  • touch platforms/ios/Podfile
@EddyVerbruggen
EddyVerbruggen / nativescript-is24HourFormat.ts
Last active September 12, 2017 06:36
Determine whether or not an iOS or Android device is running in 24 hour format
import { ad } from "tns-core-modules/utils/utils";
import { isIOS } from "tns-core-modules/platform";
let is24HourFormat: boolean;
if (isIOS) {
// solution from https://stackoverflow.com/a/12236693/2596974
const dateFormat: string = NSDateFormatter.dateFormatFromTemplateOptionsLocale("j", 0, NSLocale.currentLocale);
is24HourFormat = dateFormat.indexOf("a") === -1;
} else {
// https://developer.android.com/reference/android/text/format/DateFormat.html#is24HourFormat(android.content.Context)
@NathanWalker
NathanWalker / app.component.ts
Last active December 13, 2017 15:54
NativeScript: Wire up RadSideDrawer from 'nativescript-telerik-ui' with Angular2 taking full advantage of Router
// angular
import {Component} from '@angular/core';
@Component({
moduleId: module.id,
selector: 'app',
template: `
<StackLayout>
<page-router-outlet></page-router-outlet>
</StackLayout>
@EddyVerbruggen
EddyVerbruggen / nativescript-segmentedbar-selected-text-color.ts
Last active December 19, 2017 11:38
Change the text color of the selected item in a NativeScript SegmentedBar
import { Color } from "tns-core-modules/color";
declare const UIControlStateSelected: any;
export class CheckoutComponent implements OnInit {
// this assumes you have this in your html: <SegmentedBar #paymentOptionsBar ..>
@ViewChild("paymentOptionsBar") paymentOptionsBar: ElementRef;
ngOnInit(): void {