Skip to content

Instantly share code, notes, and snippets.

View chbaranowski's full-sized avatar

Christian Baranowski chbaranowski

View GitHub Profile
@chbaranowski
chbaranowski / MongoDecodeBase64.js
Last active August 14, 2021 09:04
MongoDB query decode Base64 document property raw-data
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9+/=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/rn/g,"n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r
@chbaranowski
chbaranowski / align.scss
Last active February 5, 2018 23:10
CSS3 and HTML - Vertical Text Alignment Options
/**
* Atom text center
*/
.text--center {
text-align: center;
width: 100%
}
/**
* Atom box
@chbaranowski
chbaranowski / ContentController.java
Created October 4, 2017 19:04
SSE Spring and Angular
@RequestMapping("/api/v1/content")
@RestController
public class ContentController {
@Autowired
ContentRepository contentRepository;
private final List<SseEmitter> emitters = new ArrayList<>();
@RequestMapping(path = "/stream", method = RequestMethod.GET)
@chbaranowski
chbaranowski / http-client.ts
Created January 21, 2017 21:30
Use Angular2 Http service outside of Angular.
export class NoXSRFStrategy extends XSRFStrategy {
configureRequest(req: Request) { }
}
// HTTP configuration to use the http service outside of angular2.
const HTTP_PROVIDERS = [
{provide: XSRFStrategy, useClass: NoXSRFStrategy},
{provide: Http, useFactory:
(xhrBackend: XHRBackend, requestOptions: RequestOptions): Http =>
new Http(xhrBackend, requestOptions),
{
"name": "example-angularjs-gulp",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
@chbaranowski
chbaranowski / KeyWordAnalyzerTest.java
Last active November 27, 2015 06:46
KeyWordAnalyzerTest
import static org.mockito.Mockito.*;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
public class KeyWordAnalyzerTest {
public static class SampleData {
@chbaranowski
chbaranowski / build.gradle
Created March 26, 2015 06:40
Gradle bnd build example
buildscript {
repositories {
ivy {
url 'https://bndtools.ci.cloudbees.com/job/bnd.master/lastSuccessfulBuild/artifact/dist/bundles'
layout 'pattern', { artifact '[module]/[artifact]-[revision].[ext]' /* OSGi repo pattern */ }
}
}
dependencies { classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:3.0.0' }
}
@chbaranowski
chbaranowski / repositories.bnd
Last active August 29, 2015 14:15
ext repositories.bnd configuration for file repo
bnd-release = https://bndtools.ci.cloudbees.com/job/bnd.master/lastSuccessfulBuild/artifact/dist/bundles
-pluginpath:\
${build}/cache/biz.aQute.repository.jar;url=${bnd-release}/biz.aQute.repository/biz.aQute.repository-latest.jar
-plugin.repositories.wrapper: aQute.bnd.deployer.repository.wrapper.Plugin; \
location = "${build}/cache/wrapper"; \
reindex = true;\
augments = WORKSPACE
-runfw: org.apache.felix.framework;version='[4.6.0,4.6.0]'
-runee: JavaSE-1.8
-resolve.effective = resolve, active
-runrequires: osgi.identity;filter:='(osgi.identity=sample)'
-runbundles: \
ch.qos.logback.classic;version='[1.1.2,1.1.3)',\
ch.qos.logback.core;version='[1.1.2,1.1.3)',\
com.eclipsesource.jaxrs.jersey-all;version='[2.10.1,2.10.2)',\
com.eclipsesource.jaxrs.publisher;version='[4.1.0,4.1.1)',\
@chbaranowski
chbaranowski / raxrs.bndrun
Created February 22, 2015 17:03
bnd run configuration for an OSGi JAXRS appliaction.
-runfw: org.apache.felix.framework;version='[4.6.0,4.6.0]'
-runee: JavaSE-1.8
-resolve.effective = resolve, active
-runrequires: osgi.identity;filter:='(osgi.identity=sample)'