Skip to content

Instantly share code, notes, and snippets.

:octocat:
Working on personal projects

Joseph Rex josephrexme

:octocat:
Working on personal projects
Block or report user

Report or block josephrexme

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@josephrexme
josephrexme / company.html.erb
Created Dec 24, 2014
Displaying various form create on a page
View company.html.erb
<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 Aug 29, 2015
Multiple CRUD operations on a page
View company.html.erb
<!-- 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 Dec 26, 2014
UJS: Continue execution of ajax request in a callback after altering with ajax:beforeSend
View forms.coffee
$(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 Dec 28, 2014
Changing themes in an application
View _variables.scss.erb
// 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 Aug 29, 2015
Form_for breaking on encounter of <td>
View DOM
<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 Jan 4, 2015
Attendance Logic
View file.rb
=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 Jan 15, 2015
Specity graph for my jekyll blog CSS. This against http://jonassebastianohlsson.com/specificity-graph/
View app.css
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
View bijective.rb
# 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
View parser.rb
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 Aug 29, 2015 — forked from necolas/README.md
Experimenting with component-based HTML/CSS naming and patterns
View README.md

NOTE I now use the conventions detailed in the SUIT framework

Template Components

Used to provide structural templates.

Pattern

t-template-name
You can’t perform that action at this time.