Skip to content

Instantly share code, notes, and snippets.

View JPCodes's full-sized avatar
🎯
Focusing

Jim Padilla JPCodes

🎯
Focusing
View GitHub Profile
@JPCodes
JPCodes / about.html
Last active March 21, 2016 23:40
About Page (Simple Version)
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/normalize.css">
<link rel="stylesheet" type="text/css" href="css/about_styles.css">
<title>About</title>
<!--[if lt IE 9]>
<script src="dist/html5shiv.js"></script>
@JPCodes
JPCodes / index.html
Last active April 24, 2016 02:25
Portfolio Site
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Home</title>
<!-- Bootstrap core CSS -->
@JPCodes
JPCodes / index.html
Last active April 18, 2016 21:16
Portfolio Site (with contact form -- no backend) (Placeholder work images)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Home</title>
<!-- Bootstrap core CSS -->
@JPCodes
JPCodes / cat.rb
Last active May 14, 2016 07:00
CF Ruby Syntax Practice
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
@JPCodes
JPCodes / beliefs.html
Last active August 7, 2016 23:37
LPC Website (Work in Progress)
<!DOCTYPE html>
<html>
<head>
<title>LPC</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="css/styles_bootstrap.css" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--[if IE]>
@JPCodes
JPCodes / scripts.js
Created February 1, 2017 22:51
algorithm to find shortest distance
// Use a closure to prevent the global namespace from be polluted.
(function() {
// Define StopIteration as part of the global scope if it
// isn't already defined.
if(typeof StopIteration == "undefined") {
StopIteration = new Error("StopIteration");
}
// The original version of Array.prototype.forEach.
var oldForEach = Array.prototype.forEach;
Write function scramble(str1,str2) that returns true if a portion of str1 characters can be rearranged to match str2, otherwise returns false.
For example:
str1 is 'rkqodlw' and str2 is 'world' the output should return true.
str1 is 'cedewaraaossoqqyt' and str2 is 'codewars' should return true.
str1 is 'katas' and str2 is 'steak' should return false.
Only lower case letters will be used (a-z). No punctuation or digits will be included.
Performance needs to be considered
@JPCodes
JPCodes / gist:0a5201cdcd3f061b9c193d4d66609dde
Created February 7, 2018 00:36 — forked from esbanarango/gist:6629748
HTML <input> required attribute and Rails form with remote true.

<input> with attribute required

This attribute specifies that the user must fill in a value before submitting a form. It cannot be used when the type attribute is hidden, image, or a button type (submit, reset, or button). The :optional and :required CSS pseudo-classes will be applied to the field as appropriate.

How to show a spinner only when the required validations pass? (Without using any validation plugin, only the required attribute).

Form with a required input

= form_for @person, remote: true do |f|
 = f.text_field, :first_name, required: true

Deploy Rails 4 app with Dokku on DigitalOcean

Install dokku

First create a Ubuntu 13.04 x64 droplet on DigitalOcean Control Panel

Then ssh with root account, run this in termianl:

$ wget -qO- https://raw.github.com/progrium/dokku/master/bootstrap.sh | sudo bash