Skip to content

Instantly share code, notes, and snippets.

View holywyvern's full-sized avatar
💭
Ramiro

Ramiro Rojo holywyvern

💭
Ramiro
View GitHub Profile
@holywyvern
holywyvern / .rubocop.yml
Last active October 3, 2022 18:09
My rubocop file for every rails project
require:
- rubocop-rails
- rubocop-rspec
AllCops:
EnabledByDefault: true
Exclude:
- spec/support/spec_helper.rb
- spec/rails_helper.rb
- db/**/*
@holywyvern
holywyvern / confirmations_controller.rb
Created September 4, 2019 14:14
Devise override controllers for devise-jwt template
class ConfirmationsController < Devise::ConfirmationsController
respond_to :json
def new
render json: nil, status: :not_found
end
end
@holywyvern
holywyvern / function curry.js
Last active September 21, 2018 21:19
Allow curry on any function.
function makeCurryFunction(fn, length = fn.length, givenArgs = []) {
return function (...newArgs) {
const args = [...givenArgs, ...newArgs];
if (args.length >= length) {
return fn(...args);
}
return makeCurryFunction(fn, length, args);
}
}
@holywyvern
holywyvern / redux-preloader.jsx
Created September 13, 2018 14:02
Easy preloader of a redux action.
// if you need to fire a redux action when a component mounts,
// this HOC helps to make that call and keep other components small.
import React, { Component } from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
class Preloader extends Component {
static propTypes = {
dispatch: PropTypes.func.isRequired,
@holywyvern
holywyvern / deepClone.js
Created August 13, 2018 19:52
Simple deepClone for JS. (Won't rescue from stack overflows, but will preserve prototype inheritance)
function cloneObject(obj, originalStack, cloneStack) {
if (typeof obj !== 'object' || obj === null) {
return obj;
}
const cloneIndex = originalStack.indexOf(obj);
if (cloneIndex !== -1) {
return cloneStack[cloneIndex];
}
if (Array.isArray(obj)) {
const newArray = new Array(obj.length);
@holywyvern
holywyvern / Object.lua
Created May 18, 2018 19:32
Lua 5.1 class system, with class and instance getters/etters and ES5 like prototypes
local function new(class, ...)
local function lookup(table, key)
local getter = class.getters[key]
if type(getter) == "function" then
return getter(table)
end
return class.prototype[key]
end
local function newIndex(t, key, value)
local setter = class.setters[key]
@holywyvern
holywyvern / canvas-fit-window.html
Created May 19, 2017 19:32
Fit window to canvas on resize
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MMORPG</title>
<style>
.canvas {
position: absolute;
@holywyvern
holywyvern / eaton-sc.inc.php
Created February 18, 2017 13:48
EATON current sensor for Observium
<?php
if ($device['os'] == 'eaton-sc') {
{
$volt_oid = '.1.3.6.1.4.1.1918.2.13.10.90.10.30.1.40.1';
$descr = "Tension de Bateria";
$volt = snmp_get($device, $volt_oid, '-Oqv');
$type = 'eaton-sc';
$divisor = 100;
$index = 0;
// $lowlimit = 0;
@holywyvern
holywyvern / gist:5675e13d4b96613f39b9
Created March 19, 2016 15:44
Snippet HTML ffmpeg encoding HLS
ffmpeg -i http://ip/mjpg/video.mjpg -async 30 -vcodec libx264 -pix_fmt yuv420p -acodec libfdk_aac -ar 44100 -b:a 64k -threads 0 -s 640x480 -f hls -g 1 -hls_time 10 -hls_list_size 1 -hls_allow_cache 0 index.m3u8
ffmpeg -f mjpeg -r 5 -i http://ip/mjpg/video.mjpg -filter:v scale=w=640:h=480 -f mjpeg pipe:1