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 romanNumber(num) { | |
| if (typeof num !== 'number') { | |
| return false; | |
| } | |
| let digits = String(+num).split(""); | |
| let key = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"]; | |
| let romanNum = ""; | |
| let i = 3; |
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 uuid() { | |
| return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | |
| var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); | |
| return v.toString(16); | |
| }); | |
| } |
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
| const moment = require('moment'); | |
| let a = moment('2013-01-01'); | |
| let b = moment('2013-06-01'); | |
| // If you want an exclusive end date (half-open interval) | |
| for (let m = moment(a); m.isBefore(b); m.add(1, 'days')) { | |
| console.log(m.format('YYYY-MM-DD')); | |
| } |
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
| type User struct { | |
| name string | |
| age int | |
| } | |
| tole := User { | |
| name: "Scott", | |
| age: 23, | |
| } |
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
| const path = require('path'); | |
| console.log(path.dirname(require.main.filename)); |
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 isUpperCase(letter){ | |
| let l = letter.charCodeAt(); | |
| return l >= 65 && l <= 90; | |
| } | |
| function isLowerCase(letter){ | |
| let l = letter.charCodeAt(); | |
| return l >= 97 && l <= 122; |
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 pyqrcode | |
| data = input('Please enter some text or link to generate QR code : ') | |
| qr = pyqrcode.create(data) | |
| qr.svg('qrcode.svg', scale=8) |
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
| '1,2'.split(',').map(a => "'" + a.replace("'", "''") + "'").join() |
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
| randomize() { | |
| var letters = '0123456789ABCDEF'; | |
| var color = '#'; | |
| for (var i = 0; i < 6; i++) { | |
| color += letters[Math.floor(Math.random() * 16)]; | |
| } | |
| return color; | |
| } |
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 class AsciiValue { | |
| public static void main(String[] args) { | |
| int x; | |
| for (x = 0; x <= 255; x++) { | |
| System.out.println("The ASCII value of " + String.format("%c", x) + " is: " + String.format("%d", x)); | |
| } | |
| } | |
| } |