Skip to content

Instantly share code, notes, and snippets.

View ahndmal's full-sized avatar
😔
stand with my homeland Ukraine

Andrii Maliuta ahndmal

😔
stand with my homeland Ukraine
View GitHub Profile
package com.ast.scripts.db
import groovy.sql.Sql
import org.ofbiz.core.entity.TransactionFactory
import org.ofbiz.core.entity.ConnectionFactory
import java.sql.Connection
Connection connection = TransactionFactory.getConnection("defaultDS")
Connection connection2 = ConnectionFactory.getConnection("defaultDS")
Get-Item -Path env:
Get-Item -Path env:JAVA_HOME
# Job
Get-Job -State Started
Get-Job -Name "ja*"
# SET
Set-Item -Path env:JAVA_HOME -Value "C:\Users\andrii\java"
Gatherer<URI, ?, String> mapToCOntents = gatherers.mapCOncurrent(16, uri -> {
try {
return fetch(uri);
} catch(IOEsception e) {
throw new UncheckedIOEsception(e);
};
String result = Stream.of(uris)
.gather(mapToContents)
## GET request
GET / HTTP/1.1
User-agent: curl/2000
Host: example.com
## GET response
HTTP/1.1 200 OK
Server: example-server/1.1
Content-Length: 5
Content-Type: plain/text
module SleighAuthenticationSpec where
import SleighAuthentication (authenticate)
import Test.Hspec
import Test.QuickCheck
spec :: Spec
spec = do
describe "authenticate" $ do
it "should work for some examples" $ do
expectTrue $ authenticate "Santa Claus" "Ho Ho Ho!"
func (b *Bus) readAndUnpack() ([]byte, error) {
n, err := io.ReadAtLeast(b.port, b.buf[:], 2)
got := b.buf[:n]
if err != nil {
return nil, newError("libzzz: cannot read 2-byte preamble [got: % 02X] - error: %w", got, err)
}
if got[0] != magic_number {
return nil, newError("libzzz: bad MAGIC NUMBER in response - message starts with: [% 02X] (expected XX...)", got)
}
length := int(got[1])
# Copyright 2017 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# Use the official lightweight Node.js 12 image.
# https://hub.docker.com/_/node
FROM node:12-slim
# Create and change to the app directory.
WORKDIR /usr/src/app
# Copy application dependency manifests to the container image.
# A wildcard is used to ensure copying both package.json AND package-lock.json (when available).
# Copying this first prevents re-running npm install on every code change.
package com.anma.java.core.nio;
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import java.util.EnumSet;
import static java.nio.file.FileVisitResult.CONTINUE;
import static java.nio.file.FileVisitResult.SKIP_SUBTREE;
use std::io::{Read, Write};
use std::{net, time};
use std::future::Future;
fn main() {
let port = 8084;
let server = net::TcpListener::bind(format!("127.0.0.1:{port}")).unwrap();