Skip to content

Instantly share code, notes, and snippets.

View matiasfha's full-sized avatar

Matías Hernández Arellano matiasfha

View GitHub Profile
@matiasfha
matiasfha / client.html
Created June 6, 2011 16:04
nodejs + thrift +socket.io for image streaming
<script src="jquery-1.6.1.min.js"></script>
<script src="socket.io/socket.io.js"></script>
<script>
var socket = new io.Socket(null,{port:8080});
socket.connect();
socket.on('message',function(obj){
switch(obj.tipo){
case 'imagen':
img = document.getElementById('stream');
img.src="";
export actions = {
prepyment: async ({ request }) => {
const formData = await request.formData()
const price = formData.get('price')
const email = formData.get('email')
const url = await generateCheckout(price, email)
return { success: true, url }
}
}
function App() {
function [currentWeather, setCurrentWeather] = useState() // No hay estado al principio
React.useEffect(() => {
api.local_current("AR")
.then(data => setCurrentWeather(data))
.catch(error => {
console.error(error)
})
## Set credentials
from dotenv import load_dotenv
load_dotenv()
import cloudinary
import cloudinary.uploader
import cloudinary.api
import pprint
pp = pprint.PrettyPrinter(indent=2)
export const stringToPastelColour = function (str: string): string {
let hash = 0;
for (let i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 6) - hash);
hash = hash & hash; // Convert to 32bit integer
}
const shortened = hash % 360;
return 'hsl(' + shortened + ',100%,35%)';
};
@matiasfha
matiasfha / forEachExample.js
Last active October 19, 2022 14:19
Exmaple
/*
* shameless plug: https://www.escuelafrontend.com/articulos/metodos-de-arreglos
*/
const arr = [1,2,3,]
const failureMessages = []
arr.forEach((item) => {
failureMessages.push("<li>${item}</li>")
@matiasfha
matiasfha / Example.jsx
Created September 27, 2022 22:42
Routing example
/*
* App.jsx main entry
*/
const SomethingElse = React.lazy(() => import('pages/SomethingElse'));
function App() {
return (
<BrowserRouter>
<Switch>
<Route path="/" component={Home} />
<Route path="/somethinElse" component={SomethingElse} />
@matiasfha
matiasfha / createSharingImage.js
Last active May 3, 2022 22:19
createSharingImage utility function using cloudinary transformations
const createSharingImage = ({ cloudName, text }) => {
const imageTransformations = [
'w_1200',
'h_627',
'c_fill',
'q_auto',
'f_auto'
].join(',')
const textTransformations = [
'w_600',
import * as React from 'react';
import { send } from 'xstate/lib/actionTypes';
import { Info } from './components.styled';
import { StatusMachineContext } from './StatusMachineProvider';
import { useSelectors } from './useSelectors';
export const InfoComponent = () => {
const { isQueue, isInProgress, isCancelled, isBid } = useSelectors();
const { statusService } = React.useContext(StatusMachineContext);
@matiasfha
matiasfha / whoAmI.ts
Created July 12, 2021 00:07
Who Am I
const whoAmI = {
work: "Senior Engineer at Clevertech",
egghead: "https://matiasfha.dev/egghead",
escuelafrontend: "https://escuelafrontend.com",
auth0: "Ambassador",
cloudinary: "Media Developer Expert",
AWS: "Communityu Builder",
"Cafe con Tech": "https://matiasfha.dev/podcast",
"Control Remoto": "https://controlremoto.io",
"Site": "https://matiashernandez.dev",