Skip to content

Instantly share code, notes, and snippets.

package main
import (
"bufio"
"bytes"
"io"
"strings"
"golang.org/x/term"
)
@cagedmantis
cagedmantis / append_to_value.py
Created August 4, 2018 14:45
append to a list in python
d = {"foo":[]}
for num in range(10):
for key, value in d.iteritems():
value.append(num)
d["foo"].append(23)

Keybase proof

I hereby claim:

  • I am cagedmantis on github.
  • I am exobit (https://keybase.io/exobit) on keybase.
  • I have a public key ASCvnbYMHagFsMnkfQzBszdtii5LJDnjzBh6ZE-nCmsY9Ao

To claim this, I am signing this object:

@cagedmantis
cagedmantis / http.go
Created December 27, 2017 18:05
Simple storage server
package main
import (
"fmt"
"log"
"net/http"
)
// web provides an interface for the setting and getting of
// keys via http endpoints.
resource "null_resource" "init_serf" {
count = "${var.num_nodes}"
depends_on = [ "digitalocean_droplet.serf" ]
provisioner "remote-exec" {
connection {
user = "root"
}
struct foo
{
int moo;
char c[];
};
struct bar
{
int moo;
/**
* @author Carlos Amedee <carlos.amedee@gmail.com>
*
* @brief
*
*
*/
#include <iostream>
#include <algorithm>
#!/usr/bin/env python
# -*- mode: python; tab-width: 4 -*-
# -*- coding: utf-8 -*-
#
import random
for x in range(100):
giants = []
while len(giants) < 10:
@cagedmantis
cagedmantis / gist:853698
Created March 3, 2011 21:56
Simple Calculator implementation employing a branch table
public interface Calculator {
int calculate(int valueA, int valueB);
}
public class Subtract implements Calculator {
public int calculate(int valueA, int valueB) {
return valueA - valueB;
}
# Description: Tic Tac Toe game implementation written in Ruby.
# The minmax algorithm is used to provide the AI.
class State
def initialize
@board = [[0,0,0],[0,0,0],[0,0,0]]
end
def is_empty(row, column)
if (@board[row][column] == 0)