Skip to content

Instantly share code, notes, and snippets.

@AlmogBaku
AlmogBaku / install-new-env.md
Last active March 2, 2024 19:22
New environment

Installations required on a new environment

  1. Install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Install Xcode Command Line Tools
    1.  xcode-select --install
@AlmogBaku
AlmogBaku / README.md
Last active October 17, 2021 19:39
Filter OpenAPI JSON by tags

Usage

node filter.js <swagger.json> <tags,seperated,by,commas>

How does it work?

  1. Iterate over the ".paths"
  2. If has relevant tag, keep it. Otherwise, delete it
  3. For relevant paths: recursively fetch for references
  4. Recurcively look for references in the "definitions", and build a complete reference map
@AlmogBaku
AlmogBaku / encoder.go
Created October 9, 2021 09:50
Sarama protobuf encoder
package protoencoder
import (
"github.com/Shopify/sarama"
"google.golang.org/protobuf/proto"
)
type encoder struct {
msg proto.Message
}
@AlmogBaku
AlmogBaku / bitly.go
Last active May 8, 2024 15:36
Golang Bitly: simple, stupid shortener written in go
package bitly
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
const BaseURL = "https://api-ssl.bitly.com/v4"
@AlmogBaku
AlmogBaku / new_es_schema.json
Created September 23, 2016 20:27
New ElasticSearch Sink schema
{
"heapster-2016.09.23": {
"aliases": {
"heapster-cpu-2016.09.23": { },
"heapster-events-2016.09.23": { },
"heapster-filesystem-2016.09.23": { },
"heapster-general-2016.09.23": { },
"heapster-memory-2016.09.23": { },
"heapster-network-2016.09.23": { }
},
@AlmogBaku
AlmogBaku / main.go
Created May 21, 2016 12:05
Sample HTTP Server written in Go
ackage main
import (
"fmt"
"io"
"net/http"
)
func hello(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Hello world!")
@AlmogBaku
AlmogBaku / leveledlogger.go
Last active May 18, 2016 23:23
LeveledLogger
package leveledlogger
import (
"github.com/go-kit/kit/log"
)
type LogLevel int
const (
Off LogLevel = iota
@AlmogBaku
AlmogBaku / order_ps_res.sh
Last active December 30, 2015 12:05
Order photoshop exported resources for android
#!/bin/bash
res_organize() {
res_dir=$1
res_suffix=$2
if [ ! -d "./${res_dir}" ]; then
mkdir ./${res_dir}
fi;
@AlmogBaku
AlmogBaku / PatchedOAuth2.php
Created December 6, 2015 00:29
Patched OAuth Server to allow `password` grant without secret
<?php
/**
* Created by PhpStorm.
* User: AlmogBaku
* Date: 04/12/2015
* Time: 3:13 PM
*/
namespace Rimoto\ApiBundle\Security;
@AlmogBaku
AlmogBaku / IndicatorAggregator.java
Created May 14, 2015 21:40
Indicator Aggregation for PageViewIndicator
package net.rimoto.android.utils;
import android.support.v4.view.ViewPager;
import com.viewpagerindicator.PageIndicator;
import java.util.ArrayList;
/**
* Indicator Aggregator
*/
public class IndicatorAggregator implements PageIndicator {