Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Baranowski chbaranowski

View GitHub Profile
@chbaranowski
chbaranowski / MongoDecodeBase64.js
Last active Aug 14, 2021
MongoDB query decode Base64 document property raw-data
View MongoDecodeBase64.js
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 Feb 5, 2018
CSS3 and HTML - Vertical Text Alignment Options
View align.scss
/**
* Atom text center
*/
.text--center {
text-align: center;
width: 100%
}
/**
* Atom box
View ContentController.java
@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 Jan 21, 2017
Use Angular2 Http service outside of Angular.
View http-client.ts
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),
View bower.json
{
"name": "example-angularjs-gulp",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
View KeyWordAnalyzerTest.java
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 Mar 26, 2015
Gradle bnd build example
View build.gradle
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 Aug 29, 2015
ext repositories.bnd configuration for file repo
View repositories.bnd
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
View jaxrs.bndrun
-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 Feb 22, 2015
bnd run configuration for an OSGi JAXRS appliaction.
View raxrs.bndrun
-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)'