CLICK ME
yes, even hidden code blocks!
print("hello world!")
# Original source: https://gist.github.com/hopsoft/56ba6f55fe48ad7f8b90 | |
# Merged with: https://gist.github.com/kofronpi/37130f5ed670465b1fe2d170f754f8c6 | |
namespace :db do | |
desc 'Dumps the database to backups' | |
task dump: :environment do | |
dump_fmt = ensure_format(ENV['format']) | |
dump_sfx = suffix_for_format(dump_fmt) | |
backup_dir = backup_directory(Rails.env, create: true) | |
full_path = nil | |
cmd = nil |
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
#payload: [{"kind"=>"person"}] | |
Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
#data: {"interest"=>["music", "movies", "programming"]} | |
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
Segment.where("jsonb_array_length(data->'interest') > 1") |
@echo off | |
echo *************************************************************** | |
echo *************************************************************** | |
echo *** This Script will stop Windows 10 Spying you...YEYYYY!!! *** | |
echo *************************************************************** | |
echo *** We will Disable Data Logging Services *** | |
echo *** We will Configure Windows Explorer *** | |
echo *** We will Uninstall OneDrive *** | |
echo *** We will edit Hosts to stop sending Data to Microsoft *** | |
echo *************************************************************** |
require 'rails_helper' | |
RSpec.describe TodosController, :type => :controller do | |
describe "GET #index" do | |
#describe "POST #create" do | |
#describe "GET #show" do | |
#describe "PATCH #update" do (or PUT #update) | |
#describe "DELETE #destroy" do | |
#describe "GET #new" do |
require 'resolv' | |
class EmailValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
if Resolv::DNS.new.getresources(value.split("@").last, Resolv::DNS::Resource::IN::MX).empty? | |
record.errors[attribute] << (options[:message] || "does not have a valid domain") | |
end | |
rescue Resolv::ResolvError, Resolv::ResolvTimeout | |
record.errors[attribute] << (options[:message] || "does not have a valid domain") | |
end |
# lib/tasks/db.rake | |
namespace :db do | |
desc "Dumps the database to db/APP_NAME.dump" | |
task :dump => :environment do | |
cmd = nil | |
with_config do |app, host, db, user| | |
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump" | |
end | |
puts cmd |
ActiveAdmin.register User do | |
index do | |
column "ID" do |user| | |
link_to user.id, admin_user_path(user) | |
end | |
... | |
column :roles do |user| | |
user.roles.collect {|c| c.name.capitalize }.to_sentence | |
end | |
default_actions |
app.directive('ngEnter', function() { | |
return function(scope, element, attrs) { | |
element.bind("keydown keypress", function(event) { | |
if(event.which === 13) { | |
scope.$apply(function(){ | |
scope.$eval(attrs.ngEnter); | |
}); | |
event.preventDefault(); | |
} |