Skip to content

Instantly share code, notes, and snippets.

@gperrudin
gperrudin / ioniclist.html
Created August 21, 2015 13:05
Ionic list not refreshed
// in my controller, the function executed when a tweet is received (this works, I verified by logging the tab)
function(e) {
$scope.tweetStream.unshift(angular.fromJson(e.data))
}
// in my view
<ion-view view-title="Tweets">
<ion-content>
<div class="list">
@gperrudin
gperrudin / sse.go
Created August 20, 2015 16:18
Eventsource golang : how to detect client disconnection ?
func (sh StreamHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
es := eventsource.New(
&eventsource.Settings{
Timeout: 2 * time.Second,
CloseOnTimeout: true,
IdleTimeout: 2 * time.Second,
Gzip: true,
},
func(req *http.Request) [][]byte {
@gperrudin
gperrudin / index.html
Created August 10, 2015 15:30
Test videojs-vast-vpaid
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>SWFObject 2 dynamic publishing example page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="bin/video-js.css" rel="stylesheet">
<script src="bin/video.js"></script>
<script src="bin/swfobject.js"></script>
<link href="bin/videojs-vast-vpaid.css" rel="stylesheet">
@gperrudin
gperrudin / station.js
Created August 7, 2015 08:20
HTML5 audio blocking Ionic app
angular.module('app')
/*
Manages the global audio player with the HTML5 audio player
See HTML5 audio player API : http://www.w3schools.com/tags/ref_av_dom.asp
*/
.factory('Player', function ($rootScope, Station, Error, $document, $window) {
return {
player : $document[0].createElement('audio'),
@gperrudin
gperrudin / gist:e2b0bf09622dea09647d
Created July 8, 2015 10:13
Running shell scripts from Golang
cmdStr := "thumbnail.sh " + url
cmd := exec.Command("/bin/sh", "-c", cmdStr)
_, err := cmd.Output()
if err != nil {
println(err.Error())
return
}
@gperrudin
gperrudin / gist:d118f331a2618739a783
Created July 7, 2015 08:28
golang http.get : connection not closed
// makes a request to a service with the get parameters passed in parameter
// returns a Response struct containing the response
func getVastPlayer(v url.Values) (Response, float64, error) {
resp := Response{}
u := VAST_URL + v.Encode()
t1 := time.Now()
myresp, err := http.Get(u)
defer myresp.Body.Close()