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
# app/models/experience.rb | |
# | |
# == Schema Information | |
# | |
# Table name: experiences | |
# | |
# id :integer not null, primary key | |
# title :string | |
# description :text | |
# created_at :datetime not null |
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
desc "rake 'latest:sitemap' Pings search engines with current channels sitemap addresses" | |
task sitemap: :environment do | |
def http_get(domain,path,params) | |
return Net::HTTP.get(domain, "#{path}?".concat(params.collect { |k,v| "#{k}=#{CGI::escape(v.to_s)}" }.join('&'))) unless params.nil? | |
return Net::HTTP.get(domain, path) | |
end | |
Site.all.each do |channel| | |
unless channel.domain.include?("autoforce") && channel.groupables.any? | |
http_get "blogs.yandex.ru", "/pings/", {status: "success", url: (channel.domain + "/sitemap.xml")} | |
http_get "google.com", "/webmasters/tools/ping", {sitemap: (channel.domain + "/sitemap.xml")} |
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
# frozen_string_literal: true | |
module Api | |
module V1 | |
# Controller to consume read-only data to be used on client's frontend | |
class FrontEndController < ActionController::API | |
prepend_before_action :set_root_resource | |
before_action :set_object, except: %i[index schema] | |
append_before_action :set_nested_resource, only: %i[nested_index] | |
append_before_action :set_records, only: %i[index nested_index] |
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
# frozen_string_literal: true | |
# Paperclip's module | |
module Paperclip | |
# Module that contains methods used on Models | |
module ClassMethods | |
# Overriding this method to add all initialized fields into class variable | |
def has_attached_file(name, options = {}) | |
class_eval do | |
@@_paperclip_attachments ||= {} |
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
# frozen_string_literal: true | |
# A module to abstract a noSQL aproach into SQL records, using a `fields` | |
# JSON column. | |
module CustomFields | |
# Overriding `method_missing` does the magic of assigning an absent field | |
# into `.fields` JSON as a key-value pair, or recovering it's value if exists. | |
def method_missing(meth, *args, &block) | |
raise NoMethodError, "#{table_name} should have a `fields` JSON column" unless can_no_sqlize? | |
no_sqlize(meth, *args, &block) |
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
# frozen_string_literal: true | |
# An abstract model to allow common behavior to be inherited | |
class ApplicationRecord < ActiveRecord::Base | |
self.abstract_class = true | |
include Discard::Model | |
default_scope -> { kept } | |
def destroy |
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
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | |
Start-Process powershell.exe "-File",('"{0}"' -f $MyInvocation.MyCommand.Path) -Verb RunAs | |
exit | |
} | |
$DesiredIP = ((bash.exe -c "hostname -I") | Out-String) -replace '\s','' | |
$domains = "hubstaff.test","account.hubstaff.test","app.hubstaff.test","tasks.hubstaff.test","talent.hubstaff.test" | |
$hostsFilePath = "$($Env:WinDir)\system32\Drivers\etc\hosts" | |
$hostsFile = Get-Content -path $hostsFilePath -raw | |
if ($hostsFile -notmatch "`r`n$") { | |
Add-Content $hostsFilePath "`r`n" |
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
#!/bin/bash | |
ip_address=`hostname -I` | |
for host_name in hubstaff.test account.hubstaff.test app.hubstaff.test tasks.hubstaff.test talent.hubstaff.test | |
do | |
matches_in_hosts="$(grep -n " $host_name" /etc/hosts | cut -f1 -d:)" | |
host_entry="${ip_address} ${host_name}" | |
if [ ! -z "$matches_in_hosts" ] | |
then | |
echo "Replacing existing record for $host_name" | |
while read -r line_number; do |
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
#!/bin/bash | |
AWS_ACCESS_KEY_ID="" | |
AWS_SECRET_ACCESS_KEY="" | |
AWS_SESSION_TOKEN="" | |
( | |
echo "Welcome to AWS CLI MFA 😎" | |
if [ -z "$MFA_DEVICE_ARN" ]; then | |
echo "Your Multi-factor authentication device has an ARN visible at: https://console.aws.amazon.com/iam/home?region=us-east-1#/security_credentials" | |
echo | |
echo "You can export your MFA device ARN as MFA_DEVICE_ARN environmental variable to avoid having to input it every time. Just add something like this to your equivalent of a ~/.bash_profile" |
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
#! /bin/bash | |
SERVER_NAME="turn:server.turn:443" | |
SECRET=5up3r53cr7 | |
expiry=8400 | |
time=$(date +%s) | |
username="$(( $time + $expiry )):justanusername" | |
password=$(echo -n $username | openssl dgst -binary -sha1 -hmac $SECRET | openssl base64) | |
echo "server => $SERVER_NAME" |
OlderNewer