This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// install pip | |
$ wget https://bootstrap.pypa.io/get-pip.py | |
$ sudo python get-pip.py | |
// install virtualenv | |
$ sudo pip install virtualenv virtualenvwrapper | |
$ sudo rm -rf ~/.cache/pip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd ~ | |
//download and unzip opencv | |
$ wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.1.0.zip | |
$ unzip opencv.zip | |
//download and unzip opencv contributions | |
$ wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.1.0.zip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Update existings packages | |
$ sudo apt-get update | |
$ sudo apt-get upgrade | |
//Install developers tools, including cmake | |
$ sudo apt-get install build-essential cmake pkg-config | |
//Install some image I/O packages for loading images |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo apt-get install build-essential cmake pkg-config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo apt-get update | |
$ sudo apt-get upgrade |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/services/PushNotifier | |
def self.sendPush(user) | |
@message = get_message() | |
if user.notification_data_id.present? | |
@notification_data = NotificationData.find(user.notification_data_id) | |
Webpush.payload_send(endpoint: @notification_data.endpoint, | |
message: @message, | |
p256dh: @notification_data.p256dh_key, | |
auth: @notification_data.auth_key, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//app/views/content/index.html.erb | |
javascript: | |
var vapidPublicKey = new Uint8Array(#{Base64.urlsafe_decode64($vapid_public).bytes}); | |
function checkNotifs(obj){ | |
if (!("Notification" in window)) { //1 | |
console.error("This browser does not support desktop notification"); | |
} | |
// Let's check whether notification permissions have already been granted |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/assets/javascript/serviceworker.js | |
self.addEventListener("push", function(event) { | |
var title = (event.data && event.data.text().split("-")[0]) || "Message recieved"; | |
var body; body = event.data.text().split("-")[1]; | |
var tag = "push-simple-demo-notification-tag"; | |
var icon = 'logo.png'; | |
event.waitUntil( | |
self.registration.showNotification(title, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#config/initializers/serviceworker.rb | |
WebPushDemo::Application.configure do | |
config.serviceworker.routes.draw do | |
# map to assets implicitly | |
match "/serviceworker.js" | |
match "/manifest.json" | |
match "/logo.png" | |
end | |
end |