Skip to content

Instantly share code, notes, and snippets.

View malcolmgreaves's full-sized avatar

Malcolm Greaves malcolmgreaves

View GitHub Profile
from botocore.credentials import RefreshableCredentials
from botocore.session import get_session
from boto3 import Session
def assumed_session(role_arn, session_name, session=None):
"""STS Role assume a boto3.Session
With automatic credential renewal.
@krishnanraman
krishnanraman / RESULTS.txt
Last active February 13, 2016 22:23
Image Detection using Statistical Moments + KMeans dominant color + Binary SVM
Dataset: COREL subset ( 7 classes, 100 images per class => 7*100 = 700 jpgs )
COREL: https://sites.google.com/site/dctresearch/Home/content-based-image-retrieval
Training Test Ratio: 80-20
Equal number of true & false samples ie. train on 80 dinos & 80 random non-dinos out of 700-100 = 600 non-dinos.
So training sample size = 80 + 80 = 160
Test sample = 20 dinos + 20 non-dinos
Train 1 SVM classifier per class => 7 SVM classifiers
@myme5261314
myme5261314 / rbm_MNIST_test.py
Last active April 10, 2020 06:59
RBM procedure using tensorflow
import tensorflow as tf
import numpy as np
import input_data
import Image
from util import tile_raster_images
def sample_prob(probs):
return tf.nn.relu(
tf.sign(
@subfuzion
subfuzion / curl.md
Last active November 20, 2025 12:10
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

object DiffieHellmanMerkle {
import java.math.BigInteger
import scala.language.implicitConversions
import scala.util.Random
def main(args: Array[String]): Unit =
println(
diffieHellmanMerkle(generator = 3, modulus = 17, alicePrivateKey = 54, bobPrivateKey = 24)
)
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

Recovering deleted files in Ubuntu with ext4 filesystem

Recently, I deleted some files by mistake in a Ubuntu machine with an ext4 fs. These notes document the steps I took to get them back.

Important

  • this procedure assumes that the partition that contained the deleted files is different from the root partition, as that was the scenario with which I had to deal (deleted files were in my home dir). The procedure needs that the partition that contained the files is unmounted, so if the deleted files were in the root partition, the process would be a bit different (e.g. storing the fs journal in a USB stick, using a live CD/USB to boot and issue the commands, etc.)
  • if something is not clear, you need more information, etc. check the sources below

With that out the way, let's begin.

@malcolmgreaves
malcolmgreaves / BinomialHypothesisTest.scala
Last active November 8, 2016 17:34
Self-contained binomial hypothesis testing. Specifically 2-tailed test at a confidence interval of 95%.
object BinomialHypothesisTest {
def tTestBinomial(p1:Double, n1:Int, p2:Double, n2:Int): TtestRes = {
val k = (n1*p1 + n2*p2) / (n1 + n2).toDouble
val z = (p1 - p2) / math.sqrt( k*(1 - k) * (1 / n1.toDouble + 1 / n2.toDouble) )
if(z > scoreForTwoTailed95CiPval)
RejectNull
else
FailToReject
}
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active September 4, 2025 01:33
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

#include <cmath>
#include <iostream>
using std::cout;
using std::endl;
float quake3_hack(float number) {
float x2 = number * 0.5f;
float y = number;
long i = *(long*) & y;