Skip to content

Instantly share code, notes, and snippets.

View devjaime's full-sized avatar
😉
My job is to make your experience the best

Jaime Hernández devjaime

😉
My job is to make your experience the best
View GitHub Profile
import random
import csv
from datetime import timedelta
def load_circles(filename):
with open(filename, 'r') as csvfile:
reader = csv.reader(csvfile)
rows = list(reader)[1:]
for row in rows:
c = Circle.objects.create(
@devjaime
devjaime / scriptMain.cs
Created July 13, 2021 02:23
ETL SSIS upload file sftp
#region Help: Introduction to the script task
/* The Script Task allows you to perform virtually any operation that can be accomplished in
* a .Net application within the context of an Integration Services control flow.
*
* Expand the other regions which have "Help" prefixes for examples of specific ways to use
* Integration Services features within this script task. */
#endregion
#region Namespaces
@devjaime
devjaime / .js
Created April 2, 2021 15:57
index.js El código de la interfaz debe realizar una solicitud a la función de la nube para crear un cargo
<!DOCTYPE html>
<html lang="en">
<head>
<title>Coinbase Demo</title>
</head>
<body>
<button id="btn">Comprar cn Criptomonedas</button>
@devjaime
devjaime / .js
Created April 2, 2021 15:52
Cree otra función de nube HTTP para manejar webhooks.
exports.webhookHandler = functions.https.onRequest(async (req, res) => {
const rawBody = req.rawBody;
const signature = req.headers['x-cc-webhook-signature'];
const webhookSecret = 'your webhook';
try {
const event = Webhook.verifyEventBody(rawBody, signature, webhookSecret);
if (event.type === 'charge:pending') {
// TODO
@devjaime
devjaime / .js
Created April 2, 2021 15:33
index.js Crear un cargo
exports.createCharge = functions.https.onRequest((req, res) => {
cors(req, res, async () => {
// TODO get real product data from database
const chargeData = {
name: 'Widget',
description: 'Usando una pasarela de prueba',
local_price: {
amount: 9.99,
currency: 'USD',
@devjaime
devjaime / .js
Created April 2, 2021 15:27
index.js importa los paquetes requeridos
const functions = require('firebase-functions');
const cors = require('cors')({ origin: '*' });
const { Client, Webhook, resources } = require('coinbase-commerce-node');
const coinbaseSecret = 'your-api-key';
const signingSecret = 'your-webhook-secret';
Client.init(coinbaseSecret);
const { Charge } = resources;
@devjaime
devjaime / .dart
Created March 21, 2021 06:17
La clase Stream también viene con algunos constructores útiles. Éstos son los más comunes
Stream.fromIterable([1, 2, 3]);
Stream.value(10);
Stream.empty();
Stream.error(Exception('ups! algo salio mal'));
Stream.fromFuture(Future.delayed(Duration(seconds: 1), () => 42));
Stream.periodic(Duration(seconds: 1), (index) => index);
@devjaime
devjaime / .dart
Created March 21, 2021 06:10
Cómo usar try, on, catch, rethrow,finally.
Future<void> printWeather() async {
try {
final api = WeatherApiClient();
final weather = await api.getWeather('London');
print(weather);
} on SocketException catch (_) {
print('No se pudieron recuperar los datos. Comprueba tu conexión');
} on WeatherApiException catch (e) {
print(e.message);
} catch (e, st) {
@devjaime
devjaime / .dart
Created March 21, 2021 05:06
Collection-if y spreads son muy útiles cuando escribe su interfaz de usuario como código
const restaurant = {
'name' : 'Pizza Mario',
'cuisine': 'Italian',
if (addRatings) ...{
'avgRating': 4.3,
'numRatings': 5,
}
};
@devjaime
devjaime / .dart
Created March 21, 2021 05:03
Por ejemplo, aquí hay una función simple para calcular el cuadrado de un número
int square(int value) {
// solo un simple ejemplo
// podría ser una función compleja con mucho código
return value * value;
}
// Dada una lista de valores, podemos mapearlos para obtener los cuadrados:
const values = [1, 2, 3];
values.map(square).toList();