Skip to content

Instantly share code, notes, and snippets.

View hopewise's full-sized avatar

Samir Sabri hopewise

View GitHub Profile
@hopewise
hopewise / gist:59c8e48f73484a1c85f24a58ab78fb9a
Created July 5, 2018 12:14
Manual installation for module in Odoo
#start odoo container for the first time
docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo --name db postgres:9.4
docker run -p 8069:8069 -it --name odoo --link db:db -t odoo
#bash into odoo as root
docker exec -i -t -u 0 odoo /bin/bash
#download module and extract it at local file system
#copy module to odoo modules directory
@hopewise
hopewise / gist:82f4c26868e52a5c3a3b4053400609a9
Created July 3, 2018 07:35
start elixir in current dir
docker run -p 4011:4011 -p 4033:4033 -v /Users/samir/Documents/projects/elixir:/usr/src -it elixir:1.5.2 bash
@hopewise
hopewise / .babelrc
Last active August 16, 2018 13:16
React JS , mobx , GraphQL , apollo client, webpack-dev-server writes file to desk, load .graphql files separately
{
"presets": [
"react",
"es2015",
"stage-1"
],
"plugins": ["transform-decorators-legacy", "transform-class-properties", "inline-import-graphql-ast"]
}
@hopewise
hopewise / gist:7bfdd80e9e9a0e2fe4ea95866fec3a0c
Last active May 28, 2018 08:02
force python3 in terminal, this is important to make sure AWS eb deploy uses git to deploy
#to let eb use python3
export PATH=/Users/Apple/Library/Python/3.4/bin:$PATH
@hopewise
hopewise / gist:b37df5c8a884babf9f9e5760cdedaa11
Created January 22, 2018 11:19
Piping (|>) to second argument in Elixir
insert_result = result
|> FieldsFitter.fit_driver_fields
|> (&Schools.Driver.changeset(%Schools.Driver{}, &1)).()
|> repo.insert
@hopewise
hopewise / gist:391d854732c2c144c9671a7e9bc79d0b
Created January 10, 2018 10:11
Json encoding Ecto changeset validation errors
for result_error <- changeset.errors do
{field_name, ecto_error}= result_error
{error_message, ecto_validation}= ecto_error
[ecto_validation_message| ecto_validation_tail] = ecto_validation
ecto_validation_message= Kernel.inspect ecto_validation_message
Poison.encode! %{error: "invalid field value", field: %{field_name: field_name, error_message: ecto_validation_message }})
end
@hopewise
hopewise / gist:0373922e51e313a55390114908c31257
Created December 12, 2017 10:59
Convert a key => value map into a sorted list based on values, works with value if string
Enum.map(Enum.to_list(0..Enum.count(Map.keys(row))), fn index -> row["#{index}"] end)
example row:
row %{"0" => "2", "1" => "أحمد عمر فؤاد خالد عبدالله 2",
"10" => "null", "11" => "null", "12" => "null", "13" => "null",
"14" => "null", "2" => "Male", "3" => "الأول الأساسي", "4" => "A",
"5" => "Amman", "6" => "null", "7" => "null", "8" => "null", "9" => "null"}
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/Users/samir/Documents/projects/tsung/tsung-1.0.dtd">
<tsung loglevel="error" version="1.0">
<clients>
<client host="localhost" use_controller_vm="true" maxusers="10000"/>
</clients>
<servers>
<server host="192.168.1.22" port="9907" type="tcp"/>
</servers>
@hopewise
hopewise / app.js
Created May 3, 2016 14:43
app.js for phoenix framework chatting example
// Brunch automatically concatenates all files in your
// watched paths. Those paths can be configured at
// config.paths.watched in "brunch-config.js".
//
// However, those files will only be executed if
// explicitly imported. The only exception are files
// in vendor, which are never wrapped in imports and
// therefore are always executed.
// Import dependencies
FROM node:latest
MAINTAINER Samir Sabri
# System update
RUN apt-get -q -y update
RUN apt-get -q -y install npm
RUN npm install -g gulp-cli
RUN npm install -g grunt-cli