This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(¬e); | |
int size = envelope.ByteSize(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
initApi(); | |
} | |
public static void initApi() { | |
port(8080); | |
get("/", MainResource::handleMain); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping( | |
value = "/hello", method = GET) | |
@ResponseBody | |
public String getHelloMessage() { | |
return "hello"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app = Flask(__name__) | |
@app.route('/hello', methods=['GET']) | |
def say_hello(): | |
return 'hello' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def as_html(func): | |
def wrapper(): | |
result = func() | |
return f'<html>{result}</html>' | |
return wrapper | |
@as_html | |
def say_hello(): | |
return 'Hello' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
cached_items = {} | |
def cached(func): | |
def wrapper(*args, **kwargs): | |
global cached_item | |
if func.__name__ not in cached_items: | |
cached_items[func.__name__] = func(*args, **kwargs) | |
return cached_items[func.__name__] | |
return wrapper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
@Retention(RetentionPolicy.RUNTIME) | |
@interface Cached { } // Nothing inside our annotation | |
static class SomeObject { | |
@Cached | |
public String intensiveTask() throws InterruptedException { | |
Thread.sleep(1000); | |
return "expensive task result"; |