Skip to content

Instantly share code, notes, and snippets.

@alexrqs
alexrqs / translate2ip.sh
Created March 4, 2019 15:11
Linux command to see the ip of a domain, no curl necessary
dig +short google.com
host google.com
nslookup google.com
const int LED = 13;
const int PWR = 12;
char blueName[4] = "lazy";
char pin[5] = "0000";
char blueSpeed = "4";
char mode = "1"; // 0 slave, 1 master
void setup() {
pinMode(LED, OUTPUT);
@alexrqs
alexrqs / loadUniqueScripts.js
Last active September 4, 2019 12:39
How to load only one time even if the script is required multiple times, and how to check or detect if the script is loaded.
// keep track of the loaded libraries
const loadedLibraries = []
function registerLibraryLoaded(id) {
// record the libs only if the array doesn't contain the same already
if (loadedLibraries.indexOf(id) < 0) {
loadedLibraries.push(id)
}
}
@alexrqs
alexrqs / get-window-user-props.js
Created August 28, 2018 20:36
Get window properties defined by the user
(function () {
var results, currentWindow,
// create an iframe and append to body to load a clean window object
iframe = document.createElement('iframe');
iframe.style.display = 'none';
document.body.appendChild(iframe);
// get the current list of properties on window
currentWindow = Object.getOwnPropertyNames(window);
@alexrqs
alexrqs / videojs-plugin-events-logger.js
Last active March 6, 2025 21:41
VideoJS event list
// The events are from https://www.w3.org/TR/html5/semantics-embedded-content.html#media-elements-event-summary
import videojs from 'video.js'
const Plugin = videojs.getPlugin('plugin')
const EVENTS = [
'loadstart',
'progress',
'suspend',
'abort',
'error',
@alexrqs
alexrqs / install.sh
Created June 17, 2018 21:53
webpack boilerplate for js with babel
yarn add -D webpack webpack-cli webpack-dev-server babel-loader@next @babel/core @babel/preset-env @babel/preset-stage-0 html-webpack-plugin
@alexrqs
alexrqs / URI.js
Last active June 22, 2018 16:03
URI parser to avoid the regex use when all you need is host, pathname, port, search..
function parseURL(url) {
// Assign resource as string
const parser = document.createElement('a')
parser.href = url
return {
// hash // == "#chiripiorca"
hash: parser.hash,
// host // == "www.chespirito.com:3000"
host: parser.host,
@alexrqs
alexrqs / App.jsx
Created May 11, 2017 00:56
Very ugly TodoApp with create-react-app redux, classnames and transitions to explain on pioneras developers
import React, { Component } from 'react'
import TodoList from './components/TodoList'
import TodoInput from './components/TodoInput'
import Filter from './components/Filter'
import './App.css'
class App extends Component {
render() {
return (
<div className="App">
@alexrqs
alexrqs / app.jsx
Last active April 25, 2017 20:53
Code spliting react router 4 with import() and webpack 2.4
import React, { Component } from 'react'
import { BrowserRouter as Router, Route, Link } from 'react-router-dom'
import async from './components/async'
class App extends Component {
render() {
return (
<Router>
<div>
<Route exact path="/" component={async(import('./pages/home')) } />
@alexrqs
alexrqs / webpack.config.babel.js
Last active April 24, 2017 23:12
webpack 2 configuration example with `webpack --opt.source=true` html/pug/jade, dev-server, eslint and scss
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import CompressionPlugin from 'compression-webpack-plugin'
import HtmlWebpackPlugin from 'html-webpack-plugin'
import autoprefixer from 'autoprefixer'
import webpack from 'webpack'
import path from 'path'
import PACKAGE from './package.json'