Skip to content

Instantly share code, notes, and snippets.

@bonyiii
bonyiii / start_rails_api.sh
Last active January 11, 2017 15:34
Start Rails Application
docker run -it \
--name sapi \
-p 3000:3000 \
--security-opt seccomp:chrome.seccomp.json \
-e DISPLAY=unix$DISPLAY \
-v /home/boni/public_html/app/my-api/gems:/usr/local/bundle \
-v /home/boni/public_html/app/my-api:/var/www/my-api \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $HOME/Downloads:/home/dev/Downloads \
-v $HOME/.config/google-chrome/:/home/dev/data \
#!/bin/bash
set -e
case "$1" in
rails|rake|passenger)
# ensure the right database adapter is active in the Gemfile.lock
if [ -z "$NO_BUNDLE" ]; then
# bundle install --without development test
bundle install
chown dev:dev $GEM_HOME -R
@bonyiii
bonyiii / rails_api.Dockerfile
Created December 19, 2016 10:32
Rails application dockerfile
FROM myapp-base
RUN mkdir -p /var/www/myapp-api && chown dev /var/www/myapp-api
WORKDIR /var/www/myapp-api
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 3000
@bonyiii
bonyiii / base_imgage.Dockerfile
Created December 19, 2016 10:29
How to set up rails development with docker base image
# original idea taken from
# https://github.com/docker-library/redmine/blob/d564a3b0d78016b2f24af2d74bcdace26a1ac0a3/3.1/Dockerfile
FROM ruby:2.3
MAINTAINER Bonaventura Fleischmann <[email protected]>
# Add user whose name the app will be run within the container
# the user id should be the default first linux user id
RUN useradd -u 1000 dev
@bonyiii
bonyiii / mailer.rb
Created July 31, 2016 12:25
Redmine mailer with sending attachments
# Redmine - project management software
# Copyright (C) 2006-2016 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
#!/bin/sh
#ctags --tag-relative -e --exclude=.git --exclude=node_modules --exclude=storage --exclude=tmp -Rf
ctags --tag-relative -e -Rf TAGS --exclude=.git --exclude=node_modules --exclude=storage --exclude=tmp . $(bundle list --paths)
# https://github.com/syl20bnr/spacemacs/issues/2275
sed -ri '/^.{1000}/d' TAGS
#https://github.com/mmorearty/elixir-ctags
@bonyiii
bonyiii / gist:2b1cf68b7894846a9678
Last active March 7, 2016 09:23
GF - Security
http://stackoverflow.com/questions/941594/understanding-the-rails-authenticity-token
https://www.owasp.org/index.php/HttpOnly#Who_developed_HttpOnly.3F_When.3F
http://blog.codinghorror.com/protecting-your-cookies-httponly/
http://stackoverflow.com/questions/1177863/how-do-i-ignore-the-authenticity-token-for-specific-actions-in-rails
#define ENGINE_LEFT OUT_A
#define ENGINE_RIGHT OUT_C
#define ENGINE_BOTH OUT_AC
#define SENS_TOUCH IN_2
#define SENS_US_FRONT IN_3
#define SENS_US_LEFT IN_1
#define SENS_COLOR IN_4
int us_left_was, us_left_new;
#define ENGINE_LEFT OUT_A
#define ENGINE_RIGHT OUT_C
#define ENGINE_BOTH OUT_AC
#define SENS_TOUCH IN_1
#define SENS_US IN_3
#define SENS_COLOR IN_4
bool button_pressed() {
int pressed1, pressed2;
#define ENGINE_LEFT OUT_A
#define ENGINE_RIGHT OUT_C
#define ENGINE_BOTH OUT_AC
#define SENS_TOUCH IN_4
#define SENS_US IN_2
#define SENS_COLOR IN_1
bool button_pressed() {
int pressed1, pressed2;