Skip to content

Instantly share code, notes, and snippets.

Avatar
💩
hacking hacking hacking!

Matthias Wessendorf matzew

💩
hacking hacking hacking!
View GitHub Profile
View Server.java
package net.wessendorf.undertow;
import io.undertow.Undertow;
import io.undertow.server.handlers.resource.FileResourceManager;
import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer;
import java.io.File;
import java.util.logging.Logger;
import static io.undertow.Handlers.resource;
View WS-Java.md

Plain WS works, pretty simple:

final WebSocketClient wsc = new WebSocketClient(new URI("ws://echo.websocket.org")) {
    @Override
    public void onOpen(ServerHandshake handshakedata) {
      System.out.println("connected");
    }

    @Override
View WebSucket.java
final WebSocketContainer container = ContainerProvider.getWebSocketContainer();
final URI securedEndpointURL = new URI("wss://echo.websocket.org");
container.connectToServer(new Endpoint() {
@Override
public void onOpen(Session session, EndpointConfig config) {
System.out.println("Connected!!!!!");
}
//}, ClientEndpointConfig.Builder.create().build(), securedEndpointURL);
}, securedEndpointURL); // ah !!! :-)
View AppDelegate.m
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
UILocalNotification *notification = [[UILocalNotification alloc]init];
notification.repeatInterval = NSDayCalendarUnit;
[notification setAlertBody:@"Wake up! You lost a billion in stocks already!"];
[notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:1]];
[notification setTimeZone:[NSTimeZone defaultTimeZone]];
[application setScheduledLocalNotifications:[NSArray arrayWithObject:notification]];
completionHandler(UIBackgroundFetchResultNewData);
View gist:9115284

User Foo has these friends:

  • mr_wolf
  • marcellus.Wallace

Now something w/ Foo happened, and all the friends need to be send a mobile push notification.

curl -3 -u "{PushApplicationID}:{MasterSecret}"
   -v -H "Accept: application/json" -H "Content-type: application/json"
   -X POST
@matzew
matzew / A_PasswordEncryption.java
Last active Aug 29, 2015
Simple AeroGear Crypto Example
View A_PasswordEncryption.java
package net.wessendorf.aerogear;
import org.jboss.aerogear.AeroGearCrypto;
import org.jboss.aerogear.crypto.password.DefaultPbkdf2;
import org.jboss.aerogear.crypto.password.Pbkdf2;
import org.junit.Before;
import org.junit.Test;
import java.security.spec.InvalidKeySpecException;
View MyAppDeletage.m
// When the program is in the foreground, this callback receives the Payload of the received Push Notification message
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
// 'userInfo' contains information related to the remote notification.
//NSString *alertValue = [userInfo valueForKeyPath:@"aps.alert"];
NSLog(@"\nForeground: %@\n", userInfo);
}
@matzew
matzew / Cordova.md
Created Mar 17, 2014
Cordova Photo Picker
View Cordova.md
  1. cordova plugin add org.apache.cordova.camera

  2. simple HTML

	<img style="display:none;width:400px;height:400px;" id="bildcken" src="" />
	<button onclick="takePhoto();">TAKE IT</button>

And the required JS:

View gist:10022025
17:02:22,634 INFO [org.keycloak.services.managers.AuthenticationManager] (http--127.0.0.1-8080-6) authenticateCookie could not find cookie: KEYCLOAK_ADMIN_CONSOLE_IDENTITY
17:02:22,657 WARN [org.jboss.resteasy.core.ExceptionHandler] (http--127.0.0.1-8080-6) Failed executing GET /realms/UnifiedPushServer/tokens/login: org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data of type: org.keycloak.services.ClientConnection
at org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:54) [resteasy-jaxrs-3.0.6.Final.jar:]
at $Proxy98.getRemoteAddr(Unknown Source) at org.keycloak.services.resources.RealmsResource.createAudit(RealmsResource.java:129) [keycloak-services-1.0-beta-1-SNAPSHOT.jar:]
at org.keycloak.services.resources.RealmsResource.getTokenService(RealmsResource.java:71) [keycloak-services-1.0-beta-1-SNAPSHOT.jar:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_09]
at sun.reflect.NativeMethodAccessorImpl
View gist:10665555
<dependency>
<groupId>org.jboss.aerogear</groupId>
<artifactId>unifiedpush-java-client</artifactId>
<version>0.5.0</version>
</dependency>