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 elementsBetweenEvenNumbers = (arr) => { | |
| return arr.reduce((x, current) => { | |
| x[0].push(current) | |
| if (x[0].length === 3) { | |
| if (x[0][0] % 2 === 0 && x[0][2] % 2 === 0) | |
| x[1].push(x[0][1]) | |
| x[0] = x[0].slice(1) | |
| } | |
| return x | |
| }, [[],[]])[1] |
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 requests | |
| def get_all_planets(): | |
| page = 0 | |
| planets = [] | |
| next_url = "https://swapi.co/api/planets/" | |
| while next_url: | |
| resp = requests.get(next_url).json() | |
| next_url = resp['next'] |
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 MSG_ROTATE = [0x0A,0x17,0x0F]; | |
| let convertDegreeToHex = (degree) => { | |
| var view = new DataView(new ArrayBuffer(4)); | |
| view.setFloat32(0, degree); | |
| return Array | |
| .apply(null, { length: 4 }) | |
| .map((_, i) => view.getUint8(i)) | |
| } |
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
| let writePacket = (characteristic, buff, waitForNotification=false, timeout=0) => { | |
| return new Promise(function(resolve, reject) { | |
| let dataRead = []; | |
| let checkIsAValidRequest = (dataRead) => { | |
| if (dataRead[5] != 0x00) { | |
| characteristic.removeListener('data', listenerForRead); | |
| reject(dataRead[5]); | |
| } |
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 noble = require('noble'); | |
| let connectTheDroid = (address) => { | |
| return new Promise((resolve, reject) => { | |
| noble.on('discover', (peripheral) => { | |
| if (peripheral.address === address) { | |
| noble.stopScanning(); | |
| peripheral.connect( (e) => { | |
| peripheral.discoverServices([CONNECT_SERVICE], (error, services) => { | |
| services[0].discoverCharacteristics([CONNECT_CHAR], (error, characteristics) => { |
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 ESC = 0xAB; | |
| const SOP = 0x8D; | |
| const EOP = 0xD8; | |
| const ESC_ESC = 0x23; | |
| const ESC_SOP = 0x05; | |
| const ESC_EOP = 0x50; | |
| let seq = 0; | |
| let buildPacket = (init, payload=[]) => { |
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
| let calculateChk = (buff) => { | |
| let ret = 0x00; | |
| for (let i = 0 ; i < buff.length ; i++) { | |
| ret += buff[i]; | |
| } | |
| ret = ret & 255; | |
| return (ret ^ 255); | |
| } |
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 CONNECT_SERVICE = "00020001574f4f2053706865726f2121"; | |
| const CONNECT_CHAR = "00020005574f4f2053706865726f2121"; | |
| const MAIN_SERVICE = "00010001574f4f2053706865726f2121"; | |
| const MAIN_CHAR = "00010002574f4f2053706865726f2121"; | |
| const MSG_CONNECTION = [0x75,0x73,0x65,0x74,0x68,0x65,0x66,0x6F,0x72,0x63,0x65,0x2E,0x2E,0x2E,0x62,0x61,0x6E,0x64]; | |
| const MSG_INIT = [0x0A,0x13,0x0D]; | |
| const MSG_OFF = [0x0A,0x13,0x01]; |
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
| from createsend import Subscriber | |
| from createsend.createsend import BadRequest | |
| class CampaignMonitorException(Exception): | |
| pass | |
| class CampaignMonitorListSubscriber(): |
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
| yum install fontconfig freetype freetype-devel fontconfig-devel libstdc++ | |
| wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 | |
| tar -xjvf ~/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 --strip-components 1 /opt/phantomjs/ | |
| sudo yum install libffi-devel openssl-devel | |
| pip install pyopenssl pyasn1 | |
| pip install requests[security] |
NewerOlder