Skip to content

Instantly share code, notes, and snippets.

View soulfly's full-sized avatar

Mr. software craftsman soulfly

View GitHub Profile
switchVideoinput: function(mediaDeviceId, callbacks){
// removes the video track from both MediaStream and PeerConnection sender
videoRoomPlugin.webrtcStuff.myStream.removeTrack(videoRoomPlugin.webrtcStuff.myStream.getVideoTracks()[0]);
videoRoomPlugin.webrtcStuff.pc.removeTrack(videoRoomPlugin.webrtcStuff.pc.getSenders()[1])
// does a new getUserMedia just for video
var constraints = {
audio: false,
video: {deviceId: {exact: mediaDeviceId}}
iceState: function(iceConnectionState){
if (iceConnectionState == "failed"){
restartLocalPeerConnection();
}
}
...
function restartLocalPeerConnection(){
switchVideoDevice(userVideoinputDevices[0].deviceId);
switchVideoinput: function(mediaDeviceId, callbacks){
// stop & close previous local peer
this.videoRoomPlugin.hangup(true);
// request new stream
var constraints = {
audio: true,
video: {deviceId: {exact: mediaDeviceId}}
};
class User < ApplicationRecord
validates :login, presence: true, uniqueness: true
end
class CreateUsers < ActiveRecord::Migration[5.1]
def change
create_table :users do |t|
t.string :login
t.string :full_name
@soulfly
soulfly / gist:fb0ed3e78a7333cabe39
Created July 31, 2015 15:02
QM Android lFB login issue
--------- beginning of /dev/log/system
07-31 18:00:47.675 373-373/? I/ActivityManager﹕ START u0 {act=SSO_WITH_FALLBACK cmp=com.quickblox.q_municate/com.facebook.LoginActivity (has extras)} from pid 25675
--------- beginning of /dev/log/main
07-31 18:00:47.761 25675-25675/? I/Choreographer﹕ Skipped 38 frames! The application may be doing too much work on its main thread.
07-31 18:00:47.894 25675-25675/? D/QBASDK﹕ onActivityResumed0
07-31 18:00:48.065 32566-32566/? I/Keyboard.Facilitator﹕ onFinishInput()
07-31 18:00:48.136 373-388/? I/ActivityManager﹕ Displayed com.quickblox.q_municate/com.facebook.LoginActivity: +349ms
07-31 18:00:48.565 25675-25675/? D/QBASDK﹕ onActivityStopped0
07-31 18:00:48.995 25675-25675/? D/QBASDK﹕ onActivityResumed0
07-31 18:00:49.050 25675-25675/? D/CALL_INTEGRATION﹕ construct QBVideoChatHelper
package com.quickblox.chat.model;
import android.text.TextUtils;
import com.quickblox.chat.propertyparsers.MessagePropertyParser;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.XmlStringBuilder;
# Get valid JWT public keys and save to cache
#
# Must correspond to one of the public keys listed at
# https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com
#
valid_public_keys = Rails.cache.read(VALID_JWT_PUBLIC_KEYS_RESPONSE_CACHE_KEY)
if valid_public_keys.nil?
uri = URI("https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com")
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
Thread Name: jp@gc - Stepping Thread Group 1-1
Sample Start: 2017-04-28 16:16:58 BST
Load time: 21000
Connect Time: 0
Latency: 0
Size in bytes: 773
Headers size in bytes: 0
Body size in bytes: 773
Sample Count: 1
Error Count: 1
@soulfly
soulfly / gist:fe7a2d4ac0a6125cbf151c2eaa7c4b2c
Last active February 21, 2017 09:18
QM_Android_crash_startapp
02-21 11:18:00.684 18925-18925/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.quickblox.q_municate, PID: 18925
java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.Collection.isEmpty()' on a null object reference
at com.quickblox.q_municate_core.utils.ChatNotificationUtils.parseDialogFromQBMessage(ChatNotificationUtils.java:68)
at com.quickblox.q_municate_core.qb.helpers.QBChatHelper.onChatMessageReceived(QBChatHelper.java:673)
at com.quickblox.q_municate_core.qb.helpers.QBChatHelper.access$600(QBChatHelper.java:63)
at com.quickblox.q_municate_core.qb.helpers.QBChatHelper$AllChatMessagesListener.processMessage(QBChatHelper.java:740)
@soulfly
soulfly / validatesessiontoken.java
Last active February 6, 2017 10:48
validate session token
String token = BaseService.getBaseService().getToken();
Date expirationDate = BaseService.getBaseService().getTokenExpirationDate();
// save to secure storage when your application goes offline or to the background
...
// recreate session on next start app
Date currentDate = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(currentDate);