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
scala> val s = "Me Moscow 2012" | |
s: String = some text 2012 | |
scala> val PersonLocation = """(.+) (.+) (.+)""".r | |
PersonLocation: scala.util.matching.Regex = (.+) (.+) (.+) | |
scala> val PersonLocation(person, city, year) = s | |
person: String = Me | |
city: String = Moscow | |
year: String = 2012 |
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
// Implicit | |
import scala.collection.JavaConverters._ | |
// For method: | |
def doSomething(things: List[Thing]): List[Result] = { ... } | |
// add the same method with another signature: | |
def doSomething(things: java.util.List[Thing]): java.util.List[Result] = | |
doSomething(things.asScala.toList).asJava |
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 HackUtils { | |
public static void setListViewHeightBasedOnChildren(ListView listView) { | |
ListAdapter listAdapter = listView.getAdapter(); | |
if (listAdapter == null) { | |
// pre-condition | |
return; | |
} | |
int totalHeight = 0; | |
for (int i = 0; i < listAdapter.getCount(); i++) { |
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
app.run(['$templateCache', function ($templateCache) { | |
/** | |
* Cached Angular Template for ui-grid/uiSelect. | |
* Allows to use in ui-grid as 'editableCellTemplate' field definition | |
*/ | |
$templateCache.put('ui-grid/uiSelect', | |
'<ui-select-grid-cell-wrap>' + | |
'<ui-select ng-model="MODEL_COL_FIELD" theme="selectize" ng-disabled="disabled" append-to-body="true">' + | |
'<ui-select-match placeholder="Choose...">{{ $select.selected[editDropdownValueLabel] }}</ui-select-match>' + |
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
public class MyMapActivity extends MapActivity | |
implements OnGestureListener { | |
... | |
private GestureDetector gestureDetector; | |
@Override |
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
public class ShowMapActivity extends MapActivity { | |
... | |
private long touchActionDownStartTime; | |
private float histX; | |
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 dashboardCtrl | |
NOTIFICATIONS_STATUS_UPDATE_PERIOD = 30 # Seconds | |
@$inject = ['$scope', '$q', '$log', '$cookies', '$state', '$rootScope', '$timeout', 'MonitoringService', | |
'loginService', 'SettingsService'] | |
_s = {} | |
scheduleAgentDataUpdate = () -> |
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
/** | |
* Determine if SSL is used. | |
* | |
* @since 2.6.0 | |
* | |
* @return bool True if SSL, false if not used. | |
*/ | |
function is_ssl() { | |
if ( isset($_SERVER['HTTPS']) ) { | |
if ( 'on' == strtolower($_SERVER['HTTPS']) ) |
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
Setting the BODY's background to the average color in the following image: | |
<br/><br/> | |
<img id="i" src="data:image/jpeg;base64,/9j/7gAOQWRvYmUAZAAAAA........Q==" /> |
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
#Color text change | |
rgb = [ | |
"255" | |
"0" | |
"0" | |
] | |
setInterval (-> | |
c = "rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + ")" | |
#http://www.w3.org/TR/AERT#color-contrast |