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 / Code.gs
Last active October 3, 2018 19:32
Google Apps Script that adds GitHub repo and PR labels to your Gmail inbox
function processInbox() {
var threads = GmailApp.search("is:unread in:inbox has:nouserlabels from:notifications@github.com newer_than:1h");
for (var i = 0; i < threads.length; i++) {
var messages = threads[i].getMessages();
for (var j = 0; j < messages.length; j++) {
processMessage(messages[j]);
}
}
@EddyVerbruggen
EddyVerbruggen / radsidedrawer-component.ts
Last active September 11, 2018 10:23
Adding depth / shadow to your NativeScript RadSideDrawer (iOS)
// In case of Angular, this is the component that contains a view with a <RadSideDrawer>
export class MenuComponent implements AfterViewInit {
@ViewChild(RadSideDrawerComponent) public drawerComponent: RadSideDrawerComponent;
private _drawer: SideDrawerType;
ngAfterViewInit(): void {
this._drawer = this.drawerComponent.sideDrawer;
this._changeDetectionRef.detectChanges();
@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 {
@EddyVerbruggen
EddyVerbruggen / connectionchecker.js
Created April 11, 2014 20:33
Check for a WiFi connection in a PhoneGap app and show a message if it's not available - and stop checking
"use strict";
(function() {
var intervalID = null;
function startCheckingNetworkConnection() {
intervalID = setInterval(function() {
var networkState = navigator.connection.type;
var isWifi = networkState == Connection.WIFI;
@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)
@EddyVerbruggen
EddyVerbruggen / nativescript-apply-cssfile-at-runtime.ts
Last active June 14, 2017 09:50
App component specific tablet CSS file in NativeScript
import { Component, OnInit } from "@angular/core";
import { DeviceType } from "ui/enums";
import { device } from "platform";
import { Page } from "ui/page";
@Component({
moduleId: module.id,
selector: "my-component",
templateUrl: "my-component.html",
styleUrls: ["my-component.css"]
@EddyVerbruggen
EddyVerbruggen / nativescript-tablet-specific-styles.css
Created June 14, 2017 08:58
Tablet CSS for NativeScript apps
/* my-component.css */
Label.text {
font-size: 15;
}
/* my-component.tablet.css */
.tablet Label.text {
font-size: 19;
}
@EddyVerbruggen
EddyVerbruggen / split-view-tablets-nativescript-angular.html
Last active June 14, 2017 08:46
Split view tablet support for NativeScript with Angular
<!-- 'master' view -->
<ActionBar></ActionBar>
<GridLayout [columns]="isTablet ? '*, *' : '*'">
<StackLayout>
<!-- 'master' ListView -->
</StackLayout>
<StackLayout col="1" *ngIf="isTablet">
<!-- 'detail-contents' component, only for tablets -->
<detail-contents></detail-contents>
</StackLayout>
@EddyVerbruggen
EddyVerbruggen / is-tablet.ts
Last active June 14, 2017 07:48
Determine running on a tablet in NativeScript
// required imports:
import { DeviceType } from "ui/enums";
import { device } from "platform";
// then wherever you need it:
const isTablet: boolean = device.deviceType === DeviceType.Tablet;
@EddyVerbruggen
EddyVerbruggen / nativescript-speech-recognition-ios-plist.xml
Created March 7, 2017 10:03
Speech Recognition in NativeScript (iOS consent popup content)
<!-- Speech recognition usage consent -->
<key>NSSpeechRecognitionUsageDescription</key>
<string>My custom recognition usage description. Overriding the default empty one in the plugin.</string>
<!-- Microphone usage constent -->
<key>NSMicrophoneUsageDescription</key>
<string>My custom microphone usage description. Overriding the default empty one in the plugin.</string>