This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fox16' | |
include Fox | |
class MyApp < FXMainWindow | |
def initialize(app) | |
@app = app | |
super(app, "Test", :height => 150, :width => 350, :opts=> DECOR_ALL) | |
self.connect(SEL_CLOSE, method(:on_close)) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start_path = "/path/to/parent/directory/" | |
def change_text_file(path) | |
file_contents = "" | |
File.open(path,'r') do |file| | |
while line = file.gets | |
if line.match "whatever" | |
line = line.sub("whatever", "new whatever") | |
end | |
file_contents += line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: UTF-8 | |
start_path = "/path/to/parent/directory/" | |
def change_text_file(path) | |
file_contents = "" | |
File.open(path,'r') do |file| | |
while line = file.gets | |
if line.force_encoding("ISO-8859-1").encode("utf-8", replace: nil).match "whatever" | |
line = line.sub("whatever", "new whatever") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>AJAX demo</title> | |
</head> | |
<body> | |
<input type="text" id="myTextField" /> | |
<button id="ajax">Submit AJAX request</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update | |
if user_params[:password].blank? | |
user_params.delete(:password) | |
user_params.delete(:password_confirmation) | |
end | |
successfully_updated = if needs_password?(@user, user_params) | |
@user.update(user_params) | |
else | |
@user.update_without_password(user_params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r1 = Role.create({name: "Regular", description: "Can read items"}) | |
r2 = Role.create({name: "Seller", description: "Can read and create items. Can update and destroy own items"}) | |
r3 = Role.create({name: "Admin", description: "Can perform any CRUD operation on any resource"}) | |
u1 = User.create({name: "Sally", email: "sally@example.com", password: "aaaaaaaa", password_confirmation: "aaaaaaaa", role_id: r1.id}) | |
u2 = User.create({name: "Sue", email: "sue@example.com", password: "aaaaaaaa", password_confirmation: "aaaaaaaa", role_id: r2.id}) | |
u3 = User.create({name: "Kev", email: "kev@example.com", password: "aaaaaaaa", password_confirmation: "aaaaaaaa", role_id: r2.id}) | |
u4 = User.create({name: "Jack", email: "jack@example.com", password: "aaaaaaaa", password_confirmation: "aaaaaaaa", role_id: r3.id}) | |
i1 = Item.create({name: "Rayban Sunglasses", description: "Stylish shades", price: 99.99, user_id: u2.id}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if user_signed_in? %> | |
Signed in as <%= current_user.email %>. Not you? | |
<%= link_to "Edit profile", edit_user_registration_path %> | |
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %> | |
<% else %> | |
<%= link_to "Sign up", new_user_registration_path %> or <%= link_to "sign in", new_user_session_path %> | |
<% end %> | |
<% flash.each do |name, msg| %> | |
<%= content_tag :div, msg, id: "flash_#{name}" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RegistrationsController < Devise::RegistrationsController | |
def update | |
account_update_params = devise_parameter_sanitizer.sanitize(:account_update) | |
@user = User.find(current_user.id) | |
if needs_password? | |
successfully_updated = @user.update_with_password(account_update_params) | |
else | |
account_update_params.delete('password') | |
account_update_params.delete('password_confirmation') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Login Details</h2> | |
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> | |
<%= devise_error_messages! %> | |
<div class="field"> | |
<%= f.label :email %><br /> | |
<%= f.email_field :email, autofocus: true %> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body{background-color:#FFF;color:#303030;line-height:1.6;font-size:16pt;font-weight:300} | |
a{text-decoration:none;color:#0083ff} | |
time{color:#ababab} | |
.super{vertical-align:super;font-size:50%} | |
.content{text-align:left;max-width:775px;margin:0 auto 2em} | |
.content ul{padding-left:2.5em} | |
.content ol{padding-left:2.5em} | |
.container{margin-bottom:3em;margin-left:1em;margin-right:1em} | |
.content .header{text-align:center;border-bottom-style:solid;border-bottom-color:#e4e4e4;border-bottom-width:.3em} | |
.content .header .siteTitle{font-size:3.5em;font-weight:700;margin-top:-.25em} |
OlderNewer