Skip to content

Instantly share code, notes, and snippets.

View rin's full-sized avatar

Rin Raeuber rin

View GitHub Profile
@rin
rin / aws-lambda-youtube-dl.js
Created December 23, 2020 19:30
AWS Lambda to download youtube videos to S3
// To use this, put it in a folder, install ytdl-core with `npm i ytdl-core`, then create a ZIP with the content of the folder and deploy it.
// https://docs.aws.amazon.com/lambda/latest/dg/nodejs-package.html#nodejs-package-dependencies
var AWS = require('aws-sdk');
const ytdl = require('ytdl-core');
const stream = require('stream');
var s3 = new AWS.S3();
exports.handler = async (event, context, cb) => {
const { videoUrl, key, bucket } = event;
@rin
rin / bugsnag.js
Created February 5, 2019 02:20
Bugsnag Grouping Hash
bugsnagClient.notify(new Error('Page not found (404)'), {
beforeSend: (report) => {
report.groupingHash = report.request.url;
report.severity = 'info';
},
})
@rin
rin / VideoPreview.jsx
Last active September 20, 2018 10:35
React component for videojs
import React, { Component } from 'react';
import { PropTypes as T } from 'prop-types';
import videojs from 'video.js';
// a component for use with videojs
// use it like this:
// <VideoPreview video={myVideo} key={myVideo.id} />
export default class VideoPreview extends Component {
ref = React.createRef();
@rin
rin / my_object.rb
Created April 13, 2017 11:25 — forked from anonymous/my_object.rb
Custom Validator for JSON in Rails
class MyObject < ActiveRecord::Base
class JsonValidator < ActiveModel::EachValidator
def initialize(options)
options.reverse_merge!(:message => :invalid)
super(options)
end
def validate_each(record, attribute_before_typecast, value)
attribute = attribute_before_typecast.to_s.sub('_before_type_cast', '')
value = value.strip if value.is_a?(String)

My Atom config

@rin
rin / brew_tea
Created November 3, 2014 14:58
Brew tea instead of beer
export HOMEBREW_INSTALL_BADGE='🍵'
@rin
rin / vibrator-example.rb
Created October 25, 2014 10:42
Using Dino to control a vibrator
require 'bundler/setup'
require 'dino'
OUTPUT_PIN = 9
module Dino
module Components
class Vibrator < BaseComponent
def output(value)
analog_write(self.pin, value)
@rin
rin / map.js
Created September 10, 2014 16:37
map function for the withSourceCases view
function(doc) {
if(doc.SourceCase !== 'undefined'){
emit(doc._id, {
lastName: doc.Surname,
otherNames: doc.OtherNames,
sourceCase: doc.SourceCase,
sourceCaseId: doc.sourcerCaseId
});
}
}
@rin
rin / ngPopup directive
Created January 15, 2014 09:19
Angular directive for a popup
app.directive 'ngPopup', [ ->
restrict: 'A'
link: (scope, element, attr) ->
element.click (e) ->
url = element.attr('href')
width = 575
height = 400
left = ($(window).width() - width) / 2
top = ($(window).height() - height) / 2