Skip to content

Instantly share code, notes, and snippets.

Piotr Mionskowski miensol

Block or report user

Report or block miensol

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@miensol
miensol / spec_helper.js
Created Mar 18, 2016
Fake Express.js Request and Response
View spec_helper.js
module.exports.request = () => {
class IncomingMessage extends require('http').IncomingMessage {
}
const request = new IncomingMessage();
request.__proto__ = require('express')().request;
return request;
};
module.exports.response = (request) => {
class ServerResponse extends require('http').ServerResponse {
}
@miensol
miensol / JpaJsonConverter.java
Last active Mar 22, 2019
Jpa Json Converter
View JpaJsonConverter.java
package sample.json;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.google.common.reflect.TypeToken;
import sample.json.Json;
import org.springframework.util.StringUtils;
import javax.annotation.Nonnull;
View StackQuesion_34773958.kt
package sample.stackanswers;
import android.app.Activity
import org.junit.Assert
import org.junit.Before;
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith;
import org.mockito.*
import org.mockito.junit.MockitoJUnit
View RetrofitTest.java
public class RetrofitTest {
@Test
public void configure() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.registerModule(new JodaModule());
Retrofit retrofit = new Retrofit.Builder()
@miensol
miensol / MsdnExample.cs
Created Dec 25, 2015
SimpleConfigSections samples
View MsdnExample.cs
public class PageAppearanceSection : ConfigurationSection<IPageAppearance>
{
}
public interface IPageAppearance
{
bool RemoteOnly { get; }
IFont Font { get; }
IColor Color { get; }
}
@miensol
miensol / aws-elasticbeanstalk-ec2-role-trust.json
Created Dec 15, 2015
ElasticBeanstaclk Default IAM Policies
View aws-elasticbeanstalk-ec2-role-trust.json
{
"Version": "2008-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
View RegisterActivity.java
import pl.brightinventions.databinding.databinding.ActivityRegisterBinding;
public class RegisterActivity extends Activity {
RegisterApi registerApi; // inject or create remote api
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityRegisterBinding viewDataBinding = DataBindingUtil.setContentView(this, R.layout.activity_register);
View RegisterActivityClassic.java
interface Action2<T,Throwable> {
void call(T t, Throwable error);
}
interface RegisterApi {
class RegistrationModel {
String firstName;
}
void register(RegistrationModel data, Action2<RegistrationModel, Throwable> result);
}
View UserBehavior2.java
public abstract class UserBehavior {
private boolean shouldRunDefault;
public void byDefault(UserReference reference){}
public void onAnonymous(UserReference user){
shouldRunDefault = true;
}
public void onRegular(RegularUserReference user) {
shouldRunDefault = true;
View UserBehavior.java
interface UserReference {
void dispatchBehavior(@NonNull UserBehavior behavior);
}
class AnonymousUserReference implements UserReference {
@Override
public void dispatchBehavior(@NonNull UserBehavior behavior) {
behavior.onAnonymous(this);
}
}
You can’t perform that action at this time.