Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View cesarvr's full-sized avatar
:electron:
compiling...

Cesar Valdez cesarvr

:electron:
compiling...
View GitHub Profile
@cesarvr
cesarvr / task_queue.js
Created September 27, 2022 19:23
Simple Async Task Queue
function task1() {
return new Promise((resolve) =>{
setTimeout(() => {
console.log('doing some work on state 1')
resolve({completed: true, value: 1})
}, 50)
})
@cesarvr
cesarvr / main.cpp
Last active November 5, 2020 20:39
Just a quick example to demonstrate information passing between two thread without a mutex.
#include <chrono>
#include <iostream>
#include <queue>
#include <thread>
/*
* This program demonstrate that using one thread to write and another to read is ok to get ordered values from a queue.
*
* One thread generate a ordered sequence of number, another consumes print the sequence
@cesarvr
cesarvr / relational.js
Created September 24, 2020 11:22
Quick example of relational schemes using the Realm DB.
/*
*
* Testing bi-directional relationship in Realm.
*
*/
let Realm = require('realm')
const PersonSchema = {
name: '_Person',
@cesarvr
cesarvr / mail.py
Created June 29, 2020 12:23
This script keep running looking for new emails, when it found one it sends a notification to a cloud service. If this email is a meeting it send's you a mail. You can modify this script to be an automatic email resend.
import win32com.client
import sched, time
import json
import requests
import sys
host = "https://notify-uat.e4ff.pro-eu-west-1.openshiftapps.com/notify"
REDIRECT_TO = 'your-email@server.com'
def look(obj):
def puzzleSolutionPartOne(puzzle):
lhs = ""
units = []
react = lambda a,b: a.lower() == b.lower() and a != b
for candidate in puzzle:
if lhs == "":
lhs = candidate
continue
def getRunningPod(label) {
def runningPod = sh (
script: "oc get pod --selector=application=${label} -o=jsonpath={.items[0].metadata.name}",
returnStdout: true ).trim()
return runningPod
}
def getRoute(label) {
def route = sh (
script: " oc get route --selector=application=${label} -o jsonpath={.spec.host}",
const { spawn } = require('child_process');
function pull(action) {
const git = spawn('git', ['pull'])
git.stdout.on('data', function(data) {
let msg = data.toString()
console.log('[git pull]: ', msg)
if(!msg.includes('Already up to date.')){
@cesarvr
cesarvr / image_tag.sh
Created April 21, 2020 11:25
Tagging images on Openshift
#!/bin/bash
oc create dc $1 --image=$(oc get is $1 -o=jsonpath='{.status.dockerImageRepository}'):prod || true &&
oc expose dc $1 --port=8080 -l app=$1 || true &&
oc expose svc $1 -l app=$1 || true &&
oc label dc $1 app=$1 production=true --overwrite=true || true
oc label svc $1 app=$1 production=true --overwrite=true || true
oc label route $1 app=$1 production=true --overwrite=true || true
@cesarvr
cesarvr / day-5.js
Created March 8, 2020 16:01
Solution for the Advent of Code [day-5](https://adventofcode.com/2018/day/5)
const reaction = (a,b) => a.toLowerCase() === b.toLowerCase() && a !== b
const solvingPuzzleOne = (puzzle_input) =>{
let lhs = ''
let tested = []
let size = puzzle_input.length
for(let i=0; i<size; i++){
let candidate = puzzle_input[i]
if(lhs === ''){
lhs = candidate
@cesarvr
cesarvr / pom.xml
Created November 14, 2019 16:46
deleteme
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<lombok.version>1.16.18</lombok.version>
<jboss-logging.version>3.3.1.Final</jboss-logging.version>
</properties>