Skip to content

Instantly share code, notes, and snippets.

View arman-h's full-sized avatar

Arman Harutyunyan arman-h

View GitHub Profile
// components/ResourceableControls.jsx
import useResourceableStore from '@/stores/resourceableStore'
/**
* This renders the Edit/Save/Cancel buttons.
* It's generic and works with any resource type.
*/
export default function ResourceableControls({
resource, // The resource being edited
resourceType, // Type of resource ('user', 'case', etc)
@arman-h
arman-h / 20190101000000_create_users.rb
Created April 23, 2019 01:43
Stripe.com-like basic authentication with Rails 5 + Warden
# db/migrate/20190101000000_create_users.rb
class CreateUsers < ActiveRecord::Migration[5.2]
def change
create_table :users do |t|
t.string :api_key, index: true
t.timestamps
end
end
end
@arman-h
arman-h / ffmppeg-advanced-playbook-nvenc-and-libav-and-vaapi.md
Created February 14, 2019 00:44 — forked from Brainiarc7/ffmppeg-advanced-playbook-nvenc-and-libav-and-vaapi.md
FFMpeg's playbook: Advanced encoding options with hardware-accelerated acceleration for both NVIDIA NVENC's and Intel's VAAPI-based hardware encoders in both ffmpeg and libav.

FFmpeg and libav's playbook: Advanced encoding options with hardware-based acceleration, NVIDIA's NVENC and Intel's VAAPI-based encoder.

Hello guys,

Continuing from this guide to building ffmpeg and libav with NVENC and VAAPI enabled, this snippet will cover advanced options that you can use with ffmpeg and libav on both NVENC and VAAPI hardware-based encoders.

For ffmpeg:

@arman-h
arman-h / texttopdftools.md
Created September 27, 2018 00:41 — forked from geramirez/texttopdftools.md
Command Line Text to PDF Tools
@arman-h
arman-h / upgrade-postgres-9.5-to-9.6.md
Created September 14, 2018 00:07 — forked from delameko/upgrade-postgres-9.5-to-9.6.md
Upgrading PostgreSQL from 9.5 to 9.6 on Ubuntu 16.04

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.6 main --stop
sudo pg_upgradecluster 9.5 main
sudo pg_dropcluster 9.5 main
@arman-h
arman-h / Oauth2.md
Created August 22, 2017 08:46 — forked from mziwisky/Oauth2.md
Oauth2 Explanation

OAUTH2

The Problem

I’m a web app that wants to allow other web apps access to my users’ information, but I want to ensure that the user says it’s ok.

The Solution

I can’t trust the other web apps, so I must interact with my users directly. I’ll let them know that the other app is trying to get their info, and ask whether they want to grant that permission. Oauth defines a way to initiate that permission verification from the other app’s site so that the user experience is smooth. If the user grants permission, I issue an AuthToken to the other app which it can use to make requests for that user's info.

Note on encryption

Oauth2 has nothing to do with encryption -- it relies upon SSL to keep things (like the client app’s shared_secret) secure.

@arman-h
arman-h / flatten_array.rb
Created December 16, 2016 10:08
Flatten an array with Ruby without using built-in methods
def recursively_flatten_an_array(nested_array, flattened_array = [])
nested_array.each do |obj|
unless obj.is_a? Array
flattened_array << obj
else
recursively_flatten_an_array(obj, flattened_array)
end
end
return flattened_array
@arman-h
arman-h / Gemfile
Created September 23, 2015 03:37
Sinatra + Mongoid CRUD Sample
source 'http://rubygems.org'
gem 'rack'
gem 'rack-flash'
gem 'thin'
gem 'sinatra', :require => 'sinatra/base'
gem 'mongoid'
gem 'bson_ext'
gem 'slim'
source :rubygems
gem 'thin'
gem 'slim'
gem 'sass'
gem 'sinatra'
gem 'sprockets'
gem 'sinatra-partial'
gem 'coffee-script'
gem 'therubyracer'
@arman-h
arman-h / 20130516013336_create_fetchers.rb
Last active December 17, 2015 11:58
Setting up Delayed Jobs and Workless with Rails and Heroku. This app creates delayed jobs to fetch large remote files using Mechanize.
# db/migrate/20130516013336_create_fetchers.rb
# Table to store fetched/unfetched files.
class CreateFetchers < ActiveRecord::Migration
def change
create_table :fetchers do |t|
t.string :url
t.binary :file
t.string :status