This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"errors" | |
"log" | |
"net/http" | |
"os" | |
"os/signal" | |
"syscall" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ urlshortener tree -a . | |
. | |
├── .devcontainer | |
│ ├── Dockerfile | |
│ ├── devcontainer.json | |
│ └── docker-compose.yml | |
└── README.md | |
1 directory, 4 files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
speechRecognition = new webkitSpeechRecognition(); | |
speechRecognition.continuous = true; | |
speechRecognition.lang = 'pt-br'; | |
speechRecognition.interimResults = true; | |
speechRecognition.start(); | |
speechRecognition.onresult = function (event) { | |
if (typeof (event.results) == 'undefined') { | |
speechRecognition.stop(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):010:0> a = KioskConfiguration.with_computer_id('00-50-E4-00-0E-C6').count | |
(2.6ms) SELECT COUNT(*) FROM "kiosk_configurations" WHERE "kiosk_configurations"."deleted_at" IS NULL AND "kiosk_configurations"."computer_id" = $1 [["computer_id", "00-50-E4-00-0E-C6"]] | |
=> 0 | |
irb(main):011:0> KioskConfiguration.all.map &:computer_id | |
KioskConfiguration Load (3.9ms) SELECT "kiosk_configurations".* FROM "kiosk_configurations" WHERE "kiosk_configurations"."deleted_at" IS NULL | |
=> ["78-31-c1-cf-fd-12", "00-50-E4-00-0E-AC"] | |
irb(main):044:0> kc = KioskConfiguration.create computer_id: '00-50-E4-00-0E-C6' | |
(2.1ms) BEGIN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController < ApplicationController | |
def create | |
respond User::Create do |user, format| | |
format.json { render status: :created, json: user.to_json } | |
end | |
end | |
end | |
class User < ActiveRecord::Base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EANValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
unless ean_valid?(value) | |
record.errors[attribute] << (options[:message] || :bad_ean) | |
end | |
end | |
def valid?(ean) | |
return false unless ean.length == 13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Recorder | |
module Config | |
class << self | |
attr_accessor :records_path | |
end | |
end | |
def self.config | |
yield Config | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AjaxQueue = { | |
batchSize: 1, | |
urlQueue: [], | |
elementsQueue: [], | |
optionsQueue: [], | |
setBatchSize: function(bSize) { | |
this.batchSize = bSize; | |
}, | |
push: function(url, options, elementID) { | |
this.urlQueue.push(url); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$script = <<SCRIPT | |
function log_and_exec { | |
callback=${1}; | |
shift 1; | |
echo "[EXEC] $callback $@"; | |
"$callback" "$@"; | |
} | |
date > /etc/vagrant_provisioned_at | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/https' | |
require 'uri' | |
usernames_to_check = %W(macedo _macedo) | |
available = [] | |
usernames_to_check.each do |username| | |
uri = URI.parse "https://twitter.com/#{username}" | |
http = Net::HTTP.new uri.host, uri.port |
NewerOlder