Skip to content

Instantly share code, notes, and snippets.

@Vestride
Vestride / encoding-video.md
Last active March 12, 2024 16:41
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
@borama
borama / tailwind_form_builder.rb
Last active February 28, 2024 10:56
Tailwind-styled Simple Form builder example - see https://dev.to/nejremeslnici/styling-simple-form-forms-with-tailwind-4pel for all details
# This is a thin wrapper of the Simple Form builder. It delegates rendering the resulting form fields to Simple Form
# but typically amends the Tailwind classes of the various elements in the field layout. It tightly integrates with the
# unstyled wrapper (aka `:plain`) Simple Form configuration (see `simple_form.rb`). The methods support the same syntax
# as the original Simple Form methods but enhance it to support replacing defaylt Tailwind claseses.
class Builders::TailwindFormBuilder < SimpleForm::FormBuilder
# This is the basic method for rendering `<input>` tags and their variants.
def input(attribute_name, options = {}, &block)
# The default Tailwind classes for the various parts of the Simple Form wrapper layout.
input_class = "block w-full sm:text-sm ... #{'text-gray-500 bg-gray-50' if options.dig(:input_html, :disabled)}"
@brandonkelly
brandonkelly / templating.md
Last active February 7, 2024 15:20
Templating in EE vs. Craft
@jonbretman
jonbretman / type.js
Last active January 16, 2024 01:16
Simple type checking in JavaScript.
(function (root) {
var type = function (o) {
// handle null in old IE
if (o === null) {
return 'null';
}
// handle DOM elements
@stevebourne
stevebourne / Gemfile
Created April 15, 2012 19:28
Add facebook auth to a Clearance app, using omniauth-facebook
gem 'omniauth'
gem 'omniauth-facebook'
gem 'clearance'
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@alex-zige
alex-zige / gist:5795358
Last active June 8, 2023 07:49
Rails Rspec API Testing Notes

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views
class AppleSignInController < ApplicationController
APPLE_PEM_URL = "https://appleid.apple.com/auth/keys"
# /api/apple/validate
def validate
name = params[:name]
userIdentity = params[:userIdentity]
jwt = params[:jwt]
@adamwathan
adamwathan / v-cloak.md
Last active February 26, 2023 14:26
Useful CSS utilities for Vue.js cloaking

Handy helpers for controlling visibility of elements until Vue has compiled.

Use like:

<div v-cloak>
  <h1>
    <span class="v-cloak--inline">Loading...</span> <!-- Only displayed before compiling -->
    <span class="v-cloak--hidden">{{ post.title }}</span> <!-- Hidden until compiling is finished -->
 
@searls
searls / client.js
Created May 13, 2018 14:05
Sometimes I find it handy when I'm developing a single page app to have all front-end errors forwarded to the backend's log (when something doesn't work, I can look in a single terminal window)
const puts = (...anything) => {
fetch("/api/puts", {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({content: anything})
})
}