Skip to content

Instantly share code, notes, and snippets.

@begetan
begetan / code.go
Created Jul 9, 2020
AWS Lambda Describe Instances Go example
View code.go
func (app *App) describeInstances(id string, name string) ([]Node, error) {
svc := ec2.New(app.cfg)
input := &ec2.DescribeInstancesInput{
InstanceIds: []string{id},
Filters: []ec2.Filter{
{
Name: aws.String("tag:Name"),
Values: []string{name},
},
},
@begetan
begetan / sysctl.conf
Created Apr 19, 2017
Linux Ubuntu 16.04 LTS tcp tunning for best performance
View sysctl.conf
net.core.wmem_max = 8388608
net.core.rmem_max = 8388608
net.ipv4.tcp_rmem = 4096 87380 8388608
net.ipv4.tcp_low_latency = 1
# Tcp congestion protocol
net.ipv4.tcp_congestion_control=yeah
View tarantool_upsert_test.php
<?php
$tarantool = new Tarantool('localhost');
$tarantool->upsert("server",array(1,0,0,0),
array (
array(
"field" => 2,
"op" => "+",
"arg" => 1
),
@begetan
begetan / main-lpv.rs
Created Jan 11, 2017
Simple test on Rust
View main-lpv.rs
pub fn lpv(iter_num: usize, sz: usize) -> usize {
let sums: Vec<_> = (0..iter_num)
.map(|_| {
let x: Vec<_> = (0..sz).map(|i| i).collect();
let y: Vec<_> = x.iter().zip(x.iter().skip(1)).map(|(x, y)| x + y).collect();
(0..sz).step_by(100).map(|i| y[i]).sum()
})
.collect();
*sums.last().unwrap()
}
@begetan
begetan / main-go.go
Last active Jan 11, 2017
Simple test
View main-go.go
package main
import "fmt"
func main() {
var sum int64
var i int64
for e := 0; e < 20; e++ {
sum = 0
View HashMapOfInteger.java
// Simple demonstration of HashMap.
import java.util.*;
public class Test {
public static void main(String[] args) {
Random rand = new Random(47);
Map<Integer,Boolean> m =
new HashMap<Integer,Boolean>();
for(int i = 0; i < 1000000000; i++) {
m.put(rand.nextInt(30),Boolean.TRUE);
@begetan
begetan / MapOfBoolean.go
Last active Dec 18, 2016
Golang test of Map random filling
View MapOfBoolean.go
package main
import (
"fmt"
"math/rand"
)
func main() {
var set = make(map[int]bool)
@begetan
begetan / SetOfInteger.java
Created Dec 16, 2016
Test Java random filling of Set
View SetOfInteger.java
import java.util.*;
public class SetOfInteger {
public static void main(String[] args) {
Random rand = new Random(47);
Set<Integer> intset = new HashSet<Integer>();
for(int i = 0; i < 1000000000; i++)
intset.add(rand.nextInt(30));
System.out.println(intset);
}
View AdaptedRandomDoubles.java
//: interfaces/AdaptedRandomDoubles.java
// Creating an adapter with inheritance.
import java.nio.*;
import java.util.*;
public class AdaptedRandomDoubles extends RandomDoubles implements Readable {
private int count;
public AdaptedRandomDoubles(int count) {
this.count = count;
}