Skip to content

Instantly share code, notes, and snippets.

View hectorromo's full-sized avatar

Hector Romo hectorromo

View GitHub Profile
@hikoz
hikoz / layout.js
Created March 3, 2017 05:22
active tab with preact-router
import { h, Component } from 'preact';
import { Router, Link } from 'preact-router';
function Header({url}) {
const NavItem = ({href, children}, state) => (
<li className={href==url ? 'is-active' : ''}><Link href={href}>{children}</Link></li>
)
return (
<section class="hero is-primary">
<div class="hero-foot">
@tmakin
tmakin / ExportPdf.cs
Last active October 24, 2024 21:21
Create PDF Rendering service in Azure Functions
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using DinkToPdf;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using IPdfConverter = DinkToPdf.Contracts.IConverter;
@AshikNesin
AshikNesin / react-file-upload.js
Created February 2, 2017 06:46
Simple React File Upload
import React from 'react'
import axios, { post } from 'axios';
class SimpleReactFileUpload extends React.Component {
constructor(props) {
super(props);
this.state ={
file:null
}
@jnewman12
jnewman12 / AdvancedMongoose.md
Last active August 22, 2023 20:45
Advanced Mongoose

Advanced Mongoose

advanced mongoose


Objectives

  • Define virtual properties for a model
  • Modify how a model is serialized to JSON
@chranderson
chranderson / nvmCommands.js
Last active May 10, 2025 20:43
Useful NVM commands
// check version
node -v || node --version
// list locally installed versions of node
nvm ls
// list remove available versions of node
nvm ls-remote
// install specific version of node

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@xposedbones
xposedbones / map.js
Last active March 17, 2025 11:24
Javascript Map range of number to another range
Number.prototype.map = function (in_min, in_max, out_min, out_max) {
return (this - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
@typeofweb
typeofweb / Observer.js
Created May 5, 2016 16:38
Observer pattern - simple implementation
/**
* Observer pattern - simple implementation
* By Michał Miszczyszyn, 2016
*/
class Observer {
constructor() {
this.observers = [];
}
@brennanMKE
brennanMKE / hero.ts
Last active April 6, 2025 07:33
Example of Mongoose with TypeScript and MongoDb
import * as mongoose from 'mongoose';
export let Schema = mongoose.Schema;
export let ObjectId = mongoose.Schema.Types.ObjectId;
export let Mixed = mongoose.Schema.Types.Mixed;
export interface IHeroModel extends mongoose.Document {
name: string;
power: string;
@sebkouba
sebkouba / ParentChild.es6
Created February 17, 2016 06:00
Basic example to pass values between parent and child components in React.
/**
* Basic example to pass values between parent and child components in React
* Seems to be in line with this
* http://stackoverflow.com/questions/24147331/react-the-right-way-to-pass-form-element-state-to-sibling-parent-elements
* Now I have the state in parent and child. Is that good or bad? Why would I need it in child?
* Could probably take that out
* */
class Parent extends React.Component {
constructor(props) {
super(props);