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 "dart:io"; | |
void main() { | |
// get user input using synchronous I/O | |
String input = stdin.readLineSync(); | |
// get user input and convert to lowercase | |
String inputLC = stdin.readLineSync().toLowerCase(); | |
print(input); |
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
int factorial(int number) { | |
int factorialRange(int bottom, int top) { | |
if (top == bottom) { | |
return bottom; | |
} | |
return top * factorialRange(bottom, top - 1); | |
} | |
return factorialRange(1, number); |
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
List<String> findAllPermutations(String source) { | |
List allPermutations = []; | |
void permutate(List list, int cursor) { | |
// when the cursor gets this far, we've found one permutation, so save it | |
if (cursor == list.length) { | |
allPermutations.add(list); | |
return; | |
} |
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
/* specific way */ | |
img { | |
-moz-user-drag: -moz-none; | |
-webkit-user-drag: none; | |
user-drag: none; | |
} | |
/* "nuke 'em all" way */ | |
img { | |
pointer-events: 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
.user-select-none { | |
-webkit-touch-callout: none; | |
-webkit-user-select: none; | |
-khtml-user-select: none; | |
-moz-user-select: none; | |
-ms-user-select: none; | |
user-select: 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
/* Chrome */ | |
::-webkit-selection { | |
background-color: #FF68B0; | |
color: #FFF; | |
} | |
/* Firefox */ | |
::-moz-selection { | |
background-color: #FF68B0; | |
color: #FFF; |
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
new Element.html("YOUR HTML STRING HERE"); | |
// You may need to pass a NodeValidator to get everything to render, like: | |
NodeValidator nodeValidator = new NodeValidatorBuilder() | |
..allowTextElements(); | |
// ..allowHtml5() | |
// ..allowElement('Button', attributes: ['ng-disabled']); | |
new Element.html("YOUR HTML STRING HERE", validator: nodeValidator); |
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
final now = DateTime.now(); | |
final lastDayOfMonth = DateTime(now.year, now.month + 1, 0); | |
print("${lastDayOfMonth.month}/${lastDayOfMonth.day}"); |
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
void downloadFileToClient(String filename, String text) { | |
AnchorElement tempLink = document.createElement('a'); | |
tempLink | |
..attributes['href'] = 'data:text/plain;charset=utf-8,${Uri.encodeComponent(text)}' | |
..attributes['download'] = filename | |
..click(); | |
} |
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 ConfigService { | |
var _config; | |
Completer _waitForConfig = new Completer(); | |
ConfigService() { | |
doHttpCall().then((result) { | |
_config = result; | |
_waitForConfig.complete(_config); | |
} |
OlderNewer