Skip to content

Instantly share code, notes, and snippets.

View cooper6581's full-sized avatar

Dustin Koupal cooper6581

  • Placerville, California
View GitHub Profile
@mock.patch.object(cell_mapping.CellMapping, '_get_by_uuid_from_db')
def test_non_formatted_url_with_base(self, mock_get):
# Make sure we just pass through the template URL if the base
# URLs are set, i.e. we don't try to format the URL to a template.
url = 'foo{'
self.flags(transport_url=url)
self.flags(connection=None, group='database')
db_mapping = get_db_mapping(transport_url=url,
database_connection=url)
mock_get.return_value = db_mapping
@cooper6581
cooper6581 / TestLogging.java
Last active October 11, 2017 17:03
LOG4J2-1311 SocketReader
package org.apache.logging.log4j;
import org.apache.logging.log4j.core.LoggerContext;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URISyntaxException;
package net.pyralis;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class TestLogging {
public static void main(String[] args) throws InterruptedException {
Logger logger = LogManager.getLogger("TestLogger");
for (int i = 0; i < 10; i++) {
Thread.sleep(1000);
@cooper6581
cooper6581 / Test.scala
Last active May 3, 2017 06:05
Spark 1.6.3 FileNotFoundException
import org.apache.hadoop.fs.{FileSystem,Path}
import org.apache.hadoop.conf.Configuration
val fs = FileSystem.get(new Configuration())
case class TestRecord(a: String, part: Int)
val df = Seq(TestRecord("one", 1), TestRecord("two", 2), TestRecord("three", 2)).toDF
df.write.partitionBy("part").parquet("/tmp/test_data")
sqlContext.sql("create external table foo (a string) partitioned by (part int) stored as parquet location '/tmp/test_data'" )
sqlContext.sql("alter table foo add partition (part=1)")
@cooper6581
cooper6581 / stacktrace.txt
Created August 25, 2016 01:24
ssl stacktrace
Program counter: 0x00007f8a6b7b0988 (gen:do_call/4 + 416)
CP: 0x0000000000000000 (invalid)
arity = 0
0x00007f8a27097ee0 Return addr 0x00007f8a66b07438 (gen_server:call/3 + 128)
y(0) #Ref<0.0.1.13302>
y(1) infinity
y(2) connect
y(3) '$gen_call'
y(4) <0.5333.0>
ruby {
code => "event['epoch'] = (event['@timestamp'].to_f * 1000).floor"
}
@cooper6581
cooper6581 / easy.erl
Created November 11, 2014 00:37
Daily #188 - Easy
-module(easy).
-export([test/0]).
-import(lists, [reverse/1, filter/2, keyfind/3]).
-define(MONTHS, [{"Jan", "01"}, {"Feb", "02"}, {"Mar", "03"},
{"Apr", "04"}, {"May", "05"}, {"Jun", "06"},
{"Jul", "07"}, {"Aug", "08"}, {"Sep", "09"},
{"Oct", "10"}, {"Nov", "11"}, {"Dec", "12"}]).
@cooper6581
cooper6581 / easy.erl
Last active August 29, 2015 14:07
Daily #183 - Easy
%#!/usr/bin/env escript
-mode(compile).
read_stdin() ->
case io:get_line("") of
eof ->
io:format("Error: Recieved eof, expected line~n");
Res ->
read_stdin(list_to_integer(string:strip(Res, right, $\n)), [])
end.
@cooper6581
cooper6581 / intermediate.go
Created September 26, 2014 00:29
Daily #181
package main
import (
"fmt"
"bufio"
"os"
"regexp"
"strconv"
"time"
)
@cooper6581
cooper6581 / hard.go
Created September 16, 2014 00:43
Daily #179 - Hard
package main
import (
. "code.google.com/p/goncurses"
"fmt"
"log"
"math"
"math/rand"
"time"
)