This file contains hidden or 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
from PySide import QtGui | |
class CustomSortFilterProxyModel(QtGui.QSortFilterProxyModel): | |
""" | |
Implements a QSortFilterProxyModel that allows for custom | |
filtering. Add new filter functions using addFilterFunction(). | |
New functions should accept two arguments, the column to be | |
filtered and the currently set filter string, and should | |
return True to accept the row, False otherwise. |
This file contains hidden or 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
h1 Comments | |
.comment-list data-controller="comment-list" | |
ul.comments-list data-target="comment-list.commentList" | |
= render @comments | |
= form_with model: Comment.new, html: { data: { type: "html", action: "ajax:success->comment-list#onPostSuccess" } } do |form| | |
= form.text_area :message, data: { target: "comment-list.message" } | |
= form.submit "Post Comment" |
This file contains hidden or 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 CommentsController < ApplicationController | |
def index | |
@comments = Comment.all | |
end | |
def create | |
@comment = current_user.comments.create(comment_params) | |
render @comment | |
end |
This file contains hidden or 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
import { Controller } from "stimulus"; | |
export default class extends Controller { | |
static targets = ["message", "commentList"] | |
onPostSuccess(event) { | |
let [data, status, xhr] = event.detail; | |
this.commentListTarget.innerHTML += xhr.response; | |
this.messageTarget.value = ""; | |
} |
This file contains hidden or 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
$(".comment-list").append("<%= j render(@comment) %>"); | |
$(".comment-list form textarea").val(""); |
This file contains hidden or 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
year | age | births | population | adjustedBirths | |
---|---|---|---|---|---|
2003 | 15 | 17520 | 2032351 | 0.862055816 | |
2003 | 16 | 38152 | 2012581 | 1.895675255 | |
2003 | 17 | 64671 | 2015547 | 3.208607887 | |
2003 | 18 | 93595 | 2032257 | 4.605470666 | |
2003 | 19 | 116222 | 1993831 | 5.829079797 | |
2003 | 20 | 115473 | 2010652 | 5.743062449 | |
2003 | 21 | 103090 | 2031746 | 5.073961017 | |
2003 | 22 | 94870 | 2057360 | 4.611249368 | |
2003 | 23 | 86886 | 2048153 | 4.242163549 |
This file contains hidden or 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
- # app/views/comments/_comment.html.slim | |
li data-controller="comment" data-action="click->comment#hello" | |
= "#{comment.message} by #{comment.user.email}" |
This file contains hidden or 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
var feedURLs = []string{ | |
"https://blog.golang.org/feed.atom", | |
"http://feeds.kottke.org/main", | |
} |
This file contains hidden or 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
type feedResult struct { | |
feed *Feed | |
err error | |
} | |
func fetchFeeds(urls []string) ([]*Feed) { | |
// Create a channel to process the feeds | |
feedc := make(chan feedResult, len(urls)) | |
// Start a goroutine for each feed url |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<feed xmlns="http://www.w3.org/2005/Atom"> | |
<title>Example Feed</title> | |
<subtitle>A subtitle.</subtitle> | |
<link href="http://example.org/feed/" rel="self" /> | |
<link href="http://example.org/" /> | |
<id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id> | |
<updated>2003-12-13T18:30:02Z</updated> |
OlderNewer