Skip to content

Instantly share code, notes, and snippets.

View dcbriccetti's full-sized avatar

Dave Briccetti dcbriccetti

View GitHub Profile
case class NameAndScreenName(val name: String, val screenName: String) extends Ordered[NameAndScreenName] {
override def toString = name + " (" + screenName + ")"
def compare(other: NameAndScreenName) = screenName compareToIgnoreCase other.screenName
def matches(search: String) = {
val slc = search.toLowerCase
search.length == 0 || name.toLowerCase.contains(slc) || screenName.toLowerCase.contains(slc)
}
}
title = "Send Message"
val isMentions = tweetsProvider.isInstanceOf[MentionsProvider] // TODO do without this test
val model = if (isMentions)
new StatusTableModel(sto, tweetsProvider, usersTableModel, fs, service, user.user, tagUsers) with Mentions
else
new StatusTableModel(sto, tweetsProvider, usersTableModel, fs, service, user.user, tagUsers)
import javax.swing.SwingWorker
class A {
def loadAll(f:(Int) => List[String]): List[String] = List("a")
def getFriendsIds(page: Int): List[String] = List("a")
def getFollowersIds(page: Int): List[String] = List("a")
}
class B {
def setFollowers(followers: List[String]) {}
case class Word(val word: String, val count: Long) {
override def toString = word + ": " + count
}
private def showWordCloud {
val counts = LinkedHashMap[String,Long]()
statusTableModel.filteredStatuses.map(status => {
List.fromArray(status.text.split("\\s")).foreach(word => {
counts.put(word, counts.getOrElse(word, 0L) + 1L)
})
http://twitter.com/statuses/followers.xml?page=4 (for dcbriccetti)
<status>
<created_at>Sun Sep 13 00:35:57 +0000 2009</created_at>
<id>3944822863</id>
<text>@milessabin as long as workinggroups and incubation happen, I'm fine. Your idea seems like less setup work initially for projects</text>
<source>&lt;a href=&quot;http://echofon.com/&quot; rel=&quot;nofollow&quot;&gt;Echofon&lt;/a&gt;</source>
<truncated>false</truncated>
<in_reply_to_status_id>#&lt;StatusInternal:0x242d90c8&gt;</in_reply_to_status_id>
<in_reply_to_user_id>29444566</in_reply_to_user_id>
GETing data from http://twitter.com/statuses/friends/dcbriccetti.xml?page=4
11:40:24,221 [pool-16-thread-1] ERROR twitter - java.lang.IllegalArgumentException: Invalid format: "2009-09-18T17:11:23+00:00" <retweeted_at type="datetime">2009-09-18T17:11:23+00:00</retweeted_at>
<retweet_details>
<retweeting_user>
<id>20</id>
<name>Evan Williams</name>
<screen_name>ev</screen_name>
<location>San Francisco, CA, US</location>
<description>CEO of Twitter</description>
<profile_image_url>http://a1.twimg.com/profile_images/66154838/ev-sky_bigger_normal.jpg</profile_image_url>
# Does the Python community enjoy this type of thing as much as the Scala community?
[[gridPanel.add(self.checkBoxes[r][c]) for r in range(R)] for c in range(C)]
# Or should I split it into the more conventional:
for r in range(R):
for c in range(C):
gridPanel.add(self.checkBoxes[r][c])
@dcbriccetti
dcbriccetti / gist:189595
Created September 19, 2009 21:21
Conway's Game of Life, for the Young Programmers Podcast
# Conway's Game of Life, for the Young Programmers Podcast
from javax.swing import JFrame, JPanel, JButton, JToggleButton, Timer
from java.awt import FlowLayout, GridLayout
from java.awt.BorderLayout import SOUTH
from GridMutator import GridMutator
class LifeGame(object):
def __init__(self, numRows, numCols):
self.numRows = numRows
class GridMutator(object):
def generateNext(self, grid):
(ROWS, COLS) = (len(grid), len(grid[0]))
nextGrid = [[False for r in range(ROWS)] for c in range(COLS)]
for row in range(ROWS):
for col in range(COLS):
neighbors = self._countNeighbors(grid, row, col)
nextGrid[row][col] = neighbors == 3 if not grid[row][col] \
else neighbors in (2,3)
return nextGrid
<status>
<created_at>Thu Sep 24 00:52:00 +0000 2009</created_at>
<id>4329889268</id>
<text>:@michaelg Hmm, I wonder what it was that broke it earlier.</text>
<source>&lt;a href=&quot;http://www.atebits.com/&quot; rel=&quot;nofollow&quot;&gt;Tweetie&lt;/a&gt;</source>
<truncated>false</truncated>
<in_reply_to_status_id>4329766281</in_reply_to_status_id>
<in_reply_to_user_id>1378181</in_reply_to_user_id>
<favorited>false</favorited>
<in_reply_to_screen_name>michaelg</in_reply_to_screen_name>