Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
// Requires NodeJS and "noble" module: https://github.com/sandeepmistry/noble | |
// Based on: https://github.com/sandeepmistry/noble/issues/62 | |
var noble = require('noble'); | |
noble.on('stateChange', function(state) { | |
if (state === 'poweredOn' ) { | |
noble.startScanning([], false); | |
} else { | |
noble.stopScanning(); | |
} |
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
import com.softwaremill.macwire.Macwire | |
class ServiceDependency | |
class Service(implicit val otherDependency : ServiceDependency) | |
trait Module extends Macwire { | |
lazy val otherDependency = new ServiceDependency | |
lazy val service = wire[Service] | |
} |
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
import akka.actor._ | |
object Beans { | |
lazy val actorSystem = ActorSystem("Hi-Actor") | |
def depActorFactory(f : ActorRefFactory) = f.actorOf(Props[DepActor]) | |
def someActorFactory = actorSystem.actorOf(Props(classOf[SomeActor], depActorFactory _)) | |
} |
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
/* | |
* DI u nas robione jest manualnie. | |
* W module tworzę factory dla aktorów. Factory są zarówno dla aktorów, którzy są parametryzowani jak i dla tych, co nie są. | |
* Potem w odpowiednim aktorze mogę wywołać context.actorOf(someActorFactory()) i mam zachowaną hierarchię. | |
* | |
* Jak chcesz więcej poczytać o manualnym DI to polecam http://di-in-scala.github.io/ | |
*/ | |
trait ActorsModule extends ActorSystemModule { | |
/* Te zależności są wmiksowywane z innych modułów */ |
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
function jh | |
if test -e /usr/libexec/java_home | |
set _jh (/usr/libexec/java_home -v 1.$argv) | |
if test -n $_jh | |
echo "Setting JAVA_HOME to $_jh" | |
set -gx JAVA_HOME $_jh | |
else | |
echo "Could not find java version $argv" | |
end | |
else |
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
{ | |
"values": [ | |
{ | |
"key": "tabor", | |
"value": "T" | |
}, | |
{ | |
"key": "linia", | |
"value": "11" | |
}, |
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
jstack -l 81427 | |
2015-06-03 13:36:09 | |
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode): | |
"Attach Listener" #36 daemon prio=9 os_prio=31 tid=0x00007fbb9e816800 nid=0x5507 waiting on condition [0x0000000000000000] | |
java.lang.Thread.State: RUNNABLE | |
Locked ownable synchronizers: | |
- None |
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
import com.softwaremill.thegarden.lawn.base.StringExtensions._ | |
trait SnakeCaseJsonProtocol extends DefaultJsonProtocol { | |
override protected def extractFieldNames(classTag: ClassTag[_]) = super.extractFieldNames(classTag).map {_.underscore} | |
override protected def fromField[T](value: JsValue, fieldName: String)(implicit reader: JsonReader[T]) = | |
super.fromField(value, fieldName.camelCase)(reader) | |
} |
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 Picture < ActiveRecord::Base | |
def self.new_from_flickr_photo(photo) | |
picture = Picture.new | |
picture.set_attributes_from_flickr_photo(photo) | |
picture | |
end | |
def set_attributes_from_flickr_photo(photo) | |
# copy whichever attributes you might need |
OlderNewer