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 src = 'https:' == location.protocol ? 'https':'http', script = document.createElement('script'); | |
script.src = src+'://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'; | |
script.onload = function () { | |
var $ = jQuery; | |
var elem = $('<div>').text("0").css({position: 'fixed', top: 0, left: 0, width: 250, height: 40, backgroundColor: '#006699', borderBottomRightRadius: 7, color: 'white', padding: 9, fontWeight: 'bold', fontSize: '30px', boxShadow: "0 0px 20px 2px black"}).appendTo(document.body); | |
var sum = 0; | |
var count = 0; | |
$("table td").click(function () { | |
var cell = $(this); |
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
#!/usr/bin/env ruby | |
require 'nokogiri' | |
require 'equivalent-xml' | |
xml = ARGV.map {|file_name| File.open(file_name) {|f| Nokogiri::XML(f)}} | |
print "Same: ", EquivalentXml.equivalent?(xml[0], xml[1]) |
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 scaldi.{Injectable, Module, Injector} | |
class UserService | |
class UserController(implicit inj: Injector) extends Injectable { | |
val userService = inject [UserService] | |
} | |
class OrderService(implicit inj: Injector) extends Injectable { | |
val userService = inject [UserService] |
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 scaldi.{Injector, Module, Injectable} | |
trait Security { | |
type User | |
def authenticate(username: String, password: String): Boolean | |
} | |
class SecuritySample extends Security { | |
def authenticate(username: String, password: String): Boolean = false |
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
package org.am.incident | |
object Test extends App { | |
def ??? = throw new IllegalStateException() | |
trait Conv[A, B] { | |
def conv(a: A): B | |
} | |
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
package scaldi.keys | |
import math._ | |
import swing._ | |
import java.io.{Closeable, InputStream, FilterInputStream} | |
import javax.swing.UIManager | |
import java.net.URL | |
object Downloader extends SimpleSwingApplication { |
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 javax.swing.UIManager | |
import java.net.URL | |
import java.awt.Dimension | |
import java.io.Closeable | |
import swing._ | |
object Downloader extends SimpleSwingApplication { | |
UIManager.getInstalledLookAndFeels | |
.filter(_.getName contains "Nimbus").headOption |
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 math._ | |
case class Progress(percent: Int, size: Long, remains: Long, done: Long, bps: Long, elapsed: Long, estimated: Long) { | |
lazy val formattedMetrics= List( | |
"Progress: " + percent + "%", | |
"File size: " + formatSize(size), | |
"Downloaded: " + formatSize(done), | |
"Remains: " + formatSize(remains), | |
"Speed: " + (bps / 1024) + " kb/s", | |
"Elapsed: " + formatTime(elapsed), |
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 math._ | |
class ProgressListener(availableBytes: Long, tracker: Progress => Unit) extends Function1[Long, Unit] { | |
var transfered: Long = 0 | |
val startTime = System.currentTimeMillis | |
def apply(bytesTransfered: Long) { | |
transfered += bytesTransfered | |
val elapsed = System.currentTimeMillis - startTime | |
val bpms = (transfered / max(elapsed, 1000)).toLong |
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 java.io.{FilterInputStream, InputStream} | |
class ProgressInputStream(in: InputStream, listener: Long => Unit) extends FilterInputStream(in) { | |
val NotificationThreshold = 8 * 1024; | |
var unnotifiedByteCount = 0 | |
override def read() = { | |
val data = super.read() | |
if (data != -1) notify(1) |