Skip to content

Instantly share code, notes, and snippets.

@begetan
begetan / code.go
Created July 9, 2020 17:06
AWS Lambda Describe Instances Go example
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 April 19, 2017 21:48
Linux Ubuntu 16.04 LTS tcp tunning for best performance
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
<?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 January 11, 2017 19:01
Simple test on Rust
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 January 11, 2017 18:55
Simple test
package main
import "fmt"
func main() {
var sum int64
var i int64
for e := 0; e < 20; e++ {
sum = 0
// 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 December 18, 2016 00:51
Golang test of Map random filling
package main
import (
"fmt"
"math/rand"
)
func main() {
var set = make(map[int]bool)
@begetan
begetan / SetOfInteger.java
Created December 16, 2016 11:47
Test Java random filling of Set
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);
}
//: 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;
}