Skip to content

Instantly share code, notes, and snippets.

View sheva29's full-sized avatar

Mauricio Sanchez Duque sheva29

  • Google
  • United States
View GitHub Profile
@sheva29
sheva29 / CreditCard.js
Last active September 13, 2018 01:38
React component - trigger event
import React from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import { Field, Fields, reduxForm, getFormValues, initialize } from 'redux-form';
import { PageHeader, PageBody, PageFooter } from '../../Layout';
import FieldText, { FieldExpDate,
required,
validateName
} from '../../forms/FieldText';
import FieldSelect from '../../forms/FieldSelect';
@sheva29
sheva29 / remove_old_gae_versions.sh
Last active April 1, 2018 18:13
Shell script to remove old versions of GAE services while deploying in Drone
#!/bin/bash
# keep only latest 2 versions of a GAE service based on the latest version numbers
VERSIONS=$(gcloud app versions list --service $1 --sort-by '~version' --format 'value(version.id)')
COUNT=0
echo "Keeping the $2 latest versions of the $1 service"
for VERSION in $VERSIONS
do
((COUNT++))
if [ $COUNT -gt $2 ]
then
@sheva29
sheva29 / generate_price_average.sh
Created March 22, 2018 14:09
This script looks at the number of occurrences for prices given a a crypto currency for 1 day, takes the first top 10, averages them and puts them in a new csv file
#!/bin/bash
# script to be at the same level as input folder and output folder
INPUT_FOLDER='bittrex-bot/*'
OUTPUT_FOLDER='csv_output/'
OUTPUT_FILE_FORMAT=".csv"
for file in $INPUT_FOLDER
do
# file name
NAME=${file##*/}
number_of_lines=10
@sheva29
sheva29 / Snippet.java
Created January 12, 2018 19:49
Parelelizing Void Method in Java using google Thread Factory
ThreadFactory factory = com.google.appengine.api.ThreadManager.currentRequestThreadFactory();
ExecutorService service = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), 16, 60, TimeUnit.SECONDS, new SynchronousQueue<>(), factory);
List<Future<Void>> futures = new ArrayList<>();
for (String tempStopAccountId : aristoDto.getTempStopHdAccountIds()) {
if (aristoDto.getProductFileDtoMap().get(tempStopAccountId) != null) {
aristoDto.getProductFileDtoMap().get(tempStopAccountId).setTempAccount(true);
}
Callable<Void> callable = () -> {
futures.add(processCancellation(tempStopAccountId));
@sheva29
sheva29 / canary_check.py
Last active August 22, 2017 22:01
Template for python script to ping canary deployment
import json
import urllib.request
import time
from datetime import datetime
MIN_TO_RUN = 1000
BODY = '{"taxDivision":"PRT","postalCode":"90210","country":"US","state":"CA","city":"Beverly Hills","currency":"USD","items":[{"id":"ID_1","unitPrice":100.00,"quantity":1,"productClass":"Newspaper","extendedPrice":100.00}]}'
@sheva29
sheva29 / ConvertingObj.cs
Created July 5, 2017 21:20
Converting obj to same type
private static T ConvertType<T>(object instance)
{
if (instance == null)
{
throw new ArgumentNullException("instance");
}
var typeSource = instance.GetType();
var typeDestination = typeof(T);
@sheva29
sheva29 / insert_entry.sql
Created April 21, 2017 20:24
INSERT SQL
/****** Script for SelectTopNRows command from SSMS ******/
SET IDENTITY_INSERT [WindstreamPLUT].[dbo].[ProductDependent] ON
INSERT INTO [WindstreamPLUT].[dbo].[ProductDependent] (ProductDependentID, ParentProductID, DependentProductID, RelationshipCd, DefaultFlg, CreateUTCDt, UpdateUTCDt, ParentProductQuantity)
VALUES ('84214', '20442', '20587', 'M', '1', '2017-04-21 19:40:25.237', '2017-04-21 19:41:25.237', NULL)

Keybase proof

I hereby claim:

  • I am sheva29 on github.
  • I am sheva29 (https://keybase.io/sheva29) on keybase.
  • I have a public key ASAb6X9ExGvIkoMJlXB8Vj_wkfQAfAdK0aCPPj0hR-YQFAo

To claim this, I am signing this object:

@sheva29
sheva29 / RegEx.txt
Last active June 6, 2017 17:12
RegEx
/*
Custom Regular Expressions
To test Regex go here: http://www.regextester.com/
*/
/* 1. Looking for specific Regex with negative look up*/
^((?!For example: Make a left at the blue sign and park by the red door).)*$
/* 2. Setting a maximun Character count*/
^.{1,70}$
/* when trying to console.log in Angular */
JSON.stringify($scope, function(key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Circular reference found, discard key
return;
}
// Store value in our collection
cache.push(value);