Skip to content

Instantly share code, notes, and snippets.

🇪🇪
Töötan

Dmitriy Chaban dmi3coder

🇪🇪
Töötan
Block or report user

Report or block dmi3coder

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
@dmi3coder
dmi3coder / Main.java
Last active Jun 3, 2019
Spark app serves method
View Main.java
public class Main {
public static void main(String[] args) {
initApi();
}
public static void initApi() {
port(8080);
get("/", MainResource::handleMain);
}
@dmi3coder
dmi3coder / .zshrc
Last active Mar 14, 2018
Kubernetes and Docker shell aliases
View .zshrc
# ALIASES
## Kubernetes
alias kp="kubectl get po"
alias kl="kubectl logs"
alias ks="kubectl get logs"
## Docker
alias dk="docker"
alias dks="dk ps"
alias dksn="dks --format \"table {{.ID}}\t{{.Names}}\t'dkl {{.ID}}'\t'dke {{.ID}} bash'\""
alias dki="dk images"
@dmi3coder
dmi3coder / gist:8c6686ad686e4660e1cdc024d5bc4376
Created Dec 9, 2017 — forked from liudong/gist:3993726
Java: Generate Public/Private Keys
View gist:8c6686ad686e4660e1cdc024d5bc4376
import java.security.KeyPairGenerator;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.KeyFactory;
import java.security.spec.EncodedKeySpec;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.security.spec.InvalidKeySpecException;
import java.security.NoSuchAlgorithmException;
View gist:97c7ab1cd36513e5198fc1d4f873c1a1
protocol::Note note = protocol::Note();
string name = "Buy vegetable";
string cafel = "-Apple\n-Pomodoro\n-Avocado";
note.set_name(name);
note.set_content(cafel);
note.set_id(1);
note.set_type(protocol::NoteType::BASIC);
Envelope envelope = createEnvelope(&note);
int size = envelope.ByteSize();
View gist:875c9617f4fc662f6dabb582080743e3
Note note = Note.newBuilder()
.setName("But list")
.setContent("Buy:\n"
+ "- Beer\n"
+ "- Beef\n"
+ "- Bacon\n"
+ "- Leg for C++ client part")
.setId(((long) (Math.random() * 900000000)))
.setType(NoteType.BASIC).build();
Envelope requesetEnvelope = Envelope.newBuilder().addNote(note).setType(Type.SAVE_NOTE).build();
View gist:aeb8d65488e7356aaba22c2f638f5042
message Envelope {
enum Type {
GET_ALL_NOTES = 0;
SAVE_NOTE = 1;
DELETE_NOTE = 2;
}
Type type = 1;
int64 arrivalTime = 2;
int64 id = 3;
View gist:7c6c17462d376a6726c2cdc3dd9ed92f
enum NoteType {
BASIC = 0;
REMINDER = 1;
SCRATCH = 2;
}
message Note {
int64 id = 1;
string name = 2;
int64 creationDate = 3;
View PermissionAspect.java
@Aspect
public class PermissionAspect {
@Around("execution(@DangerousPermission void *(..))")
public void beforeDangerousMethod(ProceedingJoinPoint point)
throws Throwable {
Activity activity = ((ActivityHolder) point.getThis()).getActivity();//getting Activity
MethodSignature signature = (MethodSignature) point.getSignature();
Method method = signature.getMethod();
//Taking our required permission to check
@dmi3coder
dmi3coder / FeedAdapter.java
Created Dec 2, 2016
Very bad DataBinding use
View FeedAdapter.java
package com.a8wizards.moximo_recruit_app.dashboard;
import android.databinding.DataBindingUtil;
import android.support.v4.content.ContextCompat;
import android.support.v4.util.ArrayMap;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
View manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.scores.sportium.es">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
You can’t perform that action at this time.