Skip to content

Instantly share code, notes, and snippets.

@mgiacomini
mgiacomini / new_decode.py
Created April 2, 2018 20:22
walter horning map
data = json.load(open("medidas.json"))
def is_json(myjson):
try:
json_object = json.loads(myjson)
except ValueError:
return False
return json_object
def decode_json(json):
@mgiacomini
mgiacomini / opportunities.gql
Last active March 8, 2018 18:39
Graphql example for create new opportunities
mutation {
createOpportunity(
contact: {
name: "mauricio",
email: "[email protected]",
phone: "41 995 000 315",
age: 35
},
loan_value: 100000.0,
realty_value: 200000.0,
@mgiacomini
mgiacomini / Flexible Dockerized Phoenix Deployments.md
Created February 14, 2018 17:20 — forked from jswny/Flexible Dockerized Phoenix Deployments.md
A guide to building and running zero-dependency Phoenix (Elixir) deployments with Docker. Works with Phoenix 1.2 and 1.3.

Prelude

I. Preface and Motivation

This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.

For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai

@mgiacomini
mgiacomini / clean_docker.sh
Created December 15, 2017 12:20
clean docker
#!/bin/bash
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@mgiacomini
mgiacomini / results.sh
Created November 18, 2017 19:32
results
#!/bin/bash
echo "#####" >> result.txt
echo "L3 Bandwidth" >> result.txt
for i in 32 33 64 65 128 129 256 257 512 1000 2000
do
echo $i >> result.txt
likwid-perfctr -f -C 0 -g L3 -m ./invmat -i 10 -r $i -o saida.txt | grep "L3 bandwidth" >> result.txt
#likwid-perfctr -f -C 0 -g L3 ./cgSolver $num 7 -i 10 -o saida.txt
@mgiacomini
mgiacomini / rails_fast_csv_importer.rb
Created September 10, 2017 01:15
use copy command to fast imports
db_conn = ActiveRecord::Base.connection.raw_connection
copy_statement = 'COPY forecasts FROM STDIN'
file_path = '/tmp/forecast.csv'
db_conn.copy_data(copy_statement) do
CSV.foreach(file_path, headers: true) do |row|
db_conn.put_copy_data(row.fields + [Time.zone.now])
end
end
@mgiacomini
mgiacomini / rails-postgres-backbone-bootstrap-bootswatch
Created August 16, 2017 03:40 — forked from sionc/rails-postgres-backbone-bootstrap-bootswatch
Instructions on creating a new app using Ruby on Rails, Postgresql, Backbone.js, Twitter Boostrap, Bootstwatch
- Check rails version
$ rails -v
- To update rails
$ gem update rails
- Creating a new rails app using postgresql
$ mkdir rails_projects
$ cd rails_projects
$ rails new myapp --database=postgresql
@mgiacomini
mgiacomini / deploy.rb
Last active September 2, 2015 17:02 — forked from jbonney/deploy.rb
Mina deployment file to setup new host for Rails applications. Creates the folder structure, fill up the database.yml file, create the associated DB and user and set up new Apache virtual host file.
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
# Usually mina focuses on deploying to one host and the deploy options are therefore simple.
# In our case, there is a number of possible servers to deploy to, it is therefore necessary to
# specify the host that we are targeting.
server = ENV['server']
# Since the same host can have multiple applications running in parallel, it is necessary to
<form>
<fieldset>
<legend>Newsletter</legend>
<label>Your e-mail:</label>
<input type='email' name='email' required/>
<input type='submit' name='submit'/>
</fieldset>
</form>
@mgiacomini
mgiacomini / .bash_profile
Created January 28, 2015 17:42
Setup GIT completion and repository state on MacOSX
#!/bin/bash
source ~/.git-completion.bash
source ~/.git-prompt.sh
MAGENTA="\[\033[0;35m\]"
YELLOW="\[\033[0;33m\]"
BLUE="\[\033[34m\]"
LIGHT_GRAY="\[\033[0;37m\]"
CYAN="\[\033[0;36m\]"