Skip to content

Instantly share code, notes, and snippets.

View ketola's full-sized avatar

Sauli Ketola ketola

View GitHub Profile
@ketola
ketola / KeyPair.java
Last active November 30, 2019 12:00
Libra key-pair
Security.addProvider(new BouncyCastleProvider());
KeyPairGenerator kpGen = KeyPairGenerator.getInstance("Ed25519", "BC");
KeyPair keyPair = kpGen.generateKeyPair();
PrivateKey privateKey = keyPair.getPrivate();
PublicKey publicKey = keyPair.getPublic();
@ketola
ketola / index.html
Created May 28, 2017 19:02
Importing the Web App Manifest
<head>
<link rel="manifest" href="/manifest.json">
</head>
@ketola
ketola / manifest.json
Created May 28, 2017 18:25
A Web App manifest file from mobile.twitter.com
{
"background_color":"#ffffff",
"description":"It's what's happening. From breaking news and entertainment, sports and politics, to big events and everyday interests.",
"display":"standalone",
"gcm_sender_id":"49625052041",
"gcm_user_visible_only":true,
"icons":[
{
"src":"https://ma-0.twimg.com/twitter-assets/responsive-web/web/ltr/icon-default.882fa4ccf6539401.png",
"sizes":"192x192","type":"image/png"
@ketola
ketola / app.js
Created May 27, 2017 12:40
Application registers the service worker
// check for service worker support in the browser
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js').then(function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}, function(err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
);
}
@ketola
ketola / sw.js
Last active May 27, 2017 12:46
A service worker that returns assets from cache and refreshes them afterwards
// Pre-fetch the assets when the service worker is installed
self.addEventListener('install', function(evt) {
evt.waitUntil(precache());
});
function precache() {
return caches.open(‘your-app-name-cache’).then(function (cache) {
// list all your assets in the array
return cache.addAll([
'/index.html',
@ketola
ketola / Spring Http Invoker. Export. web.xml
Created March 2, 2012 19:27
Export service with Spring Framework's http invoker.
<servlet>
<servlet-name>customerServiceExporter</servlet-name>
<servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>customerServiceExporter</servlet-name>
<url-pattern>/remoting/CustomerService</url-pattern>
</servlet-mapping>
@ketola
ketola / Spring Http Invoker. Import.
Created March 2, 2012 19:18
Import service with Spring Framework's http invoker.
<bean id="customerService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl" value="http://localhost:8081/remoting/CustomerService"/>
<property name="serviceInterface" value="com.codereanimator.spring.httpinvoke.serviceinterface.CustomerService"/>
</bean>
@ketola
ketola / Spring Http Invoker. Export.
Created March 2, 2012 19:14
Export service with Spring Framework's http invoker.
<bean id="customerService" class="com.codereanimator.spring.httpinvoke.app1.service.CustomerServiceImpl"/>
<bean name="customerServiceExporter" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service" ref="customerService"/>
<property name="serviceInterface" value="com.codereanimator.spring.httpinvoke.serviceinterface.CustomerService"/>
</bean>