Skip to content

Instantly share code, notes, and snippets.

View lporras's full-sized avatar
🏠
Working from home

Luis Alfredo Porras Páez lporras

🏠
Working from home
View GitHub Profile
@lporras
lporras / compress.js
Created May 3, 2024 22:26
Compress Image Imagemagick
// npm install imagemagick
const fs = require('fs');
const { exec } = require('child_process');
// Function to compress PNG using ImageMagick
function compressPNG(inputFile, outputFile, quality = 80) {
const command = `convert ${inputFile} -quality ${quality} ${outputFile}`;
exec(command, (error, stdout, stderr) => {
@lporras
lporras / create_buckets.ts
Created October 6, 2023 15:08
Create Buckets in s3 with CloudFormation
import * as cdk from 'aws-cdk-lib';
import { CfnOutput } from 'aws-cdk-lib';
import { Bucket, CfnBucket } from 'aws-cdk-lib/aws-s3';
import { Construct } from 'constructs';
class L3Bucket extends Construct {
constructor(scope: Construct, id: string, expiration: number){
super(scope, id);
new Bucket(this, id, {
@lporras
lporras / settings.json
Created April 7, 2022 21:56
unnecessary code highlighted
{
"workbench.colorCustomizations": {
"editorUnnecessaryCode.border": "red"
}
}
@lporras
lporras / CSV JSON.md
Last active March 11, 2020 09:52
CSV JSON Example
id,name,email
1,luis,luis@gmail.com
2,juan,juan@gmail.com
[
  { id: "1", name: "luis", email: "luis@gmail.com"},
 { id: "2", name: "juan", email: "juan@gmail.com"}
@lporras
lporras / macro.vb
Last active October 19, 2019 20:53
How to run a macro when certain cells change in Excel
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
' The variable KeyCells contains the cells that will
' cause an alert when they are changed.
Set KeyCells = Range("A1:C10")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
@lporras
lporras / desarrollador_fullstack_semi_senior.md
Created October 3, 2019 18:34
Desarrollador Full-Stack Ruby on Rails Webdox

Nombre empresa: Webdox

Puesto Ofrecido: Desarrollador Full-Stack

Perfil Requerido:

Buscamos desarrolladores Web que cumplan con los sgtes requisitos:

  • Al menos 2 años de experiencia.
  • Experiencia en Ruby on Rails.
  • Familiarizado con librerías y frameworks de desarrollo Frontend (React, Vue, Angular).
@lporras
lporras / Tips: Hirb Gem
Created January 13, 2011 22:11
How to user Hirb gem in rails 3
1. add to gemfile:
gem 'hirb'
2. run bundle command
3. open the rails console
4. input: require 'hirb'
5. Enable the use of hirb on rails console: Hirb.enable

Easy steps for CPU profiling a Rails app

  1. add ruby-prof to your gemfile (https://github.com/ruby-prof/ruby-prof)
  2. grab kcachegrind or qcachegrind (brew install qcachegrind graphviz on os x)
  3. plop development_profiler.rb in lib in your app
  4. wrap your questionable code in a prof block
  5. open the file in qcachegrind
@lporras
lporras / profiling-example-image.png
Last active August 7, 2019 16:15
Profiling with Ruby-Prof
profiling-example-image.png
@lporras
lporras / fetch-chunked.js
Created July 5, 2019 14:51 — forked from jfsiii/fetch-chunked.js
Quick example of using fetch to parse a chunked response
var chunkedUrl = 'https://jigsaw.w3.org/HTTP/ChunkedScript';
fetch(chunkedUrl)
.then(processChunkedResponse)
.then(onChunkedResponseComplete)
.catch(onChunkedResponseError)
;
function onChunkedResponseComplete(result) {
console.log('all done!', result)
}