Skip to content

Instantly share code, notes, and snippets.

View soulfly's full-sized avatar

Mr. software craftsman soulfly

View GitHub Profile
@soulfly
soulfly / QuickBlox signature generation example
Created December 12, 2012 13:28
QuickBlox signature generation example
// make query
long timestamp = System.currentTimeMillis()/1000;
int nonce = new Random().nextInt();
String signatureParams = String.format("application_id=%s&auth_key=%s&nonce=%s&timestamp=%s&user[login]=%s&user[password]=%s",
QBQueries.APPLICATION_ID, QBQueries.AUTH_KEY, nonce, timestamp, "test", "test");
String signature = null;
try {
signature = Signature.calculateHMAC_SHA(signatureParams, QBQueries.AUTH_SECRET);
} catch (SignatureException e) {
public class TwitterAuthScreen extends MainScreen implements Constants
{
private TwitterAuthScreen me;
private BrowserField browserField;
private ProtocolController protocolController;
private BrowserFieldErrorHandler browserFieldErrorHandler;
private BrowserFieldConfig browserFieldConfig = new BrowserFieldConfig();
private String twitterCookie = "";
private String twittwerAuthURL = "";
private TwitterPoster twitterPoster = null;
public class TwitterQBAuth implements QBHTTPAnswerListener
{
private String TOKEN = "";
private String timestamp = "";
private String BROWSER_SESSION = "";
private String TWITTER_AUTH_URL = "";
private final String QB_APP_ID = "341";
private final String QB_AUTH_KEY = "nhsOHKDNqwvpuDV";
private final String QB_AUTH_SECRET = "evPuQba3jC3Q6AX";
/**
* Post message to Twitter
*/
private boolean postTwitt(UserAccountManager _userAccMan, String _message) {
try {
Tweet uT = new Tweet(_message);
TweetER tTR = TweetER.getInstance(_userAccMan);
tTR.post(uT);
return true;
} catch (IllegalArgumentException iAE) {
QBAuth.createSession(new QBCallbackImpl() {
@Override
public void onComplete(Result result) {
// result comes here
// check if result success
if (result.isSuccess()) {
// do stuff you need
}
}
});
def update_record
json_data = JSON.parse(params["record"]["json_body"])
data = CustomData.where(:id => params["record"]["id"], :application_id => @current_app.id).first
authorize! :update, data
data.update_attributes typify_hash(json_data)
if json_data["user_id"] != data.user_id
begin
user = User.find(json_data["user_id"].to_i)
data.user_id = user.id if (user.account_id == @current_user.account_id)
- (void) captureStillImage
{
AVCaptureConnection *stillImageConnection = [AVCamUtilities connectionWithMediaType:AVMediaTypeVideo fromConnections:[[self stillImageOutput] connections]];
if ([stillImageConnection isVideoOrientationSupported])
[stillImageConnection setVideoOrientation:orientation];
[[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:stillImageConnection
completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
ALAssetsLibraryWriteImageCompletionBlock completionBlock = ^(NSURL *assetURL, NSError *error) {
@soulfly
soulfly / gist:7640054
Last active December 29, 2015 07:59
rooms
<iq type="result" id="561002161" xmlns="jabber:client" to="605901-4679@chat.quickblox.com" from="muc.chat.quickblox.com">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="4679_testflight_time@muc.chat.quickblox.com" name="TestFlight time"/>
<item jid="4679_does_this_work?@muc.chat.quickblox.com" name="Does this work?"/>
<item jid="4679_not_literlly,_it_delted@muc.chat.quickblox.com" name="Not literlly, it delted"/>
<item jid="4679_chattin_like_a_mofo@muc.chat.quickblox.com" name="Chattin like a mofo"/>
<item jid="4679_pool@muc.chat.quickblox.com" name="Pool"/>
<item jid="4679_jsnsnndjdnd@muc.chat.quickblox.com" name="Jsnsnndjdnd"/>
<item jid="4679_testing_a_yapp@muc.chat.quickblox.com" name="Testing a yapp"/>
<item jid="4679_rife_high@muc.chat.quickblox.com" name="Rife high"/>
QBUser participant = new QBUser(2);
QBPrivateChatManager manager = QBChatService.getInstance().getPrivateChatManager();
manager.addChatListener(new QBChatManagerListener() {
@Override
public void chatCreated(QBChat chat) {
}
<iq id="inroom-cr92_test_room_test@muc.chat.quickblox.com" to="92_test_room_test@muc.chat.quickblox.com" type="set"><query xmlns="http://jabber.org/protocol/muc#owner"><x xmlns="jabber:x:data" type="submit"><field var="muc#roomconfig_roomname"><value>Test Room Test</value></field><field var="muc#roomconfig_persistentroom"><value>1</value></field></x></query></iq