Skip to content

Instantly share code, notes, and snippets.

View Rio517's full-sized avatar

Mario Olivio Flores Rio517

View GitHub Profile
@LostKobrakai
LostKobrakai / form_live.ex
Last active April 12, 2024 18:56
Phoenix LiveView form with nested embeds and add/delete buttons
defmodule NestedWeb.FormLive do
use NestedWeb, :live_view
require Logger
defmodule Form do
use Ecto.Schema
import Ecto.Changeset
embedded_schema do
field :name, :string
@goofansu
goofansu / app.js
Last active August 5, 2023 04:05
LiveView upload directly to AWS China S3
let Uploaders = {}
Uploaders.S3 = function (entries, onViewError) {
entries.forEach(entry => {
let xhr = new XMLHttpRequest()
onViewError(() => xhr.abort())
xhr.onload = () => (xhr.status === 200 ? entry.done() : entry.error())
xhr.onerror = () => entry.error()
xhr.upload.addEventListener("progress", event => {
if (event.lengthComputable) {
sudo apt install -y autoconf automake build-essential python-dev libtool libssl-dev pkg-config
cd /tmp
git clone https://github.com/facebook/watchman.git -b v4.9.0 --depth 1
cd watchman/
./autogen.sh
./configure --enable-lenient
make
sudo make install
@bnhansn
bnhansn / 0002_sidekiq_initial.config
Created June 29, 2016 14:24
AWS Sidekiq Restart Configuration
---
restart_sidekiq: &RESTART_SIDEKIQ
mode: "000755"
content: |
#!/bin/bash
initctl restart sidekiq || initctl start sidekiq
ln -sf /var/app/current/log/sidekiq.log /var/app/containerfiles/logs/sidekiq.log
mute_sidekiq: &MUTE_SIDEKIQ
mode: "000755"
content: |
@nidamanx
nidamanx / Create Development Icons.jsx
Last active February 6, 2016 21:21 — forked from twonjosh/Create iOS Icons.jsx
Photoshop Script to Create Android, iOS, WIndows Phone Icons from a source image
// Photoshop Script to Create iPhone Icons from iTunesArtwork
//
// WARNING!!! In the rare case that there are name collisions, this script will
// overwrite (delete perminently) files in the same folder in which the selected
// iTunesArtwork file is located. Therefore, to be safe, before running the
// script, it's best to make sure the selected iTuensArtwork file is the only
// file in its containing folder.
//
// Copyright (c) 2010 Matt Di Pasquale
// Added tweaks Copyright (c) 2012 by Josh Jones http://www.appsbynight.com
@ssaunier
ssaunier / sidekiq.config
Created September 24, 2015 09:30
Running Sidekiq on AWS Elastic Beanstalk (Put that file in `.ebextensions` folder)
# Sidekiq interaction and startup script
commands:
create_post_dir:
command: "mkdir -p /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq.sh":
mode: "000755"
owner: root
group: root
// Set up global May Day object (md) to attach functions to
var md = md || {};
(function($, md) {
// dollar sign ($) == jQuery
// Can add new functions to the jQuery prototype
$.fn.newFunction = function() {
return true;
}
@ktkaushik
ktkaushik / Steps
Created April 30, 2012 15:04
install mongoDB on Ubuntu
1) receive the key that 10gen has setup
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
2) sudo vi /etc/apt/sources.list and add this line at the end
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
3) Update. This step is very important to load everything from sources.list from the previous step.
@dingsdax
dingsdax / damerau_levenshtein.rb
Created January 9, 2011 19:42
string similarity metrics in ruby
# extension for string class
class String
# return character array of string with indices
def each_char_with_index
i = 0
split(//).each do |c|
yield i, c
i += 1
end
end