Skip to content

Instantly share code, notes, and snippets.

View skounis's full-sized avatar

Stavros Kounis skounis

View GitHub Profile
@skounis
skounis / shoutcastionic-getCover.js
Last active October 5, 2015 11:13
Shoutcast Ionic Tutorial - getCover
function getCover(title) {
return $http.get(itunesSearchUrl + title).then(function(response) {
var item = response.data.results[0];
if (!item || !item.artworkUrl100) {
return null;
}
return item.artworkUrl100.replace(resolutionRegex, '500x500');
});
}
@skounis
skounis / shoutcastionic-getStreamInfo.js
Created October 5, 2015 11:12
Shoutcast Ionic Tutorial - getStreamInfo
function getStreamInfo() {
return $http.get(metadataUrl).then(function(response) {
var title = parseShoutcastResponse(response.data);
if (!title) {
return {};
}
return getCover(title).then(function(coverUrl) {
return {
title: title,
coverUrl: coverUrl
@skounis
skounis / shoutcastionic-services.js
Created October 5, 2015 11:14
Shoutcast Ionic Tutorial - Services
angular.module('starter.services', [])
.factory('Chats', function() {
// Might use a resource here that returns a JSON array
// Some fake testing data
var chats = [{
id: 0,
name: 'Ben Sparrow',
lastText: 'You on your way?',
@skounis
skounis / shoutcastionic-pause.js
Created October 5, 2015 11:18
Shoutcast Ionic Tutorial - Pause playback
function pause() {
vm.info = null;
$interval.cancel(timer);
if (!stream) {
return;
}
stream.stop();
}
@skounis
skounis / shoutcastionic-controler-getStreamInfo.js
Created October 5, 2015 11:20
Shoutcast Ionic Tutorial - Controller getStreamInfo
function getStreamInfo() {
streamService.getStreamInfo().then(function(info) {
vm.info = info;
}, function() {
vm.info = null;
});
}
@skounis
skounis / shoutcastionic-controller.js
Created October 5, 2015 11:21
Shoutcast Ionic Tutorial - Controller
angular.module('starter.controllers', [])
.controller('DashCtrl', function($scope) {})
.controller('ChatsCtrl', function($scope, Chats) {
// With the new view caching in Ionic, Controllers are only called
// when they are recreated or on app start, instead of every page change.
// To listen for when this page is active (for example, to refresh data),
// listen for the $ionicView.enter event:
//
@skounis
skounis / shoutcastionic-tab-stream.html
Created October 5, 2015 11:25
Shoutcast Ionic Tutorial - Stream tab
<ion-view view-title="{{vm.info.title || 'Audio Stream'}}">
<ion-content class="center" style="
background: url({{vm.info.coverUrl || 'images/ionic.png'}}) center center;
background-size: cover;">
<a class="button button-icon icon play-button-icon {{ vm.isPlaying ? 'ion-ios-pause' : 'ion-ios-play' }}"
ng-click="vm.togglePlay()"></a>
</ion-content>
</ion-view>
@skounis
skounis / network-check-cordova.js
Last active December 18, 2015 08:26
Network check workaround for android due to issue https://issues.apache.org/jira/browse/CB-10160
function getNetworkStatus() {
// On Android and when only the 3G interface is on
// the return connection type is `unknown` even the device is online.
// To work around this we will assume that only Connection.NONE
// is declaring an offline device. Which is returned when data are
// disabled.
var isPluginAvailable = !!navigator.connection;
@skounis
skounis / repair-hooks.sh
Last active February 2, 2016 16:58
Make all .js files executable recursively
#!/bin/bash
# Copy the repair-hooks.sh files into the hooks folder,
# make it executable and run it.
#
# You could always copy and paste the following command
# in the terminal, while being into the hooks folder.
find . -name '*.js' -exec chmod u+x {} \;
@skounis
skounis / resize.sh
Last active January 9, 2016 09:06
Batch Resize Images Quickly in the OS X Terminal 0 sips
# So what's happening? Well, "sips" is the command being used
# and -Z tells it to maintain the image's aspect ratio.
# "640" is the maximum height and width to be used and "*.jpg"
# instructs your computer to downsize every image ending in .jpg.
# It's really simple and shrinks your images very quickly.
# Just be sure to make a copy first if you want to preserve their
# larger size as well.
#
# http://lifehacker.com/5962420/batch-resize-images-quickly-in-the-os-x-terminal
#