Skip to content

Instantly share code, notes, and snippets.

View dovidkopel's full-sized avatar

Dovid Kopel dovidkopel

View GitHub Profile
@buroz
buroz / main.go
Created November 25, 2020 10:11
Generics in Golang
package main
import (
"encoding/json"
"fmt"
"io"
"os"
)
type Company struct {
#!/bin/bash
set -e
echo 'Loading docker cache...'
mkdir -p $IMAGE_CACHE_ROOT
DOCKER_IMAGES_CACHE=`mktemp`
find $IMAGE_CACHE_ROOT -name *.tar.gz > $DOCKER_IMAGES_CACHE
while read file; do
#/bin/bash
set -e
mkdir -p $IMAGE_CACHE_ROOT
DOCKER_IMAGES_NEW=`mktemp`
docker images -a -q --no-trunc | awk -F':' '{print $2}' | sort | uniq > $DOCKER_IMAGES_NEW
DOCKER_IMAGES_CACHE=`mktemp`
find $IMAGE_CACHE_ROOT -type f -name *.tar.gz | xargs -n1 basename | awk -F. '{print $1}' | sort | uniq > $DOCKER_IMAGES_CACHE
@kitwalker12
kitwalker12 / images.xml
Last active June 17, 2023 12:08
Amazon MWS Beauty Product Feed XML Sample
<?xml version="1.0" encoding="utf-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>AXXXXXXXXXX</MerchantIdentifier>
</Header>
<MessageType>ProductImage</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
@d-schmidt
d-schmidt / rangemap.go
Last active May 4, 2021 06:06
Simple golang RangeMap implementation for sorted, not overlapping ranges of integers (like IP address ranges). Elements are found using binary search.
package main
import (
"fmt"
"sort"
)
type Range struct {
L int
U int
@konstantin-morenko
konstantin-morenko / list-categories-count.liquid
Last active January 21, 2021 14:49 — forked from Phlow/list-categories-count.liquid
Jekyll: List all categories with according post count and show and link all post items listed in the according category
<h2>Categories</h2>
<ul>
{% assign categories_list = site.categories %}
{% if categories_list.first[0] == null %}
{% for category in categories_list %}
<li><a href="#{{ category }}">{{ category | capitalize }} ({{ site.tags[category].size }})</a></li>
{% endfor %}
{% else %}
{% for category in categories_list %}
<li><a href="#{{ tag[0] }}">{{ category[0] | capitalize }} ({{ category[1].size }})</a></li>
@alyssaq
alyssaq / 1. Install python3.7 & pip3.md
Last active April 11, 2023 02:13
Python3.7 setup on Mac 10.14 (Mojave)
  1. Install Python 3.7.x from https://www.python.org/downloads/ or via homebrew.
$ brew install python3   # Installed at /usr/local/Cellar/python3

Check that python3 has been installed by running it at the terminal:

$ python3
>>> Python 3.7.2
  1. Download get-pip.py from https://bootstrap.pypa.io/get-pip.py and install (this should already be installed if python was installed from python.org or homebrew):
@mbedward
mbedward / gist:6e3dbb232bafec0792ba
Last active September 26, 2021 14:08
Scala macro to convert between a case class instance and a Map of constructor parameters. Developed by Jonathan Chow (see http://blog.echo.sh/post/65955606729/exploring-scala-macros-map-to-case-class-conversion for description and usage). This version simply updates Jonathan's code to Scala 2.11.2
import scala.language.experimental.macros
import scala.reflect.macros.blackbox.Context
trait Mappable[T] {
def toMap(t: T): Map[String, Any]
def fromMap(map: Map[String, Any]): T
}
object Mappable {
@metasim
metasim / ScalaInterpreterExample.java
Last active November 6, 2017 10:02
Demo code for defining a scala class dynamically (as string) and load it into Java.
package eri;
import scala.collection.Iterator;
import scala.collection.JavaConversions;
import scala.collection.Seq;
import scala.reflect.internal.util.BatchSourceFile;
import scala.reflect.io.AbstractFile;
import scala.runtime.AbstractFunction1;
import scala.runtime.BoxedUnit;
import scala.tools.nsc.GenericRunnerSettings;
@emersonf
emersonf / s3etag.sh
Last active March 27, 2024 10:11
A Bash script to compute ETag values for S3 multipart uploads on OS X.
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 file partSizeInMb";
exit 0;
fi
file=$1
if [ ! -f "$file" ]; then