Skip to content

Instantly share code, notes, and snippets.

View tobgu's full-sized avatar

Tobias Gustafsson tobgu

  • Stockholm, Sweden
View GitHub Profile
@tobgu
tobgu / remotessh.go
Last active October 5, 2023 12:14
Remote ssh exec using Go
package main
import (
"bufio"
"fmt"
"golang.org/x/crypto/ssh"
"io"
"log"
"os"
"strconv"
package main
import (
"sync"
"fmt"
)
const MAX_CONCURRENCY = 40
const NUMBER_OF_JOBS = 1000000
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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
#
try:
raise Exception("Bang")
except Exception e:
# -- Create prepared statement and store exception information in Cassandra here --
# Re-raise exception, this works fine with protocol version 4 but fails
# with version 3 because the exception context has been cleared
raise
# Run cassandra with Jolokia to expose JMX metrics over HTTP
# Add the following to /etc/cassandra/cassandra-env.sh
JVM_OPTS="$JVM_OPTS -javaagent:/opt/jolokia/jolokia-jvm-agent.jar"
# See https://www.flexinvesting.fi/2014/jolokia-apache-cassandra/
# for more information.
# Collect information with Telegraf according to the below config.
# There's also a http json plugin that should be useful for fetching
# information from arbitrary HTTP JSON interfaces.
/* test.c */
#include <stdio.h>
#define LEN 200000000
void main() {
static int arr[LEN];
int i = 0;
int result = 0;
@tobgu
tobgu / gist:4cd1ed1c3d9c421fb5d7
Last active August 29, 2015 14:18
gobench competition
// Package bench is a package which contains
// programs of Go Benchmark Competition.
package bench
import (
"errors"
"bufio"
"os"
"fmt"
"bytes"
@tobgu
tobgu / table_scraper.py
Created February 2, 2014 14:56
Basic HTML table scraper. To be used during high level testing for example.
from collections import OrderedDict
from bs4 import BeautifulSoup
# TODO
# * Find table by ID
# * Multi column headers
# * Multi row headers
# * Table with multiple columns with the same name
from prettytable import PrettyTable
@tobgu
tobgu / gameoflife3.py
Created December 15, 2013 08:34
Set based game of life
def candidates_for(world):
return set.union(*[neighbours_of(cell) | set([cell]) for cell in world])
DIRECTIONS = {(-1, 1), (0, 1), (1, 1),
(-1, 0), (1, 0),
(-1, -1), (0, -1), (1, -1)}
def neighbours_of(cell):
x, y = cell
@tobgu
tobgu / FileDestination.java
Created May 28, 2012 17:01
Profiling with visual VM
package primegenerator;
import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
//import org.springframework.stereotype.Component;