Skip to content

Instantly share code, notes, and snippets.

@megamos
megamos / application_controller.rb
Last active November 12, 2015 10:27
Failing to pass routing from rails(backend) over to angularJS. On page refresh rails does the routing instead of angular.
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def index
end
end
@megamos
megamos / feedbacks_controller.rb
Last active February 11, 2016 21:54
Setting values other then from form on create
def create
@feedback = Feedback.new(feedback_params)
respond_to do |format|
if @feedback.save
if current_user
@feedback.created_by = current_user.id
format.html { redirect_to user_path(current_user), notice: "Tack för din feedback!"}
end
format.html { redirect_to root_path, notice: "Tack för din feedback!"}
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
@megamos
megamos / form.rb
Created April 18, 2016 23:50
Trying to pass a hash with array through strong parameters
- url_path = _old_virtual_path.include?("new") ? venue_practices_path : venue_practice_path(@practice.venue_id,@practice)
.form
= simple_form_for(@practice, url: url_path ) do |f|
= f.error_notification
.form-inputs
= f.input :name, label: "Namn"
.row
.col-sm-6.category
= f.input :category, label: "Kategori"
.col-sm-6.under_category
@megamos
megamos / capybara cheat sheet
Created April 3, 2017 16:21 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@megamos
megamos / bash_arrays_and_loops.sh
Last active April 4, 2018 09:36
Looping array by using var from outer loop
#!/bin/bash
# Departments
departments="engineering sales is"
# Users in each department
engineering=( Lars Jenny Carl )
sales=( Nils Mark Hunny )
is=( Robert Lisa John )
@megamos
megamos / file.c
Created April 6, 2018 12:34
Cannot compile a simple c file
/* file.c */
#include &lt;stdio.h;&gt
int main()
{
printf("Hello World!\n");
return 0;
}
#Output
@megamos
megamos / .angular-cli.json
Created April 24, 2018 08:12
Showing basic sass set up for angular
#.... removed to show less
"prefix": "app",
"styles": [
"sass/styles.sass"
],
"scripts": [],
#.... removed to show less
In this file we only change the value of "styles" from "styles.sass" to "sass/styles.sass" because
we have created a sass folder and moved the styles.sass file in to it.
February 10 of YR2 We have found thieves from Whoop There it is (6:18) causing trouble within our lands!
February 10 of YR2 264 peasants were kidnapped!
February 11 of YR2 Meteors rain across the lands and kill 36 peasants!
February 12 of YR2 Meteors rain across the lands and kill 172 peasants, 3 soldiers and 44 Harpies!
February 12 of YR2 We have found thieves causing trouble within our lands. Unfortunately, we know not where they came from.
February 12 of YR2 We have found thieves causing trouble within our lands. Unfortunately, we know not where they came from.
February 12 of YR2 We have found thieves from Whoop There it is (6:18) causing trouble within our lands!
February 12 of YR2 We have found thieves causing trouble within our lands. Unfortunately, we know not where they came from.
February 12 of YR2 Our mages noticed a possible spell attempt by Calena Morgan (6:18) causing trouble on our lands!
February 12 of YR2 Meteors rain across our lands, and are not expected to stop for 8 days.
@megamos
megamos / gist:e057659fc056f8eccf6c13a6404c3adb
Created November 22, 2019 21:11
WoW riding equip macro (Replace Riding gear and trinkets)
/equipslot [nomounted] 14 Carrot on a Stick
/equip [nomounted] Gnomish Rocket Boots
/equipslot [mounted] 14 Gyrofreeze Ice Reflector
/equip [mounted] Omnicast Boots
/use Swift White Mechanostrider