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
| function humanFileSize(bytes, si=false, dp=1) { | |
| const thresh = si ? 1000 : 1024; | |
| if (Math.abs(bytes) < thresh) { | |
| return bytes + ' B'; | |
| } | |
| const units = si | |
| ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] | |
| : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']; |
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
| try { | |
| FileTime creationTime = (FileTime) Files.getAttribute(path, "creationTime"); | |
| } catch (IOException ex) { | |
| // handle exception | |
| } | |
| try { | |
| BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class); | |
| FileTime fileTime = attr.creationTime(); | |
| } catch (IOException ex) { |
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
| public void givenTwoDateTimesInJava8_whenDifferentiatingInSeconds_thenWeGetTen() { | |
| LocalDateTime now = LocalDateTime.now(); | |
| LocalDateTime tenSecondsLater = now.plusSeconds(10); | |
| long diff = ChronoUnit.SECONDS.between(now, tenSecondsLater); | |
| assertEquals(10, diff); | |
| } |
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
| public void givenTwoDatesBeforeJava8_whenDifferentiating_thenWeGetSix() | |
| throws ParseException { | |
| SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH); | |
| Date firstDate = sdf.parse("06/24/2017"); | |
| Date secondDate = sdf.parse("06/30/2017"); | |
| long diffInMillies = Math.abs(secondDate.getTime() - firstDate.getTime()); | |
| long diff = TimeUnit.DAYS.convert(diffInMillies, TimeUnit.MILLISECONDS); |
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
| https://medium.com/@onexlab.io/main-jsbundle-does-not-exist-fixed-7d92f466ba5a | |
| in package.json add | |
| "build:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios' | |
| "error Unable to resolve module `react-native-webview` from `src/screens/TermoUsoScreenComponent.js`: react-native-webview could not be found within the project. | |
| If you are sure the module exists, try these steps: | |
| 1. Clear watchman watches: watchman watch-del-all |
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
| function replaceSpecialChars(str=''){ | |
| return str.normalize('NFD') | |
| .replace(/[\u0300-\u036f]/g,''); | |
| } |
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
| str = str.replace(/(?:\r\n|\r|\n)/g, '<br>'); |
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
| app.post('/api/0.1/people', express.bodyParser({limit: '5mb'}), yourHandler); |
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 str = 'a b c'; | |
| var replaced = str.replace(/\s/g, '+'); | |
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
| //Baseado na solução em https://pt.stackoverflow.com/questions/91379/como-validar-data-com-angularjs-ou-jquery | |
| function validateDate(data){ | |
| if(!data){ | |
| return false; | |
| } | |
| let dataTemp = data; | |
| if(dataTemp.length===8){ | |
| dataTemp = data.substr(0,2)+'/'+data.substr(2,2)+'/'+data.substr(4); |
NewerOlder