Skip to content

Instantly share code, notes, and snippets.

View josephrexme's full-sized avatar
:octocat:
Training wolves and dragons

Joseph Rex josephrexme

:octocat:
Training wolves and dragons
View GitHub Profile
@josephrexme
josephrexme / company.html.erb
Created December 24, 2014 06:32
Displaying various form create on a page
<section class="row-doubles">
<div>
<div class="title">Add Department</div>
<div class="content pad10">
<%= form_for @department, url: 'department_path' do |f| %>
<p>
<%= f.label :name, 'Department Name' %>
<%= f.text_field :name %>
</p>
<p>
@josephrexme
josephrexme / company.html.erb
Last active August 29, 2015 14:12
Multiple CRUD operations on a page
<!-- Create -->
<%= form_for @department do |f| %>
<p>
<%= f.label :name, 'Department Name' %>
<%= f.text_field :name %>
</p>
<p>
<%= f.label :parent %>
<% department_array = @departments.all.map { |department| [department.name, department.name] } %>
<%= f.select :parent, options_for_select([['no parent', '']] + department_array) %>
@josephrexme
josephrexme / forms.coffee
Created December 26, 2014 10:33
UJS: Continue execution of ajax request in a callback after altering with ajax:beforeSend
$(document).ready ->
$('[id^="edit_department"').on("ajax:success", (e, data, status, xhr) ->
$(this).append "<p class='fr'>Updated Succesfully</p>"
$(this).children('.fr').delay(2000).fadeOut()
).on "ajax:error", (e, data, status, error) ->
$(this).append "<p class='fr'>Failed to update</p>"
$('.content>.fr span:last-of-type>a').on "ajax:beforeSend", (xhr, settings) ->
swal
title: "Are you sure?"
@josephrexme
josephrexme / _variables.scss.erb
Created December 28, 2014 20:15
Changing themes in an application
// Variables
$hopbush: #c69;
$bouquet: #b37399;
$venus: #998099;
$patina: #699;
$nebula: #d2e1dd;
$wine: #B21F1F;
$dawn-pink: #f2ece4;
$wafer: #e1d7d2;
$skyblue: #9BC1F5;
@josephrexme
josephrexme / DOM
Last active August 29, 2015 14:12
Form_for breaking on encounter of <td>
<html><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="ostrich-dev">
<link href="http://fonts.googleapis.com/css?family=Roboto+Condensed:400,300" rel="stylesheet" type="text/css">
<link rel="author" href="http://ostrich-dev.com">
<link rel="shortcut icon" href="http://localhost:3000/favicon.ico">
<title>vitabiotics</title>
<link data-turbolinks-track="true" href="/assets/application.css" media="all" rel="stylesheet">
@josephrexme
josephrexme / file.rb
Created January 4, 2015 23:38
Attendance Logic
=begin
Help with Logic
=end
allRecords = Attendance.pluck(:date, :presence).map { |attendance, presence| [attendance.strftime('%B'), presence] } #=> [['November',true],['November',false],['November',true],['December', true], ['December', false], ['January',false], ['January',true]]
monthFilter = allRecords.uniq.map { |month| [month[0]] } #=> ['November','November', 'November', 'December', 'December', 'January','January']
months = monthFilter.uniq #=> ['November','December','January']
# Expected To do the following:
# To fetch all the records and count the number of true presence with false presence per month. Then get a percentage of true / total in each month
@josephrexme
josephrexme / app.css
Created January 15, 2015 14:29
Specity graph for my jekyll blog CSS. This against http://jonassebastianohlsson.com/specificity-graph/
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font:inherit;font-size:100%;vertical-align:baseline}html{line-height:1}ol,ul{list-style:none}table{border-collapse:collapse;border-spacing:0}caption,th,td{text-align:left;font-weight:normal;vertical-align:middle}q,blockquote{quotes:none}q:before,q:after,blockquote:before,blockquote:after{content:"";content:none}a img{border:none}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}/*! HTML5 Boilerplate v4.3.0 | MIT License | http://h5bp.com/ */html,button,input,select,textarea{color:#222}html{font-size:1em;line-height:1.4}::-mo
# Simple bijective function
# Basically encodes any integer into a base(n) string,
# where n is ALPHABET.length.
# Based on pseudocode from http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener/742047#742047
ALPHABET =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(//)
# make your own alphabet using:
# (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle.join
@josephrexme
josephrexme / parser.rb
Created July 4, 2015 08:27
Parser method
def parse(self)
=begin
Method to parse the resource file for the terminal alias
provided, and populate the gw array with the terminal information.
Parameters
==========
None
Exceptions
==========
zipfile.BadZipfile - in case resource file cannot be read
@josephrexme
josephrexme / README.md
Last active August 29, 2015 14:27 — forked from necolas/README.md
Experimenting with component-based HTML/CSS naming and patterns

NOTE I now use the conventions detailed in the SUIT framework

Template Components

Used to provide structural templates.

Pattern

t-template-name