This file contains hidden or 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
#========================== | |
# UserHost | |
# internet access, same OS and version with TargetHost | |
apt-get update | |
apt-get --allow-unauthenticated -y install --print-uris postgis postgresql-13-postgis-3 | cut -d\' -f2 | grep http:// > download-list | |
wget -i download-list | |
# transfer *.deb files to TargetHost |
This file contains hidden or 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
# Put it to lib/mix/tasks/project.rename.ex | |
defmodule Mix.Tasks.Project.Rename do | |
use Mix.Task | |
@shortdoc "Rename project" | |
def run([name]) do | |
from_name_otp = Atom.to_string(Mix.Project.config()[:app]) | |
from_name = Macro.camelize(from_name_otp) | |
to_name_otp = Macro.underscore(name) | |
to_name = Macro.camelize(name) |
This file contains hidden or 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
import url from 'url' | |
import createRouter from 'router5' | |
export async function mockRequests(requests) { | |
const router = createRouter( | |
Object.keys(requests).map(request => { | |
return { name: request, path: request } | |
}) | |
) | |
router.start() |
This file contains hidden or 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
import url from 'url' | |
/** | |
* Intercept request and response data by url substring/regexp | |
* @param {(string|RegExp)} regexp - String or regexp | |
* @param {Function} callback - Callback | |
* @return {Object} request - Request object | |
* @return {string} request.url - Request url | |
* @return {string} request.method - Request method - GET|POST|PUT|DELETE |
This file contains hidden or 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
available_extensions = [ | |
"*.tsx", "*.ts", "*.js", "*.json", "*.css", "*.scss", "*.json", | |
"*.html", "*.slim", "*.erb", "*.rb", "Gemfile", "Procfile.dev", "package.json" | |
].map { |f| "\"#{f}\"" } | |
files = `find . -type f \\( -name #{available_extensions.join(' -or -name ')} \\) -print`.split("\n") | |
data = '' | |
def readfile(path) |
This file contains hidden or 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
fullpath = File.expand_path('../', __FILE__) | |
output = File.new(File.join(fullpath, 'out.txt'), 'w') | |
delimiter = -> (f) do | |
"\r\n\r\n===========================================================\r\n#{f}\r\n\r\n" | |
end | |
templates = %w{ *.ru *.rb *.yml *.json *.html *.slim *.erb *.css *.scss |
This file contains hidden or 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 AllowedHosts | |
ALLOWED_HOSTS = ['www.dot.tk', 'your-app-on-heroku.herokuapp.com', 'localhost', '127.0.0.1'] | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
if ALLOWED_HOSTS.include?(env['HTTP_HOST']) |
This file contains hidden or 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
def set_dimensions | |
if tempfile = self.image.queued_for_write[:original] | |
dimensions = Paperclip::Geometry.from_file(tempfile) | |
self.width = dimensions.width | |
self.height = dimensions.height | |
end | |
end |
This file contains hidden or 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
thread.posts.with_image.where(Post.arel_table[:id].not_in(posts.map(&:id))).count |