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 extractPropertiesValues(obj: any, props: string[]): any { | |
| function getNestedPropertyValue(obj: any, path: string): any | undefined { | |
| const pathArray = path.split('.'); | |
| if (pathArray.length === 1) return obj[pathArray[0]]; | |
| const prop = pathArray.splice(0, 1)[0]; | |
| if (!!!obj[prop]) { | |
| console.log( | |
| '[xyz] PropNotFound:', | |
| { prop, obj, pathArray } | |
| ); |
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 fs = require('fs'); | |
| const jsonToCsv = (data, filename) => { | |
| const allProperties = new Set(); | |
| for (const record of data) { | |
| extractProperties(record, '', allProperties); | |
| } | |
| const properties = Array.from(allProperties).sort(); | |
| // Generar los datos para el archivo |
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 'dart:io'; | |
| void main() { | |
| int port = 8080; | |
| HttpServer.bind(InternetAddress.anyIPv4, port).then((HttpServer server) { | |
| print("HttpServer listening... localhost:$port"); | |
| server.serverHeader = "Sample websocket server"; | |
| server.listen((HttpRequest request) { | |
| if (WebSocketTransformer.isUpgradeRequest(request)) { | |
| WebSocketTransformer.upgrade(request).then(handleWebSocket); |
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 xVals = []; | |
| let yVals = []; | |
| let a, b, c, d, e; | |
| const learningRate = 0.2; | |
| let optimizer; | |
| function setup() { | |
| createCanvas(400, 400); |
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
| #!/bin/bash | |
| ############################################### | |
| # To use: | |
| # chmod +x install-redis.sh | |
| # ./install-redis.sh | |
| ############################################### | |
| version=5.0.0 |
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
| class FixedQueue: | |
| """ | |
| Abre y mantiene una cola de tamaño definido. | |
| :param width: Tamaño de cola | |
| :param init: Valores iniciales | |
| """ | |
| def __init__(self, width:int, init=[]): | |
| self.q = deque(init[-width:]) | |
| self.w = width | |
| def update(self, data): |
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
| #!/usr/bin/python3 | |
| import socket | |
| import threading | |
| import select | |
| import sys | |
| terminateAll = False | |
| class ClientThread(threading.Thread): |
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 array | |
| def ema(s, n): | |
| """ | |
| returns an n period exponential moving average for | |
| the time series s | |
| s is a list ordered from oldest (index 0) to most | |
| recent (index -1) | |
| n is an integer | |
| returns a numeric array of the exponential |
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 threading | |
| class ThreadJob(threading.Thread): | |
| def __init__(self,callback,event,interval): | |
| '''runs the callback function after interval seconds | |
| :param callback: callback function to invoke | |
| :param event: external event for controlling the update operation | |
| :param interval: time in seconds after which are required to fire the callback | |
| :type callback: function | |
| :type interval: int |
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 getSlopeAngle(s1,s2) { | |
| return Math.atan((s2[1] - s1[1]) / (s2[0] - s1[0])) * 180/Math.PI; | |
| } | |
| console.log(getSlopeAngle([0,0],[2,3]); // 56.309932474020215 |
NewerOlder