Skip to content

Instantly share code, notes, and snippets.

View dimitarvp's full-sized avatar
🏠
Working from home

Dimitar Panayotov dimitarvp

🏠
Working from home
  • Sofia, Bulgaria
View GitHub Profile

Keybase proof

I hereby claim:

  • I am dimitarvp on github.
  • I am dimitarvp (https://keybase.io/dimitarvp) on keybase.
  • I have a public key ASBdSxUelhzLTU9bJNlyRvrsYOjAyBMIkE5Fgc_sDAU-ego

To claim this, I am signing this object:

@dimitarvp
dimitarvp / play.ex
Created February 5, 2017 20:06
Elixir function modifying a destination map only if a source map has a certain key whose value is processed and stored in the destination map.
defmodule Play do
def test1 do
src = %{createdAt: "2017-01-19T08:32:26+02:00"}
dest = %{}
dest =
case Map.has_key?(src, :createdAt) do
true ->
{:ok, date, _} = DateTime.from_iso8601(src[:createdAt])
Map.put(dest, :createdAt, date)
false ->
@dimitarvp
dimitarvp / http_streamer.go
Created January 9, 2017 13:28
A dead-simple Go HTTP streamer/proxy for files hosted in a S3 bucket. NOTE 1: You will need the `AWS_ACCESS_KEY` and `AWS_SECRET_KEY` environment variables set properly in order for this script to work. NOTE 2: This creates a mini HTTP server on localhost:3001.
package main
import (
"github.com/mitchellh/goamz/aws"
"github.com/mitchellh/goamz/s3"
"log"
"net/http"
"io"
)
@dimitarvp
dimitarvp / test.rb
Created April 2, 2014 23:07
Cannot modify `request.params` in before(:all) block.
# Given this auth helper in spec/support/ directory...
module AuthHelpers
def add_token_to_params(token)
request.params.merge!({sessionToken: token}) # also tried 'request.params[:sessionToken] = token'
end
end
# Given this test...
class ThingController
describe Thing do
require 'awesome_print'
input = <<TEXT
2 1 app/assets/javascripts/bar.js
16 25 app/assets/javascripts/baz.js.coffee
1 1 app/assets/javascripts/foo.js.coffee
4 9 app/controllers/bar_controller.rb
3 2 app/controllers/baz_controller.rb
11 0 app/controllers/foo_controller.rb
3 2 db/schema.rb
@dimitarvp
dimitarvp / gemdetails.rb
Created June 18, 2011 08:32
Get online info about any gem existing at rubygems.org
# Alternative way of getting all Gem details using the official Rubygems REST API (thanks @qrush)
require 'open-uri'
require 'active_support/json'
require 'awesome_print'
ap ActiveSupport::JSON.decode(open("http://rubygems.org/api/v1/gems/#{ARGV[0]}.json"))