Sunday, June 13, 2021

e-techbytes

e-techbytes


Recent Questions - Arqade

Posted: 13 Jun 2021 11:24 AM PDT

Recent Questions - Arqade


When game is focused somehow my music and browser audio is lowered, any ideas?

Posted: 13 Jun 2021 10:26 AM PDT

Somehow whenever I'm playing any game on Steam (any game, including WoWs, Satisfactory, and Cities Skylines) if i have the game focused (i'm in game), somehow my machine is lowering my audio for my browser and also lowering iTunes. I've also noticed that when in game the itunes music and browser has less EQ. i.e. Little to no bass.

I have currently disabled the communications under Control Panel -> Sound -> Communications -> Disabled

I'm also running VoiceMeeter, however this issue was happening prior to the installation of that software, so I'm assuming that this is either a Windows issue or a Steam issue. I've looked and found numerous articles and other answers on forums, however they are all about 6 years old, and no solution is applicable here as the information contained within is outdated.

Is anyone else having these issues, or knows whats going on?

Will I loose anything by changing my Nintendo Account’s region?

Posted: 13 Jun 2021 06:38 AM PDT

I recently moved from Australia to the US and have perched a US WiiU. To access my digital-Australian games I'd need to change the region on my account from Australia to USA but, I'm worried that I might loose stuff. Especially considering I would have to cancel my Nintendo Online subscription to do so. Will I actually loose anything? Games, Save data ect.?

LoL - slow loading/recovery of client after game ends

Posted: 13 Jun 2021 03:28 AM PDT

Since a certain patch - I cannot determine which one, like 6 months ago - I began experiencing an issue where my client is stuck on a "Game in progress..." screen for a minute after I finish a game. I tried:

  • reinstalling LoL
  • reinstalling LoL to a brand new SSD
  • moving my TEMP/TMP directories to said SSD
  • killing the LeagueOfLegends.exe process after game
    • this seemed to have an effect as opposed to the other tries: The client returns to the post-game screen immediately, but is extremely slow - graphs load slowly, returning to the party screen (Play again) works, but my friends do not see me as connected, after the minute passes (during which no actions are viable) a lot of screens blink and then the party screen opens again and everything works
  • letting the client close during a game
    • this just causes it to open immediately and then proceed with "Game in progress..." as before.

Does anyone have any idea how to fix this?

How do I change the thing under the crosshair back to normal?

Posted: 13 Jun 2021 08:36 AM PDT

Pls, help me. So you know the thingy under the crosshair in Minecraft? My brothers' friend played on my pc and he changed the settings so the bar under the crosshair isn't there anymore but instead it isn't a bar and it is a sword that charges but it is NEXT to my HOTBAR. TYSM if you help me. (soz if this is too long)

Is it possible to generate a river biome with water in a floating islands world with sealevel = 0?

Posted: 13 Jun 2021 01:09 AM PDT

I want to generate a custom floating island world with a river biome (with water in it), but when I change the sea level to 0, the river is empty.

Is there any way to fix this?
Can I generate custom river biomes with custom biomes already filled with water?

Image of floating islands with sealevel = 0 and sealevel = 67

Can I change the biome of the world?

Posted: 13 Jun 2021 03:38 AM PDT

I wanted to see if we can change the biome on my world. For example, if it was a super flat plains, can I make it a snowy biome after building in the world?

What are the strongest characters in Paladins?

Posted: 12 Jun 2021 11:14 PM PDT

I wanted to know some of the strongest characters for the Paladins. I have also google it and found a tier list paladins-tier-list but it's totally useless. Can anybody guide me to the strongest characters. I can select for the game.

Is there any way to make it so you hear a music disc anywhere?

Posted: 13 Jun 2021 02:10 AM PDT

Is there any way I can make it so I can hear a music disc anywhere, without it fading away if I'm far away?

Minecraft Fabric 1.17 cant create entity

Posted: 12 Jun 2021 07:22 PM PDT

Story

I am trying to write a minecraft mod after my favorite pet, gerbils (cute small desert rodents), so i started to learn how to make a mod using fabric (i used the official fabric website and Suited Llama's tutorials). I created an item without any major problems, but as soon as i tried to implement an entity, i ran upon a big problem.

Problem

The tutorial is outdated, the classes definitions arent the same and im a little bit lost since i dont know what i can do and what i cant.

Question

Is there any valid tutorial for mc 1.17+ out here yet? And if, where can i find them?

No Man's Sky: Is this supposed to be blood?

Posted: 13 Jun 2021 07:54 AM PDT

Was watching a gameplay video and saw this:enter image description here

Is the red supposed to be blood, or is it your helmets HUD? Is it disabled if you remove player blood effects, or is their an option to disable it?

How do I change the amount of time a player can spend underwater before taking drowning damage?

Posted: 12 Jun 2021 10:05 PM PDT

I want to be able to give the player less air bubbles, or just make them drown a lot faster. How can I do this?

Is it possible to remove viewscreen weather effects?

Posted: 12 Jun 2021 10:51 PM PDT

I'm playing No Man's Sky on PC (via Steam), and I've noticed that when I start my game on a hazardous planet, the "weather effects" on the viewscreen seem to persist even when I leave the planet. Is there a way to disable the weather effects entirely? I don't find it adds very much to the ambience on hazardous planets, beyond making it even more difficult to see than usual. (By weather effects I mean the "frost" that builds up on the edges of glacial planets, or the yellow toxic film that builds up on toxic planets. etc.)

As an example, I started today's session in a base that I have on a glacial moon. Afterwards I left and went to the anomaly to talk to Polo. As you can see from the screenshot below, the "frosting" on the edges of my viewscreen are still present even though I'm in the perfectly climate-controlled anomaly. :(

Screenshot onboard the Anomaly

Can I play against any other CPUs past PRO status?

Posted: 12 Jun 2021 03:21 PM PDT

I've been playing Wii Tennis, and while its a fun experience, it's rather boring seeing the same CPU over and over.

This occurs when I'm at the【PR✪】level, or 1000 skill points. Anyways, after that I just see the same CPU again. It's Elisa and this other girl I can't really remember.

Are there any other CPU besides them that I can play against? I'd rather do this without using a new Mii.

How can I make it so when I equip a helmet it equips a entire suit of armor

Posted: 12 Jun 2021 06:27 PM PDT

I want it so when you equip a helmet, a full set of armour is immediately equipped.

How can I do this in Minecraft: Bedrock Edition?

can you remove items off the ground without entering the minecraft server

Posted: 13 Jun 2021 01:06 AM PDT

my friend has spawned in 9000 water buckets right next to me and the game crashed, so i was wondering if it was possible to remove items from the ground not in the server

How can I summon an entity where I punch? [closed]

Posted: 13 Jun 2021 10:25 AM PDT

I'd like to spawn an evocation fang wherever I punch but I can't figure out the commands necessary in minecraft bedrock.

Why do mobs not despawn when they are more than 128 blocks above me?

Posted: 12 Jun 2021 08:08 PM PDT

I' playing on a modded Minecraft server with my friends, and there are many extreme hills biomes. On top of one of these mountains (around Y-180), there were a lot of monsters spawning around me. But, when I enter a cave below the mountain and I'm below Y-10, nothing spawns in the caves, due to all those monsters that are still loaded on the mountain. Is there any way to fix this?

Dying Light the following: How to beat the Mother in final battle?

Posted: 13 Jun 2021 02:02 AM PDT

I am at the final part of dying light - the following. I have rejected Mother's request for sacrifice and fighting her. But she is too fast and furious in the last phase - in seconds, I am dead. Especially, when she screams, my health goes to zero fast. Is there a specific strategy to beat her in last phase of battle?

Minecraft Java server won't let me increase RAM usage, and also crashes easily,,

Posted: 12 Jun 2021 04:00 PM PDT

So, I'm using Mojang's guide as well as a YouTube video to help me set up this server; I've been told that in the start.txt file, you can set up how much memory is used during/after startup by pasting Java -Xms512M -Xmx3.5G -jar server.jar (I changed the original minecraft_server.jar to just server.jar as that's what mine's labeled). It ran the 1.16.4 version of Minecraft, but I'm not sure why it keeps issuing a Can't keep up! Is the server overloaded? Running [x]ms or [y] ticks behind error/warning.

I just want to be able to play on my own on this sever, nevermind having others try and join (one step at a time). If anyone could help me out, or point me to a post that clearly points out that I'm having an issue someone has already had before, that would be great/

If there's also a comprehensive guide on how to setup Vanilla servers (I know a bit about computers, so it's okay if it's not for beginners) I'd greatly appreciate it.

Falling blocks don't work for me

Posted: 13 Jun 2021 01:07 AM PDT

I'm trying to make a fire ability for something I'm making that will summon falling fire blocks, and I'm having issues with the fire disapearing.

I'm using /summon minecraft:falling_block ~ ~ ~ {BlockState:{Name:"minecraft:fire"},Time:1} and it doesn't seem to work. It still disapears regarless of the Time:1 tag.

I have used this method of spawning fire many times in the past, and it confuses me why it doesn't work anymore. I've checked for errors a fair amount of times and even loaded up old worlds (in 1.13) and copied the command (and while in 1.13 on the old worlds it worked but still doesn't work on new worlds).

I can't get rid of an infinite poison effect?

Posted: 13 Jun 2021 06:38 AM PDT

So I was playing on one of my mod packs (1.12.2 if this helps), and had been bitten by a vampire and had turned, everything was normal until then. As in, when I turned I got an infinite poison effect, and I cannot get rid of it, at all. Milk buckets don't work neither does the /effect @p clear command. Even the /kill command does nothing, it just comes back. I have no clue how to get rid of it since this has never happened before and there is nothing about it anywhere I can find. I mean you can see how an infinite poison effect can be annoying when you are trying to play in survival.

Here's the list of mods if you need it

  • Astikor Carts
  • Baby Animals
  • Backpack
  • Baubles Mod
  • Bewitchment Mod
  • Biomes O Plenty
  • Code Chicken Lib
  • CoFH Core
  • Craftable Saddles
  • Fossils Archeology
  • Just Enough Items
  • LLibrary
  • OptiFine
  • Patchouli Mod
  • Redstone Flux API
  • Tree Chopper
  • U Team Core
  • Vampirism

I have an issue with PES 2020 for Android

Posted: 13 Jun 2021 11:05 AM PDT

I just downloaded the game and finished the tutorials and played my first match (I think this first match is the last part of the tutorial).

Then, a white message appeared taking most of screen space. I'm not sure if it's supposed to be an ad, or if I received a reward, or it's an information message. But it's totally white blank.

I clicked on the (X) button to hide it. It goes then appears again.

How can I get rid of it?

Roblox Suddenly Lagging

Posted: 12 Jun 2021 08:12 PM PDT

So I know there are similar questions on Google, but they had something to do with their Nvidia driver, which I don't have or any way to get it (I'm just a kid, I don't have enough knowledge to go through my PC stats and get an Nvidia driver or whatnot).

I did try the reducing lag methods (such as going into Roblox studio and turning off frame manager and changing the render distance to a lower resolution), but I still get stuttering frames, just barely-noticeable but gameplay-changing amounts of lag and just overall server lagging (pressing a key and the function of the key happening about a second later, people teleporting and such).

This isn't my PC problem - my 2 PCs had no problem running Roblox about 2 days ago, then one day I turned on my wireless PC and it just seems to have lag. I thought this may be just it being wireless and tried my wired one, but that had the exact same problem. I also tried disabling my antivirus on my big PC, which did seem to get rid of a tiny bit of lag but still lagging the same way nonetheless. Others seem to not have this problem, re-installing or restarting the PC doesn't work, and Roblox didn't update until today (which still lags). This is extremely frustrating, any help will be appreciated.

How do I farm creepers for XP without them exploding?

Posted: 13 Jun 2021 12:30 AM PDT

I have created a mob farm which I want to be able to turn into an XP farm at the switch of a button. Basically a multitude of mobs spawn at the top, fall down, and die. I want to add a dispenser that dispenses water so I can catch the mobs and kill them for the XP instead of their drops. However, creepers start to self-destruct as soon as I start hitting them through my half-slabs. I've tried using different combinations of slabs, stairs, fences, etc, but the creepers keep blowing up my mobs. Is there any way to stop this? I can draw a diagram of the XP farm if it would help.

What's the most efficient way to grind for coins?

Posted: 12 Jun 2021 11:51 PM PDT

Most of the customisation items for characters are locked away in the Krypt mode, which requires you to spend coins to open boxes that contain random items. The boxes with the better items are much more expensive than the others and drain resources quickly.

What's the quickest/most efficient way to grind for the coins required to open a bunch of chests for the best chance at getting the items you want?

Note: The in-game store lets you purchase specific items, but it's only about 5 at a time and they're on a rotation that takes many real-world hours to rotate. It's not a viable solution to the problem of getting the items you actually want.

What is the port range for Minecraft LAN worlds?

Posted: 13 Jun 2021 12:02 AM PDT

When I want to invite my friends over the internet into my LAN world in Minecraft, I need to set my router to forward the port specified by Minecraft. As Mincraft picks a different port each time I open my world over LAN, I have to edit my router settings every time I want to start a multiplayer LAN session over the internet. Instead, I would like to set the router to the range of port numbers that Minecraft picks from.

What is the range of ports that Minecraft uses for LAN worlds?

So far, after four sessions, I have had ports between 49525 and 50852. I play the Java edition, if that makes any difference.


Alternatively:

The port range must be coded into the Minecraft code. What file(s) would I look at to find it?

What is this "magic circle" in Castlevania: Dawn of Sorrow?

Posted: 13 Jun 2021 07:08 AM PDT

While I was farming for Alamaric Sniper and Ghost Dancer souls, I had something happen where it looked like a Sniper was going to give me a soul, but I didn't actually get one. Instead, this red magic circle-looking thing was left behind in the air for a few seconds, along with a pair of wings. Eventually, the wings disappeared, and the circle expanded and faded away.

Mysterious red magic circle with wings

Mysterious red magic circle without wings

Mysterious red magic circle fading away

I only had 7 Sniper souls at the time, so it wasn't that I was maxed out. I've tried researching it myself, but searches about "magic circle" tend to lead to Magic Seals, and searches about souls not dropping tend to lead to complaints about drop rates, so I haven't had any luck. If it matters, I'm playing on DeSmuME 0.9.7.

Is this an actual part of the game, or just a glitch of some sort?


In response to the Arc Demon suggestion: I've found a Dawn of Sorrow Arc Demon sprite sheet on this site. While they also use red magic circles, the designs aren't very similar, so I'm afraid that can't be it. Among other things, this circle has a star in the center, while the Arc Demon one does not.

Comparison of magic circles

What cheat code do you use for spruce wood in Minecraft?

Posted: 12 Jun 2021 06:26 PM PDT

What is the cheat code for spruce wood in Minecraft on computer?
I know this part: /give (player)
but I don't know the rest.

Please help.

OSCHINA 社区最新专区文章

Posted: 13 Jun 2021 10:38 AM PDT

OSCHINA 社区最新专区文章


Cloud Foundry 2018发展路线图

Posted: 16 Mar 2020 10:43 PM PDT

Cloud Foundry 基金会CTO Chip Childers加入了云标准客户委员会(Cloud Standards Customer Council),讨论Cloud Foundry技术(Application Runtime,Container Runtime和BOSH)、应用案例、核心项目更新,平台的技术优势,以及Cloud Foundry在2018年的重点发展领域。 点击以下链接可以在Cloud Foundry优酷账户里观看C...

Jenkins X邀你参加Hacktoberfest 2020

Posted: 14 Oct 2020 09:01 PM PDT

我们很激动地宣布,Jenkins X将再次参加今年的Hacktoberfest!Hacktoberfest是一个为期一个月的全球开源软件庆典。 从10月1日到10月31日,提交四个pull request以获得限量版Hacktoberfest衬衫。我们鼓励所有背景和技能水平的人参加Hacktoberfest,并加入一个全球开源贡献者社区。 了解更多关于Hacktoberfest的信息: ht...

亚洲领先的云供应商—阿里云现已支持Cloud Foundry

Posted: 08 Jul 2020 08:35 AM PDT

全球增长最快的云服务公司成为Cloud Foundry Foundation金牌会员,为Cloud Foundry打开了中国及更广阔的市场 旧金山—2018年4月18日,Cloud Foundry 基金会—全球最广泛应用的开源云技术基金会今天宣布,阿里云将为Cloud Foundry平台提供全面技术集成支持。阿里云隶属于阿里巴巴集团的云计算部门,是中国最大的云基础设施...

OSCHINA 社区最新专区文章

Posted: 13 Jun 2021 09:11 AM PDT

OSCHINA 社区最新专区文章


Linux 上的 RISC-V 将支持 Transparent Hugepages

Posted: 12 Jun 2021 05:19 PM PDT

根据最新的提交显示,Linux 内核的 RISC-V 即将获得 Transparent Hugepages(THP)支持。 Linux 内核的 RISC-V 继最近添加原地执行 XIP、对 KProbes 和其他功能的支持以及硬件特定工作如 SiFive FU740 SoC 支持后,由华为工程师提供的 Transparent Hugepages 支持现在也已准备就绪。 Transparent Hugepages 是 Linux 的内...

KDE Frameworks 5.83.0 发布

Posted: 12 Jun 2021 04:09 PM PDT

KDE Frameworks 5.80.0 已正式发布。KDE Frameworks 是 Qt 的 83 个附加库,它在成熟的、经过同行评审和测试的库中提供了各种常见的功能,并且具有友好的许可条款。 主要更新内容 Baloo 在 KIOSlaves 中嵌入 JSON 元数据 将协议文件转换为 JSON [balooctl] 允许清除已删除的文档 BluezQt 将缺少的 Qt5::DBus 添加到 qml ...

V2EX - 技术

Posted: 13 Jun 2021 08:05 AM PDT

V2EX - 技术


mysql n+1 查询大家是怎么处理的

Posted: 13 Jun 2021 08:00 AM PDT

如果是单条件查询直接 select * from test where a in (1,2,3) 然后通过代码组合就可以了

但是如果是多个查询条件怎么处理呢 select * from test where a=1 and b=2 and c=3 那个循环的变量值都不一样

大家怎么处理这种 N+1 的查询

分享一款自带工作流引擎的 NodeJS 全栈框架,接单快手、创业神器,欢迎拍砖

Posted: 13 Jun 2021 07:22 AM PDT

CabloyJS 是什么

CabloyJS 是一款自带工作流引擎的 Node.js 全栈框架, 接单快手、创业神器, 基于 koa + egg + vue + framework7 + mysql

在线演示

场景 链接 /二维码
PC 端 https://test.cabloy.com/
Mobile 端 cabloy-demo-qrcode

谁会用这款 Node.js 全栈框架?

>>>>> 1. 外包接单

痛点

客户希望项目按质如期完工、价格低、风险小;服务商希望毛利高、投入少、进度快、客户满意。如何实现二者的平衡呢?

如果接到项目,从零开始代码开发,就会放大客户与服务商之间的矛盾,增大项目的实施风险。因此,一款高质、高效、灵活的全栈框架,可以让外包接单之路走得更顺一些,更远一些

优点

  1. 高效灵活:CabloyJS 历时 5 年精心打造的 Node.js 全栈框架,内置大量特性功能,开箱即用,同时又具有强大的可扩展性,便于定制开发
  2. 二次机会:CabloyJS 完善的基础建设,不仅让开发效率更高,而且可以引导和培育客户的日常操控体验,从而衍生出更多的业务需求和合作机会

>>>>> 2. 初创企业

诉求

在创业成本高企、竞争越发激烈的今天,初创企业往往希望在尽短的时间、以尽少的成本,研发出最小可用产品( MVP ),从而尽早发布测试、收集反馈、迭代优化

优点

  1. 尽快落地:CabloyJS 采用模块化体系,支持全场景开发,确保 MVP 产品尽快落地
  2. 保值:CabloyJS 从底层内置分布式设计,并且内置工作流引擎等核心特性。当系统起量之后可以无缝支持集群部署,并在 MVP 产品的基础上继续深入开发更核心的业务,从而达到保值的效果
  3. 增值:CabloyJS 提供了模块市场,可以通过模块市场直接选购与自身业务需求相匹配的模块,以低成本快速实现业务需求,从而达到增值的效果

CabloyJS 的商业模式

  1. 开源免费:CabloyJS 全栈框架,开源免费,并提供大量文档、测试模块、视频课程等资源
  2. 模块市场:CabloyJS 提供了模块市场。研发同仁可以在实际开发过程中不断沉淀通用的模块,发布到模块市场,与平台共享收益。从而成为外包接单之外的睡后收入。模块足够优秀,收益就足够多,姿势也就足够躺平
  3. 二级分销模块市场导入二级分销的玩法,汇聚更多社会渠道资源,带动模块的销售

CabloyJS 先期制作了一套视频课程,导入了相同的二级分销的玩法,欢迎品鉴

相关链接

CabloyJS 的四大亮点

>>>>> 亮点 1:自适应布局:pc = mobile + pad

  1. 背景说明

对于前端开发而言,有一个很现实的问题:如何同时进行 pc 端和 mobile 端的开发?

传统的做法一般而言有两个:

1 )采用css 自适应媒体查询

由于原生 mobile 端的布局和 pc 端的布局是不同的。css 自适应媒体查询只是让 pc 端的页面在 mobile 端可用,但达不到原生 mobile 端的效果

比如,许多使用bootstrap实现的博客;再比如,市面上绝大多数后台管理系统模版。往往优先处理 pc 端的显示效果,然后采用css 自适应媒体查询来适配 mobile 端,从而在 mobile 端仅仅达到能看的程度,但绝对不好用

2 )采用两套代码

由于采用css 自适应媒体查询有很大的局限性,很多项目采用两套代码来分别处理pc 端mobile 端的布局显示。这样虽然解决了问题,但是同样的业务逻辑需要做两套代码,成本、时间、精力都得翻倍

  1. 解决之道:pc = mobile + pad自适应布局

CabloyJS 首创pc = mobile + pad的自适应布局机制:只需要一套代码,mobile 端达到原生效果,同时将mobile 端的操控体验和开发模式无缝带入pc 端

效果演示:进入演示网站https://test.cabloy.com/,然后调整窗口尺寸分别体验 pc 端和 mobile 端的效果

>>>>> 亮点 2:模块化开发体系与模块隔离

  1. 模块化体系:CabloyJS 采用模块思维规划系统架构,以业务功能为单位,将与业务功能相关的前端组件与后端逻辑组织为一个业务模块,有利于业务功能的内聚与重用,从而便于沉淀通用的模块,然后发布到模块市场
  2. 模块隔离:模块的页面、数据、逻辑、路由、配置等元素均进行了命名空间隔离处理,避免模块之间的变量污染与冲突
  3. 全局模块与局部模块:CabloyJS 内置了大量全局模块,提供工作流引擎用户管理角色管理权限管理菜单管理参数设置管理表单验证登录机制,等等诸多特性。具体的业务开发则在局部模块中进行,架构清晰、层次分明,从而轻松应对业务规模的持续增长

>>>>> 亮点 3:前后端分离,全场景开发

通过前后端分离的架构设计,可以支持全场景业务的快速开发

场景 前端 后端
PC:Web CabloyJS 前端 CabloyJS 后端
PC:Exe CabloyJS 前端 + Electron CabloyJS 后端
Mobile:IOS CabloyJS 前端 + Cordova CabloyJS 后端
Mobile:Android CabloyJS 前端 + Cordova CabloyJS 后端
微信公众号 CabloyJS 前端 + 微信 API CabloyJS 后端
企业微信 CabloyJS 前端 + 企业微信 API CabloyJS 后端
钉钉 CabloyJS 前端 + 钉钉 API CabloyJS 后端
Slack CabloyJS 前端 + Slack API CabloyJS 后端
小程序:微信、支付宝等 Uni-app + CabloyJS 前端 SDK CabloyJS 后端
  • 后端:由于完整的前后端分离设计,只需开发一套 CabloyJS 后端代码即可
  • 前端:所有可基于 H5 的场景,只需开发一套 CabloyJS 前端代码即可
  • 小程序:提供 CabloyJS 前端 SDK 让 Uni-app 可以轻松对接 CabloyJS 后端代码

>>>>> 亮点 4:内置 NodeJS 工作流引擎

众所周知,NodeJS 作为后端开发语言和运行环境,支持高并发、开发效率高,有口皆碑,但是大多用于数据 CRUD 管理中间层聚合中间层代理等工具场景,很少深入到业务领域的核心。有许多采用 NodeJS 开发的最小可用产品( MVP )最终会另起炉灶重构,这是原因之一

究其根源,NodeJS 作为业务开发平台,还缺少许多核心的基础构件,NodeJS 工作流引擎便是其一。CabloyJS 4.0 重点开发了 NodeJS 工作流引擎,并作为内置的基础核心模块(同样是开源、免费),近一步拓展了 NodeJS 在后端的应用场景,为深入研发各类商业业务逻辑,提供了基础支撑

CabloyJS 的研发历程

CabloyJS 从 2016 年启动开发,主要历经两个研发阶段:

1. 第一阶段:EggBornJS

EggBornJS 关注的核心就是模块化体系模块隔离,并以此实现一套完整的全栈开发框架

比如模块egg-born-front是框架前端的核心模块,模块egg-born-backend是框架后端的核心模块,模块egg-born是框架的命令行工具,用于创建项目骨架

这也是为什么所有业务模块都是以egg-born-module-为命名前缀的原因

2. 第二阶段:CabloyJS

EggBornJS 只是一个基础的全栈开发框架,如果要支持业务的快速开发,还需要考虑许多与业务相关的支撑特性,如:工作流引擎用户管理角色管理权限管理菜单管理参数设置管理表单验证登录机制,等等。特别是在前后端分离的场景下,对权限管理的要求就提升到一个更高的水平

CabloyJS 在 EggBornJS 的基础上,提供了一套核心业务模块,从而实现了一系列业务支撑特性,并将这些特性进行有机的组合,形成完整而灵活的上层生态架构,从而支持具体的业务开发进程

有了 EggBornJS,从此可复用的不仅仅是组件,还有业务模块

有了 CabloyJS,您就可以快速开发各类业务应用

CabloyJS 架构图与技术栈

CabloyJS 并不盲目重新造轮子,而是采用业界成熟的开源框架和组件,经过有机组合、再次创新,补充业务层面的基建特性,从而具备了丰富的功能特性,又保持了强大的可扩展性

cabloy-2x

1. 第一层:NodeJS

基于 NodeJS,从而使得前后端均可以采用 Javascript 语言进行全栈开发,从而显著提升开发效率

2. 第二层:VueJS 、KoaJS

3. 第三层:Framework7 、EggJS

  • 前端:采用 Framework7 作为主体的 UI 组件库,同时根据业务需要搭配其他 UI 组件库,如 AntD Vue 的表格组件、AntV X6 工作流绘制组件、ChartJS 图表组件,等等
  • 后端:采用 EggJS 作为底层框架,从而沿用了 EggJS 成熟的基础建设和丰富的插件生态

4. 第四层:egg-born-front 、egg-born-backend

  • egg-born-front:是前端的核心模块,主要进行了以下几方面的工作:
  1. 模块前端隔离:对模块前端的页面、数据、逻辑、路由、配置等元素进行了命名空间隔离处理,避免模块之间的变量污染与冲突
  2. 模块加载机制:只需给模块名称增加一个sync后缀,即可实现模块的同步加载异步加载,参见:加载机制
  3. pc=mobile+pad 自适应布局:对 Framework7 进行了改造,只需要一套代码,mobile 端达到原生效果,同时将mobile 端的操控体验和开发模式无缝带入pc 端,参见自适应布局:pc = mobile + pad
  4. 组件环境对象:向 Vue 组件实例注入了大量环境对象,方便开发,参见:Component
  • egg-born-backend:是后端的核心模块,主要进行了以下几方面的工作:
  1. 模块化开发体系:EggJS 原有的目录结构并不适合模块化的开发风格。但是 EggJS 提供了强大的扩展机制,允许提供自定义的 Loader 加载器。通过开发自定义的 Loader 加载器,实现了以业务模块为单元的目录结构。每个业务模块可以定义与自身业务相关的资源,如:Routes 、Controllers 、Services 、Models 、Middlewares 、Config 、i18n 语言资源,等等。而且这些元素可以编译打包成一个 js 文件,同时也可以进行丑化,从而保护商业代码。由于这种模块化的开发体系,也方便把编译打包的模块直接发布到NPM 仓库或者模块市场,与社区分享,参见:模块编译与发布
  2. 模块后端隔离:以自定义的 Loader 加载器为基础,对模块后端的Routes 、Controllers 、Services 、Models 、Config等元素进行了命名空间隔离处理,避免模块之间的变量污染与冲突
  3. Bean 容器与 AOP 编程:基于原生 JS ( Vanilla JS )实现了更轻量、更灵活的 Bean 容器,并可以通过 AOP 机制进行扩展,参见:Bean
  4. 原生分布式架构:EggJS 原有的Worker + Agent进程模型,对于单机而言非常便利。但是面对多机集群,特别是基于docker的集群部署而言,Agent 进程就失去了用武之地。更重要的是,如果一开始基于Agent 进程进行开发,后续很难平滑的过渡到分布式场景。因此,egg-born-backend采用Redis,从框架底层就开始原生分布式的架构设计,并衍生出了Broadcast 、Queue 、Schedule 、Startup等一系列分布式的开发组件,方便我们从一开始就进行分布式的开发。因此当系统起量后,可以轻松做集群扩展,参见:Broadcast, Queue, Schedule, Startup

5. 第五层:EggBornJS

egg-born-frontegg-born-backend,再加上一些周边工具,共同构成了 EggBornJS,也就是 CabloyJS 研发历程的第一阶段

6. 第六层:CabloyJS

CabloyJS 在 EggBornJS 的基础上,研发了一套核心全局模块,实现了一系列业务支撑特性,并将这些特性进行有机的组合,形成完整而灵活的上层生态架构,从而支持具体的业务开发进程

7. 第七层:Project (项目)

实际的项目由全局模块局部模块构成

  • 全局模块:CabloyJS 内置的核心模块、来自NPM 仓库或者模块市场的第三方模块,统称为全局模块,一般安装在node_modules目录
  • 局部模块:项目实际的开发工作一般在局部模块中展开。局部模块位于项目目录内,参见:新建模块

信念

凡是可以用 JavaScript 来写的应用,最终都会用 JavaScript 来写 | Atwood 定律

相信,Javascript 的深度探索者都会被这句名言激发,共同努力,为 Javascript 生态添砖加瓦,构建更繁荣的应用生态

CabloyJS 正是对这一名言的探索之作。欢迎您也加入 CabloyJS 的社区生态,一起促进 Javascript 的繁荣与应用

名称的由来

1. EggBorn

这个名称的由来比较简单,因为有了 Egg(后端框架),所以就有了 EggBorn 。有一部动画片叫《天书奇谭》,里面的萌主就叫"蛋生",我很喜欢看(不小心暴露了年龄😅)

2. Cabloy

Cabloy 来自蓝精灵的魔法咒语,拼对了 Cabloy 这个单词就会有神奇的效果。同样,CabloyJS 是有关化学的魔法,基于模块的组合与生化反应,您将实现您想要的任何东西

预览

  • 白色主题

theme-light

  • 暗色主题

theme-dark

  • 风信子主题

theme-hyacinth

  • 灿烂主题

theme-brilliant

  • 显示侧边栏

theme-light-panel

  • 移动端风格

theme-light-mobile

License

MIT

相关链接

有没有兄弟姐妹用的是 win10 + 32 寸显示器 2k 的分辨率?用啥字体或者缩放?

Posted: 11 Jun 2021 03:31 PM PDT

看起来没有 mac 下舒服。

我的配置如标题,用啥字体,或者设置成啥分辨率比较"好看"一些。

另,系统是 win10 pro 最新版, en 语言为主

OSCHINA 社区最新专区文章

Posted: 13 Jun 2021 06:11 AM PDT

OSCHINA 社区最新专区文章


详细解析工作流Activiti框架中的LDAP组件!实现对工作流目录信息的访问控制和分布式访问

Posted: 12 Jun 2021 07:00 AM PDT

![](https://oscimg.oschina.net/oscnet/up-7f9dd0806c7a92a655498059aae7e4135b4.JPEG) # Activiti集成LDAP简介 - 企业在LDAP系统中保存了用户和群组信息,Activiti提供了一种解决方案,通过简单的配置就可以让activit连接LDAP # 用法 - 要想在项目中集成LDAP,需要在pom.xml中添加activiti-ldap依赖: ```xml org.activiti...

Recent Questions - Ask Different

Posted: 13 Jun 2021 05:45 AM PDT

Recent Questions - Ask Different


A security system on wifi from hotspot that runs on 2.4 ghz

Posted: 13 Jun 2021 05:18 AM PDT

I am making a security system to protect something very important in my room. Its the ink in printer. I have many enermies and they have done black magic on me so I am tring to fight the black magic by making holy water and taking ruqyah baths with it see the links below for information on:

  1. making holy water with prinitable Quran sheets. https://www.youtube.com/watch?v=ECWkTPaaTvw

2)Ruqyah baths. https://www.youtube.com/watch?v=DqklNcAvCRQ

3)black magic. https://www.youtube.com/watch?v=X2nUG5eMBus&list=PLv5GL22SuWj-SW-ZdlH62Sl8BMyTv58GI

The black magic allows these people to probe in my mind. So there is no point using for example corded locks. These people will go to all lenghths to contaminate this ink so it does not work, My mother is on their side and has the key to my room. Althogth these people want to contaminate this ink badly they also do not want to get caught at it or for me to no they have done it.

So i decided i will set up a motion camera in my room, that will allow me to see when motion is detected in my room. As my mother will simple turn her wifi off. so i decided to get a moblie phone to make a wifi hotspot in my room to connect to my phone.

Now the problem is that everything works on 2.4 ghz. I think from the internet, its better to buy and andoid moblie than iphone to get a 2.4 ghz wifi, my question is will any of these mobiles do the job:

https://www.wish.com/product/5de87d0f2b774128cf48597b?hide_login_modal=true&from_ad=goog_shopping&_display_country_code=GB&_force_currency_code=GBP&pid=googleadwords_int&c=%7BcampaignId%7D&ad_cid=5de87d0f2b774128cf48597b&ad_cc=GB&ad_curr=GBP&ad_price=29.00&campaign_id=12686188707&retargeting=true&exclude_install=true&gclid=CjwKCAjw2ZaGBhBoEiwA8pfP_ijnFr5lsIjA2aLcS6p5RlfTj4seoj5nWKR1Yap8SNXLo5ADqJzSHRoCVwoQAvD_BwE&share=web

https://www.wish.com/product/5da177b91ad3a04112aeb57f?hide_login_modal=true&from_ad=goog_shopping&_display_country_code=GB&_force_currency_code=GBP&pid=googleadwords_int&c=%7BcampaignId%7D&ad_cid=5da177b91ad3a04112aeb57f&ad_cc=GB&ad_curr=GBP&ad_price=24.00&campaign_id=12686188707&retargeting=true&exclude_install=true&gclid=CjwKCAjw2ZaGBhBoEiwA8pfP_p_Ay0kHIgzCYmyxEbLjHQTvVKxgB1_kpLTuPUQwWnCvXTXk-pSVcxoCKdoQAvD_BwE&share=web

I am not rich so can only get cheap phones.

My second probelm is that this phone that make my 2.4 ghz internet in my room need to connect to my iphone 5s. I think this shoud be okay as its sending it to my e-mail account.

This is the plan i have but if you can think of a better security system i would like to know. Bear in mind these people can read my mind and are many people and are very driven to stop me for example if i get a pad lock and lock my printer in my suit case which i will also do, they will simple pick the lock.

automatically turn iPhone sound off after a certain duration

Posted: 13 Jun 2021 04:15 AM PDT

If I'd like to go to sleep with sound playing on my iPhone but have it turn off at a certain time during the night, or after a certain duration, how would I accomplish that?

Spaces: how to get the list of apps running in a Space/Desktop

Posted: 13 Jun 2021 03:07 AM PDT

Is there a way to retrieve a list of applications running per Space/Desktop in MacOs Big Sur (11.4)? Ideally, I'd like to save the state of apps running in a chosen space and be able to reopen them later in a single space.

Is it possible (using Apple Script or XCode)? Where to look for Spaces-related data? Any advice is highly appreciated.

Thanks!

How to pixelate / blur part of an image in Mac Preview?

Posted: 13 Jun 2021 03:59 AM PDT

I have a screenshot of a web UI and I wish to blur the parts that are not relevant to the point being demonstrated, is there a way to blur / pixelate part of an image using Mac Preview?

Note: the top ranking google result offers a highly substandard solution resulting in an obtrusive rectangle in place of the parts you want blurred - this is really not the same as subtle blurring that obscures information with minimal aesthetic interference with the look of the image.

Lost keys after formatting Mac HD

Posted: 13 Jun 2021 04:01 AM PDT

I lost my private keys after formatting my Mac and reinstalling my OS. I only have the public keys and the passphrase. What can I do?

MacBook Pro 16 inch thermal throttling even when temperatures are low

Posted: 13 Jun 2021 03:16 AM PDT

Sometimes when I start to use MacBook its cpu speed limit stays at 20% despite the low temperature. I use the app "HOT" to monitor it. Sometimes even when temperature is 60 Celsius cpu speed limit stays at 20%. Only after a reboot it gets to 100%. Or it takes a very very long time.It might be inactivity of half a day or a day. But cannot predict when it will be reset. Is there any reason for this? Or is is it a hardware fault. I have tried clean install of OS. NVRAM SCM ..etc all the resets. But issue stays the same. I have asked the same question here as well. enter image description here

enter image description here enter image description here

`open folder`from terminal and `reveal file in finder` not working

Posted: 12 Jun 2021 11:23 PM PDT

If you search for a file in Spotlight and command-click the file you expect the finder to activate and show that file. Instead, the Finder activates but only shows my home folder.

Same thing in Terminal:

open /Users/myHome/Documents/aa/ab  

will activate the Finder but with a window on /Users/myHome/. Same thing with any open file: if you command-click on the file name on top of the file window you can select any folder on its path to have it open in Finder. Instead, the finder opens /Users/myHome/.

Same thing with several applications that tell the Finder to reveal a file (not all apps: Music will correctly reveal track in Finder).

I have tried rebuilding the Spotlight index, checking the disk with Disk Utility, reinstalling Big Sur 11.4 but that does not fix the issue.

Any suggestion is welcome.

How to clear iPadOS Files cache for files in third-party cloud storages?

Posted: 12 Jun 2021 09:12 PM PDT

I'm currently running iPadOS 14.6 and I don't understand how Files app integration with cloud storages works.

I have Yandex.Disk application (think of it as Google Drive alternative) which does have its own "Offline" section, so I can download some files and access them locally without internet connection.

I also have Yandex.Disk visible in stock Files app and I can download files from there. The issue is that I have no idea how to delete files which were cached in Files app.

For example: when I open Files app and download some 1 Gb file from Yandex.Disk opened in Files, I do see that Yandex.Disk cache was increased in 1 Gb (System Settings -> Storage), however there is no "Delete" option in Files since it shows Yandex.Disk mounted as "Read-only". For now the only way I see to clear that cache is to completely delete the app and re-install it.

What's wrong with the Files app?

Why are some Firefox windows not cycling through the entire list of windows I have open?

Posted: 12 Jun 2021 10:13 PM PDT

I've got a bunch of open windows in Firefox and somehow two of them (this one included which is the most recent one I've opened) are isolated into their own group. The other 8 or so windows will cycle through when I hit the command-~ key, but this window and the other window in its group never come up and I have to use the mouse and Window menu to select one of those windows. After I select one of the windows in that other group, the command-~ key will cycle through just those two windows and ignores the other 8 windows. Are those different desktop spaces? How can I get all the windows to be in one group?

(I'm talking about browser windows only here. Each window might have any number of tabs in it, but that doesn't seem to be relevant.)

MacOS Sierra, Firefox 89.0 (64-bit)

Bluetooth device connected but not showing up in Output Device

Posted: 13 Jun 2021 01:18 AM PDT

In order to remove another audio device from my Mac, I deleted the HAL folder from Library/Audio/Plug-Ins/ (This is the advice I got from a quick google search, I don't understand the mechanics of it at all)

It removed the device I wanted to remove but now my Galaxy buds are not working. They connect to the bluetooth successfully for a few seconds and then disconnect automatically. Even when they are connected, the headphones do not show up in the list of Output devices.

If someone has any solutions, please help me out.

What Visual Cue Is Available To Show Safari 14.1's Tab Bar Is Scrollable?

Posted: 13 Jun 2021 01:11 AM PDT

What visual cue is available to show that Safari 14.1's tab bar is scrollable?

I understand that I can scroll it when there are too many tabs to fit. Other than trying to scroll it and looking to see whether or not it scrolls, how can I tell whether it is scrollable?

In some cases, the last visible tab may be partially covered, so that's a tiny cue. In other cases, if the windows size is "just wrong", all visible tabs are fully rendered.

Is there a cue I'm missing? Is there a cue I can enable? Is there an extension that would provide a cue?

Help understanding Attempting to create AWDL interface for en0 in wifi logs

Posted: 12 Jun 2021 03:34 PM PDT

Came across a wifi log today titled wifi-01-06-2021__(the date it was created). I have never seen one of this type before, and I am pretty confused about the first few lines of it:

SC: <airport[237]> scInitInterface for device en0  <airport[237]> _bsdDriver_init: registration for monitoring bssSteeringRequest event  Info: <airport[237]> psCallback: powerSource = AC Power  Info: <airport[237]> psCallback: set powersave disabled on en0 Roam: <airport[237]> _initInterface: AirPort Interface <en0> <6>  P2P: <airport[237]> CreateVirtualInterface: Attempting to create AWDL interface for en0 with MAC address *omitted* (attemptNumber = 0)  P2P: <airport[237]> CreateVirtualInterface: Created AWDL interface awdl0 with address *omitted* for en0  Offload: <airport[237]> _openIpAddressMonitoringSockets: Monitoring IP address changes on en0  <airport[237]> _initLocaleManager: Started locale manager  <airport[237]> _initInterface: Failed to query current SSID (Operation not supported)  <airport[237]> CoreCapture preference: 0  <airport[237]> finished with CoreCapture preferences  

I know AWDL is the Apple Wireless Direct Link, and is used for peer-to-peer, and en0 is my wifi. What I don't understand is what it means by creating a virtual interface, or the MAC address that I have omitted.

Bluetooth and all sharing are disabled, and when this happened, wifi was disabled to. I wasn't connected to a network. The MAC address in question doesn't seem to match anything I can find on my Mac, or on my network, though that should be irrelevant given I wasn't connected to it.

Is this just a random MAC address my Mac is generating using MAC randomisation, or what is it?

Mac OS Big Sur | kernal_task usage is 500% when connected to external monitor

Posted: 12 Jun 2021 09:05 PM PDT

I'm facing a system lag issue whenever I connect to my external monitor, even though there is no user process.

I have already gone through some of the answers in the stack exchange and did two things as of now.

  1. I have disabled the automatic graphics switching.
  2. I have disabled "Display have separate space"
  3. There is no software update pending

as mentioned in this link CPU usage is too high with Yosemite and an external monitor

But the problem, even after those two changes I can see kernal_task is more than 500% and I'm not able to use Macbook pro at all.

Previously it was once or twice an occurrence, now it is happening every time I connect to an external monitor.

enter image description here

Activity Monitor enter image description here

enter image description here

I have also taken a spin-dump ( 5MB ) and system diagnostics ( 200+ MB ). So I dunno how to share this here. Let me know if any of you need it for analysis.

Make open file 'finder' larger by default

Posted: 12 Jun 2021 06:06 PM PDT

How do I make this window larger by default so whenever I 'open a file' in any program, it's not super small?

I am referring to the window size, not the text size.

I have the finder (outside of 'open a file') larger by default, I am unsure how to make this one larger.

enter image description here

I placed Neovim in usr/local/bin but getting permission denied

Posted: 12 Jun 2021 02:03 PM PDT

I'm not sure where to place the Neovim folder (after extracting it). Is the location usr/local/bin correct?

I get the following

zsh: permission denied: nvim

Too large Other Volume in Container

Posted: 12 Jun 2021 10:29 PM PDT

My Mac show disk full and realized that I can use only 100 GB (Out of 500 GB). I checked Storage and realized that there are a lot of space for "Other Volume in Container".

enter image description here

So I check diskutil list in terminal and found below

ainer

I know APFS Volume disk1s5 and disk1s6 but I am not sure what is disk1s1. It is not visualized it in DiskUtil also. Does someone know how to increase available volume? Or how to delete that disk1s1 volume?

Below is the command result from "diskutil apfs list"

enter image description here

Thank you!

How do I download songs in a playlist in Music?

Posted: 13 Jun 2021 04:02 AM PDT

I used to be able to download all of the songs in a playlist from iCloud at once in Music, but the download button is no longer showing in the playlist title area it used to. It does show next to individual songs that haven't been downloaded, however selecting all and right-clicking now longer shows a download button in the context menu either. The only way I have found to download more than one is to go to the album, and the download button shows in the album title area.

Any ideas on how to re-enable the download button? Is this a bug?

Note: it does not seem to make a difference if the playlist only contains content I have purchased, uploaded with iTunes Match, or added to my library from Apple Music.

Album view with download button visible:

Album with download button visible

Playlist view missing the download button: Playlist with no download button visible

Download button missing from menu: Download button missing from menu

Is there a way to get Firefox-like-Containers in Safari?

Posted: 12 Jun 2021 02:12 PM PDT

I'm looking for an extensions (or built in feature?) of Safari that does the same as Multi-Containers for Firefox. I need different users/containers to separate private browsing from different works contexts.

I found this older post Multiple user accounts in Safari like in Chrome? and tried Google but not much came out of it.

Maybe someone knows a hidden gem

How fix MacOS Mail so Gmail labels appear?

Posted: 12 Jun 2021 03:01 PM PDT

I recently bought a new MacBook Pro, and set up Mac Mail with my Gmail accounts. At first, when the mail was being imported, the labels for my emails listed in the list preview section of the Inbox / message browser appeared. Then, Mac ran an update for 10.15 (Catalina), and all of the labels for my emails listed in the list preview section of the Inbox / message browser disappeared.

I've ensured that the 'Show in IMAP' checkbox is ticked next to all of the labels I wish to see as folders in Apple Mail. It shows the mailbox but not the labels for the messages listed in the list preview section of the Inbox / message browser.

Any ideas on how to fix this? I've contacted Apple support, but they haven't provided any guidance.

Add USB-C ports to an old 2014 iMac

Posted: 13 Jun 2021 01:03 AM PDT

All my Apple devices are fairly new and apart from Lightning cables, all my peripherals are now USB-C.

But for photo editing I still like to use my 2015 27" iMac that was heavily upgraded. Now this iMac only has two Thunderbolt 2 ports and, obviously, no USB-C ports. I would like to add a hub to my iMac that allows me to use USB-C devices, like hard drives that are mostly just USB 2 or USB 3 anyway. A single USB-C port would be enough. At the moment I keep a spare set of USB-A to whatever cables around but it's getting increasingly annoying.

Is there a Thunderbolt 2 dock that would have a USB-C port or a way for me to use something like Satechis USB-C hub on my Thunderbolt 2 iMac? It does not need to be a Thunderbolt 3 port or support PD, all of which would require an active component.

enter image description here

iCloud reminders (web site) - missing features?

Posted: 12 Jun 2021 04:01 PM PDT

This Apple KB article implies that one can create new reminders lists, edit details of reminders set as alert time, change folders of reminders, etc.

https://support.apple.com/kb/PH12088?locale=en_US

However, I don't see any of these options. I can add new reminders and edit notes, but I can't do any of the other things it states.

Is the iCloud reminders web interface neutered now? I don't have the "+ at the top" the article refers to.

As far as I can see, the only things I can do on the iCloud web site are:

  • add remidners
  • add/modify notes on reminders
  • change list colors/appearance
  • show/hide completed

I don't think there are any other possible functions - ?

Was hoping to use iCloud on the web as an interim since the macOS desktop reminders app won't sync with iCloud until Catalina.

Here is a screen shot taken on macOS Mojave with Safari 13.0.1...looks the same in the current version of Chrome for macOS as well:

enter image description here

How do I download all iCloud Drive files to external hard drive using MS Windows?

Posted: 13 Jun 2021 05:24 AM PDT

Using Google Chrome on Windows, I am trying to download or copy + paste all of my files to an external hard drive so I can delete them afterwards and downgrade my iCloud drive subscription to something cheaper. I have tried to find a way but I can't seem to find a way to grab them all at once. It also wont let me download the file folders individually either. I also tried opening the iCloud folder on my computer and clicking the little cloud with the down arrow but it takes super long and hangs up my internet so I can't do anything else with it for hours.

The only way I could find to do this is to download the document files without the folders meaning I would essentially need to re-create the folder layout on my external, download the document files and then move them to the external drive which would be a pain and really slow.

Does anyone know of a way to do this a faster way? Or a way to back up iCloud so I can get to the files that way?

caffeinate can't keep display from sleeping

Posted: 13 Jun 2021 01:43 AM PDT

I have a fleet of 7 macbook pro's running mac osx 10.10, 10.11, and 10.12, and 3 mac pro's running mac os 10.13 ("high sierra"). On all systems, I have set it to never sleep the system or display. Oddly, that doesn't suffice, so I also use caffeinate to prevent sleep. On the 10.13 systems, though, the display still goes to sleep, no matter what I try. This affects two things:

  • my opengl tests hang
  • "osascript -e 'tell app "System Events" to restart'" hangs

Since only the display is asleep, I can still ssh in and look around.

I currently run my script under caffeinate -dsiu -t 31536000, and when it hangs, evidently I've still got all the proper assertions going:

$ pmset -g assertionslog  2017-11-20 19:34:27 -0800 : Showing all currently held IOKit power assertions  Assertion status system-wide:  BackgroundTask 0  ApplePushServiceTask 0  UserIsActive 1  PreventUserIdleDisplaySleep 1  PreventSystemSleep 1  ExternalMedia 0  PreventUserIdleSystemSleep 1  NetworkClientActive 1  

and yet the display is in DevicePowerState 1:

$ ioreg -n IODisplayWrangler | grep -i IOPowerManagement  | | "IOPowerManagement" = {"DevicePowerState"=1,"CapabilityFlags"=0,"CurrentPowerState"=1,"MaxPowerState"=4}  

Executing another caffeinate -u wakes the display up and puts it into DevicePowerState 4 for 15 or so seconds, then it goes back to sleep and DevicePowerState 1, even if I give a longer timeout with -t. I've also tried repeating the -t argument after each assertion (in case the confusing manpage meant that).

To rescue "osascript -e 'tell app "System Events" to restart'", I have to issue "caffeinate -u". "caffeinate -d" or "caffeinate -i" are not sufficient.

See my comments at https://github.com/newmarcel/KeepingYouAwake/issues/92 for more details.

I guess I should use lldb to get a backtrace from a hung opengl test, figure out what API it's hung on, and then create a minimal app that sets the appropriate power management assertion, sleeps a bit, then calls the hanging API. I'll try to do that when I get a chance.

To work around it, I currently have this in a background script:

while true  do     caffeinate -ud sleep 10  done  

but that's not enough; CurrentPowerState dips down to 1 frequently on all systems (though I think only the 10.13 systems actually sleep the display and hang my tests).

Has anyone else run into this? Any suggestions how I can diagnose this further?

macOS keyboard shortcut for correcting misspelled words?

Posted: 13 Jun 2021 03:06 AM PDT

In a Mac OS X native textfields, misspelled and typo'd words are underlined with a red squiggle.

Is there a standard keyboard shortcut that will correct a mispelling by selecting the most-likely correction?

This should work in all native textfields. The solution should not be limited to a single app.

misspelled words in macOS document

It's already possible to Right Click a misspelled word. I'd like a keyboard shortcut to bring up a similar feature, so that I don't have to manually Right Click each word individually.

The feature could correct each word, one-by-one, allowing you to select each correction. Or, it could use the best guess for all misspelled words in the document.

correcting spelling via Right Click

App-specific sound output devices

Posted: 13 Jun 2021 02:10 AM PDT

I am looking for a control / app for sound output control which has function that allows me to have selective sound output for any app that plays sound or music.

Examples:

  • I am playing music in iTunes and I want it use my AirPort Output for the sound. The rest of sound / voice / music from my MacBook can use the internal speak or headset to play it.

  • At the same time, I can play my Spotify on my living room AirPort, my iTunes to my bedroom and watch YouTube on my MacBook.

Why does a .DS_Store file keep appearing on the desktop?

Posted: 12 Jun 2021 05:21 PM PDT

Every time I delete it from the desktop, I get the same file ".DS_store" created after some time. Is there a reason why this happens ? And can I permanently stop it from being created ?

V2EX - 技术

Posted: 13 Jun 2021 05:41 AM PDT

V2EX - 技术


火绒的杀毒,比 win10 自带的要好么?可是,我只想要火绒的网络进程监控和控制,怎么办?

Posted: 13 Jun 2021 05:35 AM PDT

如题。 如果火绒的杀毒功能,并不比 win10 好的话,不太想装这个。

但是,我最想要的是火绒的那个网络访问的进程监控。还可以直接允许 /禁止一些正在访问网络的程序(比如,腾讯的一些莫名其妙的后台进程)

这个能够分别安装么?还是一装就是"全家桶",所有都得安装了......

pixel experience 如何跳过开机引导的“准备手机”阶段?

Posted: 13 Jun 2021 05:13 AM PDT

已经尝试过的方法:

https://blog.allwens.work/androidSkipCheck/
https://www.v2ex.com/t/485478

为什么 mysql 要搞出 having where on 三个关键字?

Posted: 13 Jun 2021 05:07 AM PDT

我感觉完全没必要啊,只保留一个 where 然后直接按照 sql 语句的书写顺序决定限制条件和临时数据表是否生成何时生成不就好了吗?为什么要设计三个关键字?

pip install 怎么都用不了

Posted: 13 Jun 2021 04:37 AM PDT

在下才疏学浅,有空的前辈们能否帮忙

Traceback (most recent call last): File "/usr/local/bin/pipz" line 9: in smodules load_entry_point('pip==21.1.2' 'console scripts' File "/ust/Lib/python2.7/dist-packages/pkg_resources/ 'pipz°)0) init .py", Line 542, n load_entry_point return get _distribution(dist). load entry_point (group, name) File "/ust/lib/python2.7/dist-packages/pkg_resources/ init _-Py". Line 2569, in load entry_point return ep.load() File "/usr/Lib/pythonz.7/dist-packages/pkg_resources/__init. py" line 2229, in Load return self.resolve() File "Just/Lib/pythonz.7/dist-packages/pkg_resources/_init. • • Py" . Line 2235, in resolve module = import (self .module_name, fromlist=[' Level=0) File "*'usr/local/116/python2.7/dist-packages/pip/internat/cli/main.py" line 58 sys.stderr.write(f"ERROR: [exc]") SyntaxError: invalid syntax

CentOS 7.9 root 账号被提示"Operation not permitted",没弄明白怎么回事请教真大佬指点

Posted: 13 Jun 2021 02:58 AM PDT

环境描述 CentOS 7. 通过宝塔安装了 LNMP 环境,并未作其他特殊操作。 selinux 是 disable 状态,也从未安装过云锁一类软件,上下级其他目录读写文件或文件夹正常, 唯独一个目录修改权限、目录下新建出现异常. 请大佬指点下怎么回事,或者提供个思路怎么排查.

[root@vul_02 wwwroot]# pwd  /www/wwwroot  [root@vul_02 wwwroot]# whoami  root  [root@vul_02 wwwroot]# ll cwzdy.com/  total 28  drwxr--r-x 18 www www 4096 Mar 11  2019 chengyu  drwxr--r-x  7 www www 4096 Mar 11  2019 cy  drwxr--r-x 15 www www 4096 Apr 13 16:45 default  drwxr--r-x  6 www www 4096 Mar 11  2019 img  drwxr--r-x 17 www www 4096 Mar 11  2019 m  drwxr--r-x 16 www www 4096 Mar 11  2019 qiche  drwxr--r-x 17 www www 4096 Mar 11  2019 youjia  [root@vul_02 wwwroot]# touch cwzdy.com/new.txt  touch: cannot touch 'cwzdy.com/new.txt': Permission denied  [root@vul_02 wwwroot]# mkdir cwzdy.com/new_dir -v  mkdir: cannot create directory 'cwzdy.com/new_dir': Permission denied  [root@vul_02 wwwroot]# chmod 777 -v cwzdy.com  chmod: changing permissions of 'cwzdy.com': Operation not permitted  failed to change mode of 'cwzdy.com' from 0755 (rwxr-xr-x) to 0777 (rwxrwxrwx)  [root@vul_02 wwwroot]#   [root@vul_02 wwwroot]# getenforce   Disabled  [root@vul_02 wwwroot]#  

pycharm Python interpreter 添加 anaconda 下面同步的 packages 不完整

Posted: 13 Jun 2021 02:04 AM PDT

用 pycharm 的 python interpreter 添加 anaconda 的环境后,下面同步的 package 不完整 只显示以下几个,不知道什么原因,改了几次都不太行,在线等

ca-certificates 2021.5.25 2021.5.25 certifi 2021.5.30 2021.5.30 libcxx 10.0.0 10.0.0 libffi 3.3 3.3 ncurses 6.2 6.2 openssl 1.1.1k 1.1.1k pip 21.1.2 21.1.2 python 3.8.10 3.9.5 readline 8.1 8.1 setuptools 52.0.0 52.0.0 sqlite 3.35.4 3.35.4 tk 8.6.10 8.6.10 wheel 0.36.2 0.36.2 xz 5.2.5 5.2.5 zlib 1.2.11 1.2.11

怎么在 centos7 上面安装 M2Crypto 这个库呀

Posted: 13 Jun 2021 01:38 AM PDT

我用 yum install rh-python36 装的 python36

现在需要装 M2Crypto 这个库, 发现怎么装都装不上

早知道用 ubuntu

go 有什么日志库,可以让日志文件按小时/天滚动?

Posted: 13 Jun 2021 12:26 AM PDT

类似 Python 的 TimedRotatingFileHandler,when='midnight'

Sptingboot 集成 swagger, jaxrs, jaxws 示例

Posted: 12 Jun 2021 09:59 PM PDT

https://github.com/mightofcode/springboot-jaxrs-jaxws-swagger-example

包含:
1,cxf 开发的 rest 、soap 接口
2,springmvc 开发的 rest 接口
2,swagger-ui

soap 过于复杂,使用 soap 的项目都不是出于效率上的目的,更像是为了给 java 工程师找活干
rest 相比 soap,有巨大的进步

小程序搜 xx 优选之类的, 里面有各地团长,但手机号码都打了 xx,如何能拿到?

Posted: 12 Jun 2021 07:23 PM PDT

爬虫? 还是各种技术外手段?

Recent Questions - Unix & Linux Stack Exchange

Posted: 13 Jun 2021 05:23 AM PDT

Recent Questions - Unix & Linux Stack Exchange


How is "fifty million man-years" development effort inside <The Art of Unix Programming>

Posted: 13 Jun 2021 04:59 AM PDT

I was reading the book <The Art of Unix Programming>

There is one line claiming

The three and a half decades between 1969 and 2003 is a long time. Going by the historical trend curve in number of Unix sites during that period, probably somewhere upwards of fifty million man-years have been plowed into Unix development worldwide.

That's 1.47 million man-year goes into Unix development during that period. It means 1.47 million developers worked on Unix system yearly.

Personally I find the number a bit hard to believe. Or am I understanding the number in the wrong way?

How to recover Data after "mdadm zero-superblocks"

Posted: 13 Jun 2021 05:16 AM PDT

I wanted to swap from CentOS to Openmediavault. I had a RAID1 with mdadm in place and wanted to split it again into two separate disks. The Guide (Similar to ArchWiki) told me to do the following:

umount -l /mnt/nas  mdadm --stop /dev/md0    mdadm --zero-superblock /dev/sdc1  mdadm --zero-superblock /dev/sdd1  

Then I installed OMV5 and now I can not mount it because the superblock is gone(which I thought would not be a problem).

I will provide more information if needed. Thanks in advance :)

fdisk:

fdisk -l /dev/sdd  Disk /dev/sdd: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors  Disk model: WDC WD30EFRX-68E  Units: sectors of 1 * 512 = 512 bytes  Sector size (logical/physical): 512 bytes / 4096 bytes  I/O size (minimum/optimal): 4096 bytes / 4096 bytes  Disklabel type: gpt  Disk identifier: FB8D182E-6744-4C9F-8E08-B3038729CA6D    Device     Start        End    Sectors  Size Type  /dev/sdd1   2048 5860524976 5860522929  2.7T Linux RAID  

blkid:

/dev/sdd1: LABEL="NAS" UUID="2f0e4622-29fa-41e5-8cd5-bc1d8d5e98e0" TYPE="ext4" PARTLABEL="primary" PARTUUID="01294e69-ee07-49ea-9d04-46b379d9c4c4"  

mount:

mount /dev/sdd1 /test  mount: /test: wrong fs type, bad option, bad superblock on /dev/sdd1, missing codepage or helper program, or other error.  

Disagreement between glib and gcc after gcc downgrade

Posted: 13 Jun 2021 04:34 AM PDT

I updated my distro a week ago Linux *** 5.10.41-1-MANJARO x86_64 GNU/Linux

But need to work with gcc 10.2.0 and its equivalents gcc-libs 10.2.0

I downgraded gcc and glib according to this guide

There is no problem with this but other thing get break like Firefox, Chromium etc and it gives the following error

firefox  /usr/lib/firefox/firefox: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /usr/lib/firefox/firefox)  

How can I downgrade gcc and coworker libs which I think its glib

I don't know how to deal with glib

sudo downgrade glib-  glib-compile-resources  glib-genmarshal         glib-mkenums  glib-compile-schemas    glib-gettextize   

Should I downgrade a glib thing belongs to them?

Why qbittorrent and deluge can download the resource instead of transmission?

Posted: 13 Jun 2021 04:21 AM PDT

I found that both qbittorrent and deluge can download the sample torrent which i have uploaded in the dropbox.

sample torrent to check enter image description here enter image description here

It can't be downloaded with transmission,why? enter image description here Please try to download it with transmission,maybe some wrong setting in my transmission!?

different ways of disabling password logins on FreeBSD

Posted: 13 Jun 2021 04:00 AM PDT

What is the difference between:

pw lock <user>

and

pw mod user <user> -w no

They both accomplish the same thing: disabling password-based logins, but why would I pick one way over the other?

How can I disable (and later re-enable) one of my NVIDIA GPUs?

Posted: 13 Jun 2021 05:19 AM PDT

I'm working on a system with multiple NVIDIA GPUs. I would like disable / make-disappear one of my GPUs, but not the others; without rebooting; and so that I can later re-enable it.

Is this possible?

Notes:

  • Assume I have root (though a non-root solution for users which have permissions for the device files is even better).
  • In case it matters, the distribution is either SLES 12 or SLES 15, and - don't ask me why :-(

bash multiline string variable assignment failing

Posted: 13 Jun 2021 03:51 AM PDT

in bash why does this work fine:

$ cat test1.sh  #!/bin/bash  echo "some text" \  "some more text"  $ ./test1.sh  some text some more text  

but this fails

$ cat test2.sh  #!/bin/bash  text="some text" \  "some more text"  echo $text  $ ./test2.sh  ./test2.sh: line 3: some more text: command not found  

I was expecting both test1.sh and test2.sh to do the same thing.

Applying simple string mappings on JSON files

Posted: 13 Jun 2021 02:36 AM PDT

Somehow I think there must be a one-liner to apply a simple mapping on the command line. In this case the keys in JSON will (as usual) provide context, ensuring that we don't foolishly replace strings that shouldn't.

Suppose we are given a library catalog in a JSON file using the Dewey Decimal Classification

[    {      "Title": "Design Pattern",      "Call Number": "005.12 DES"    },    {      "Title": "Intro to C++",      "Call Number": "005.133 C STR"    }  ]  

as well as a mapping between Dewey and the Library of Congress call numbers

[    {      "Dewey": "005.12 DES"      "Congress": "QA76.64 .D47 1995X"    },    {      "Dewey": "005.133 C STR"      "Congress": "QA76.73.C153 S77 2013"    }  ]    

and want to produce the output file:

[    {      "Title": "Design Pattern",      "Call Number": "QA76.64 .D47 1995X"    },    {      "Title": "Intro to C++",      "Call Number": "QA76.73.C153 S77 2013"    }  ]  

Does this still fit within the one-line set of transformations that jq will handle?

What is more efficient or recommended for reading output of a command into variables in Bash?

Posted: 13 Jun 2021 03:32 AM PDT

If you want to read the single line output of a system command into Bash shell variables, you have at least two options, as in the examples below:

  1. IFS=: read user x1 uid gid x2 home shell <<<$(grep :root: /etc/passwd | head -n1)

and

  1. IFS=: read user x1 uid gid x2 home shell < <(grep :root: /etc/passwd | head -n1)

Is there any difference between these two? What is more efficient or recommended?

How to assign a remote public ip (via wireguard) to lxc container

Posted: 13 Jun 2021 02:04 AM PDT

What I have:

lxc host

# ifconfig  wg1: flags=209<UP,POINTOPOINT,RUNNING,NOARP>  mtu 1420  inet 192.168.7.2  netmask 255.255.255.0  destination 192.168.7.2  ...    enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  inet 192.168.1.110  netmask 255.255.255.0  broadcast 192.168.1.255  ...    lxdbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  inet 10.7.56.1  netmask 255.255.255.0  broadcast 0.0.0.0  ...  

/etc/wireguard/wg1.conf

[Interface]  PrivateKey = my_private_key  Address = 192.168.7.2/24    [Peer]  PublicKey = my_public_key  AllowedIPs = 0.0.0.0/0  Endpoint = my_remote_server_ipv4:51194  PersistentKeepalive = 15  
# route -n  Kernel IP routing table  Destination     Gateway         Genmask         Flags Metric Ref    Use Iface  0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 enp2s0  10.7.56.0       0.0.0.0         255.255.255.0   U     0      0        0 lxdbr0  192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 enp2s0  192.168.1.1     0.0.0.0         255.255.255.255 UH    100    0        0 enp2s0  192.168.7.0     0.0.0.0         255.255.255.0   U     0      0        0 wg1  

lxc container

# curl ifconfig.me  my_remote_server_ipv4  

Everything is ok, but:

# ifconfig  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  inet 10.7.56.100  netmask 255.255.255.0  broadcast 10.7.56.255  ...  

What I want:

# ifconfig  eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  inet my_remote_server_ipv4  netmask 255.255.255.0  broadcast ...  ...  

I want to do this without changing anything in the container.

Upd. I want to assign a public ip (owned by my remote server) to my home lxc container. Looks like it's impossible...

Ensuring EXT4/BTRFS/other_journal_file_system guarantee backups even in power outages

Posted: 13 Jun 2021 02:43 AM PDT

I'm using RSYNC to do periodic backups of my data into an external hard disk formatted in EXT4. I'm using the "hard link option", thus files that haven't changed from the previous backup are just hard linked instead of fully copied, which reduces the used disk space.

To guarantee that a power cut, a system hang, or other problem during backups doesn't pose a problem, I first do the backup into a temporary folder, run a SYNC to flush the disk cache, rename the temporary folder to the definitive name, and run another SYNC. This way I can guarantee that all the data is in the disk before committing the backup.

The point is that now I want to use a NAS, but I can't order a SYNC command (to flush the remote cache), neither through SFTP, nor NFS, which means that a problem in the middle of a backup can leave it in an intermediate state (like a file with only part of the data).

My question is: setting my NAS in "data=journal" mode would guarantee that there won't be incorrect data if I suffer a power loss, as long as I first do the backup in a temporary folder and then, after that, I rename it to the definitive name? Do other filesystems (like BTRFS or ReiserFS) have that mode and should it be set like in EXT4? And, of course, which NAS can you recommend me that allows to enable that mode?

protection for duplicate sed replacements

Posted: 13 Jun 2021 01:58 AM PDT

This is more of a architectural question:

I have a script that does some in file sed replacements/additions like:

sed -i 's/MY_VAR = 1000/MY_VAR = 1000\nMY_VAR2 = 500/' file.txt  

which works fine but this is part of a fairly large script and someone may either ^C the first run and re-run this or just re-run it N-times back-to-back which will result in something like

MY_VAR = 1000  MY_VAR2 = 500  MY_VAR2 = 500  MY_VAR2 = 500  MY_VAR2 = 500  ...  

which might not be expected. So my question is: what's the best way to avoid this? I came up with something like:

if [ ! -f file.txt~copy ]  then      cp file.txt file.txt~copy      sed -i 's/MY_VAR = 1000/MY_VAR = 1000\nMY_VAR2 = 500/' file.txt  fi  

which should work fine but I was wondering if there's a better/recommended way to go about it? The above could obviously be problematic if your files are significantly large and you may just want to touch a copy file for protection instead.

Flattening JSON lines arrays with JQ

Posted: 13 Jun 2021 05:20 AM PDT

I can write

> echo '{"a": "arbiter", "b": "brisk"}{"a": "astound", "b": "bistro"}' | jq '.a, .b'  "arbiter"  "brisk"  "astound"  "bistro"  

but if I do

> echo '{"a": "arbiter", "b": "brisk", "c": ["cloak", "conceal"]} {"a": "astound", "b": "bistro", "c": ["confer", "consider"]}' | jq '.a, .b, .c'  

I get

"arbiter"  "brisk"  [      "cloak",      "conceal"  ]  "astound"  "bistro"  [      "confer",      "consider"  ]  

How do I flatten the c arrays to get instead

"arbiter"  "brisk"  "cloak",  "conceal"  "astound"  "bistro"  "confer",  "consider"  

Update

Since null safety is quite fashionable in several modern languages (and justifiably so), it is perhaps fitting to suppose that the question as asked above was incomplete. It's necessary to know how to handle the absence of a value.

If one of the values is null,

> echo '{"b": "brisk"}{"a": "astound", "b": "bistro"}' | jq '.a, .b'  

we get a null in the output

null  "brisk"  "astound"  "bistro"  

That may well be what we want. We could add a second step in the pipeline (watching out not to exclude "null"), but it's cleaner if jq itself excludes nulls. Just writing select(.a != null) does the trick, but introduces a {} level. What is the right way to discard nulls from within jq?

Have I put ZFS in a dangerous state by building against the wrong kernel headers?

Posted: 13 Jun 2021 03:53 AM PDT

I've reverted to an older kernel after discovering that OpenZFS does not have currently have DKMS packages for the latest 5.12 release of Fedora 33 after a yum update.

I used Koji with the search term Kernel to download and install the necessary dependencies to revert to the latest 5.11 kernel, rebooted into it, and rebuilt ZFS without issue.

But while removing packages from the newer kernel I found that only kernel-headers for 5.12.9-200 was still installed (kernel-headers-5.12.9-200.fc33.x86_64 specifically).

I then realized that the packages listed by Koji for the packages I'd selected for 5.11 did not include kernel-headers and I had neglected to revert this before rebuilding ZFS.

Everything appears to be running correctly but have I inadvertently put my system or ZFS into a dangerously undefined state as a result?

The packages annobin, boost-devel, perl-ExtUtils-CBuilder, and zfs all depend on kernel headers and I am most worried about zfs.

I plan to install the correct kernel headers and rebuild these packages but wanted to ask here first for advice.

Also, why is kernel-headers not listed on the Koji page for the selected kernel? Because headers do not always track with the actual kernel release, I had to manually locate the last release for 5.11 which was 5.11.20-200. I would have preferred if this information was linked directly by Koji with the other kernel packages as tracking it manually is subject to error.

SSH Tunnel with automatic reconnect and password auth in Docker container

Posted: 13 Jun 2021 03:50 AM PDT

I want to forward a Socks5 proxy using SSH with password authentication inside a Docker container. YES, I know that SSH keys would be better. But since it's not my own server, I'm not able to use keys, they just offer user/password authentication. autossh seems to be the right tool for this job, so I used it with sshpass in my entrypoint shellscript:

sshpass -P "assphrase" -p "${PASSWORD}" autossh -M0 -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -oStrictHostKeyChecking=no -oUserKnownHostsFile=custom_known_hosts -4 -N -D *:5080 ${USER}@${HOST}  

Both packages are installed in the Dockerfile

FROM debian:stretch-slim  RUN apt-get update \    && apt-get upgrade -y  RUN apt-get install -y ssh wget sshpass autossh  RUN wget https://www.provider.com/custom_known_hosts   COPY run.sh .  ENTRYPOINT "./run.sh"  

This establishes the SSH tunnel to the Socks5 proxy. But after the internet connection got lost, the authentication fails:

socks5_forward_1  | Warning: Permanently added 'server.provider.com' (ECDSA) to the list of known hosts.  socks5_forward_1  | SSHPASS searching for password prompt using match "assword"  socks5_forward_1  | SSHPASS read: myUser@server.provider.com's password:  socks5_forward_1  | SSHPASS detected prompt. Sending password.  socks5_forward_1  | SSHPASS read:  socks5_forward_1  |  socks5_forward_1  | packet_write_wait: Connection to 1.2.3.4 port 22: Broken pipe  socks5_forward_1  | SSHPASS read: myUser@server.provider.com's password:  socks5_forward_1  | SSHPASS detected prompt, again. Wrong password. Terminating.  socks5_forward_1  | Permission denied, please try again.  socks5_forward_1  | Permission denied, please try again.  socks5_forward_1  | Received disconnect from 1.2.3.4 port 22:2: Too many authentication failures  socks5_forward_1  | Authentication failed.  socks5_forward_1  | Permission denied, please try again.  socks5_forward_1  | Permission denied, please try again.  socks5_forward_1  | Received disconnect from 1.2.3.4 port 22:2: Too many authentication failures  socks5_forward_1  | Authentication failed.  

I also tried

sshpass -v -p "${PASSWORD}" autossh -M0 -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -oStrictHostKeyChecking=no -oUserKnownHostsFile=custom_known_hosts -4 -N -D *:5080 ${USER}@${HOST}  

and build a loop myself since I thought that sshpass won't properly work after autossh tries to reconnect:

while true; do command sshpass -P "assphrase" -p "${PASSWORD}" ssh -M0 -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -oStrictHostKeyChecking=no -oUserKnownHostsFile=custom_known_hosts -4 -N -D *:5080 ${USER}@${HOST}; [ $? -eq 0 ] && break || sleep 5; done  

Both approaches doesn't work. Since my ISP does a reconnect every 24 hours, it's annoying to restart the container every day by hand. I couldn't figure out yet why at the last approach in the loop can' handle the reconnect properly

unable to access Manjaro (kernel file not found)

Posted: 13 Jun 2021 01:56 AM PDT

I have Prime OS and Windows 10 alongside Linux Manjaro. I was using Prime OS nearly 2 hours. Then, I turned off my laptop for 30-60 minutes. Then, I turned my laptop on and I was using Windows 10 for 1 hours. After working on Windows 10, I had thought to work in Linux Manjaro. So, I turned my laptop off. Unfortunately, It was taking too much time to turn off my laptop that's why I had turned my laptop off by power button. Again, Windows 10 was automatically opening (without showing grub). So, I had again turned my laptop off by power button again. When I turned my laptop on and clicked on Linux Manjaro, I saw the following screen.

error: file `/boot/vmlinuz-5.10-x86_64' not found.  error: you need to load the kernel first.    Press any key to continue..._   

I think that I can't access Manjaro's file from Windows or, Prime OS (I am not sure). How can I turn on Manjaro?

Here's my grub info grub info

I have found following solutions

  1. https://forum.manjaro.org/t/boot-file-not-found/60059
  2. https://forum.manjaro.org/t/file-boot-vmlinuz-5-4-x86-64-not-found/18488
  3. https://forum.manjaro.org/t/manjaro-unable-to-boot-error-file-boot-vmlinuz-5-7-x86-64-not-found/18445/3

Currently, I don't have bootable USB. So, how can I deal with it from grub? I can move to grub command-line also.

I had said what I did before starting Manjaro. After searching little bit, I remember that I had broke updating system. I had run following command

sudo pacman -Syyu  

Then, I had pressed on Ctrl+C. Since then, I am facing the problem.


Currently what i am thinking that is searching for vmlinuz somehow in Manjaro from grub command line.

Image alt text

I had tried with search,locate,find. None of them were working. But, search option was used for something else.

USB Created with dd will not boot

Posted: 13 Jun 2021 01:06 AM PDT

I downloaded the newest RHEL 8 ISO (9 GB) and created a bootable USB with a dd command in CentOS 7.9. But it would not boot at system startup. I tried it with 2 different USBs but to no avail.

Secondly I tried the Rufus software on Windows. It said that there is some kind of "Lock" on the ISO image from the creators, so it, (Rufus), also used the dd option to create the USB. The result is the same; it will not boot to start the installation process.

dd if=rhel-8.4-x86_64-dvd of=/dev/sdd1 command was used.

ssh with separate stdin, stdout, stderr AND tty

Posted: 13 Jun 2021 03:50 AM PDT

Problem

Consider a command like this:

<binary_input ssh user@server 'sudo tool' >binary_output 2>error.log  

where tool is arbitrary and ssh is a wrapper or some ssh-like-contraption that allows the above to work. With regular ssh it doesn't work.

I used sudo here but it's just an example of a command that requires tty. I'd like a general solution, not specific to sudo.


Research: the cause

With regular ssh it doesn't work because:

  • sudo needs tty to ask for password (or to work at all), so I need ssh -t; actually in this case I need ssh -tt.
  • On the other hand ssh -tt will make sudo read the password from binary_input. I want to provide the password via my local tty. Even if sudo is configured to work without password or if I inject the password to the binary_input, ssh -tt will make sudo and tool read from the remote tty and write output and errors and prompts to the remote tty. Not only I won't be able to tell the output and the errors/prompts apart locally. All the streams will be processed by the remote tty and this will mangle binary data.

Research: comparison to commands that work

  • This local command is the reference point. Let's assume it successfully processes some binary data:

    <binary_input tool >binary_output  
  • If I need to run tool on a server, I can do this. Even if ssh asks for my password, this will work:

    <binary_input ssh user@server tool >binary_output  

    In this case ssh is transparent for binary data.

  • Similarly local sudo can be transparent. The following command won't mangle the data even if sudo asks for my password:

    <binary_input sudo tool >binary_output  
  • But running tool on the server with sudo is troublesome:

    <binary_input ssh user@server 'sudo tool' >binary_output  

    In this configuration ssh and sudo together cannot be transparent in general. Finding a way to make them transparent is the gist of this question.


Research: similar questions

I have found few similar questions:

  • Use sudo with ssh command and capturing stdout

    This question cares about stdout only. The existing answer (from the author of the question) advises sudo -S which consumes stdin. I don't really want to alter my binary_input. And I would appreciate a solution not specific to sudo.

  • stderr over ssh -t

    This concentrates on passing Ctrl+c and the background is GNU parallel. A workaround that only makes Ctrl+c work without a remote tty is not enough for me.

  • SSH: Provide additional "pipe" fds in addition to stdin, stdout, stderr

    This is a good start (especially this answer, I think). However here I want to emphasize the need for tty. I want a solution that automates things and allows me to use remote sudo (or whatever) as if it was local.


My explicit question

In the following command:

<binary_input ssh user@server 'requires-tty' >binary_output 2>error.log  

requires-tty is a placeholder for code that requires a tty but processes binary data from its stdin to its stdout. It seems I need ssh -tt, otherwise requires-tty will not work; and at the same time I mustn't use ssh -tt, otherwise the binary data will be mangled. How to solve this problem in a convenient way?

requires-tty can be sudo … but I don't want a solution specific to sudo.

I imagine the ideal(?) solution will be a script/tool that replaces ssh in the above invocation and just works. It should(?) connect the remote stdin, stdout and stderr each to its local counterpart, and the remote tty to the local tty.

If it's possible, I prefer a client-side solution that does not require any server-side companion program.

Can I install another Linux distribution to an extra HDD without rebooting?

Posted: 13 Jun 2021 04:38 AM PDT

I have a computer with a Linux distribution installed on partitions in drive /dev/sda. I also have another physical drive, /dev/sdb.

I want to install Linux to the second physical drive - to later run either on the same computer or another one. I know the planned hardware configuration of the target machine, and I have an installer for my new Linux distribution (say on a third drive, /dev/sdc, or in an ISO I can mount etc.)

Can I perform the installation without rebooting? That is, other than in the usual way of booting from an installation medium?

If this question is too general, then - can I do so with Debian Buster/Devuan Beowulf?

Note: You may make any reasonable assumption about the system, but please state it explicitly.

Virtualbox shared folders with symlinks

Posted: 13 Jun 2021 01:58 AM PDT

I want to configure 1 shared folder /home/host/shared and put symlinks to other shared items in that shared directory to make them accessible by the guest machine like /home/host/shared/d1 --> /home/host/a_linked_dir. This is so that I can modify the files & directories as I use the VM without having to change the config in Virtualbox and so that multiple VMs can easily be configured to use a single shared folder. However, putting s symlink /home/guest/shared/link --> /home/host/shared/f1 doesn't allow the guest machine to access the linked directory and instead just points to a target non-existent on the guest machine.

Is there a way to use symlinks between the host & guest VMs in Virtualbox?

Trouble selecting "Fully Preemptible Kernel (Real-Time)" when configuring/compiling from source

Posted: 13 Jun 2021 02:00 AM PDT

I am trying to compile the 5.4 kernel with the latest stable PREEMPT_RT patch (5.4.28-rt19) but for some reason can't select the Fully Preemptible Kernel (RT) option inside make nconfig/menconfig.

I've compiled the 4.19 rt patch before, and it was as simple as copying the current config (/boot/config-4.18-xxx) to the new .config, and the option would show. Now I only see:

No Forced Preemption (Server)  Voluntary Kernel Preemption (Desktop)  Preemptible Kernel (Low-Latency Desktop)  

And if I press F4 to "ShowAll", I do see the option:

XXX Fully Preemptible Kernel (Real-Time)   

But cannot select it. I've tried manually setting it in .config with various PREEMPT options like:

CONFIG_PREEMPT=y  CONFIG_PREEMPT_RT_BASE=y  CONFIG_PREEMPT_RT_FULL=y  

But it never shows. I just went ahead and compiled it with CONFIG_PREEMPT_RT_FULL=y (which is overwritten before when saving the make nconfig), but it seems it's still not the fully preemptive kernel that is installed.

With 4.19, uname -a would show something like:

Linux 4.19.106-rt45 #2 SMP PREEMPT RT <date>

or something like that, but now it will just say:

Linux 5.4.28-rt19 #2 <date>

Anyone know what I'm missing here?

OS: CentOS 8.1.1911

Kernel: 4.18.0-147.8.1 -> 5.4.28-rt19

When can a "cd" command fail in a shell script and what can I do to remedy it?

Posted: 13 Jun 2021 05:06 AM PDT

I have a shell script that failed to finish last week; it was a failed "cd" command and it exits if it fails.

The script is a bash shell script for configuring new Debian installs. Here is the full script: debianConfigAswome.sh. The script is run as root so it has full access to the file-system.

Can you please list all the reasons a script would not be able to successfully execute a cd command and what to do to avoid the error?

Can I use Clonezilla to backup and restore a bootable USB volume?

Posted: 13 Jun 2021 05:02 AM PDT


I have this external USB HDD that I've installed Lubuntu 16.04 and Windows 10 on as a dual boot. They are portable installations that I can take around with me and use on a variety of computers and have all my apps and configurations with me. It's a real installation of Lubuntu, not a persistent live USB. Windows 10 was done through WinToUSB.

Can I use Clonezilla to make a backup of this drive? And if I then restore that image to another drive, will that second drive also be bootable in the same way?

What to do if the owner of /usr/bin/* changes to a non-root?

Posted: 13 Jun 2021 04:00 AM PDT

It would be the right thing to say that I messed up!

Accidentally, I changed the owner of all files in /usr/bin to 'dev' from 'root'. Now, sudo does not work! If I use sudo with any command, I get -

sudo: effective uid is not 0, is sudo installed setuid root?

I cannot use chown command to change the owner back to 'root'. This is a major set back!

Because this is a Virtual Machine, I cannot access the Recovery Console. Infact, even the reboot command needs the user to have 'root' access.

Experts, please help me in getting control of the OS without having to re-image.

Thanks!

P.S - Possibly a duplicate but reposting as his solution was to start afresh.

More info -

su - root always says incorrect password. Unfortunately, the owner of su is also 'dev'.

I am able to create a new user using the GUI. It accepted the root password. How do I grant the new user with root access without using visudo.

Apache - Allow access for folders starting with /

Posted: 13 Jun 2021 02:07 AM PDT

I'm running apache in a linux environment. I've to serve files whose directory structure have "/." in it. Now, apache by default won't allow files with /. To remove the constraint, I've included the following entry in httpd conf.

  <DirectoryMatch "^.|/.">      Order allow,deny      Allow from all  </DirectoryMatch>  
But,this opens up all hidden directories under apache root. I'm trying to use a directory pattern so that it'll only allow files under this directory. For e.g. the directory path always start with /content/. The occurrence of /. can be anywhere. For e.g.
  /content/url/test/.NET/sample/abc.html  /content/xyz/.BETA/sample/test.html  
As you can see, I'm trying to create a pattern where the rule would allow directories starting with "/content" and can having "/." in its path. Just wondering if it's possible to have a rule like this in option.

How to stop the find command after first match?

Posted: 13 Jun 2021 01:26 AM PDT

Is there a way to force the find command to stop right after finding the first match?

OSCHINA 社区最新新闻

Posted: 13 Jun 2021 04:49 AM PDT

OSCHINA 社区最新新闻


Apache Dubbo 3.0.0 正式版即将发布

Posted: 13 Jun 2021 02:10 AM PDT

在今年3月份Apache Dubbo发布首个3.0分支预览版本3.0.0.preview时,官方已预告6月份将发布3.0正式版。 恰逢端午假期,前方传来最新消息,Dubbo项目的GitHub发布页面3.0.0版已显示为预发布状态。按照惯例,需要发起社区邮件投票,通过后将进入正式版本的发布流程。Apache Dubbo 3.0.0版发布后,相关构建稍后将会同步至Mav...

Recent Questions - Server Fault

Posted: 13 Jun 2021 03:21 AM PDT

Recent Questions - Server Fault


site2site wireguard with docker : routing problems

Posted: 13 Jun 2021 02:08 AM PDT

Disclaimer: repost from stackoverflow: https://stackoverflow.com/questions/67917278/site2site-wireguard-with-docker-routing-problems

I am trying to have two containers, running on two RPI, act as a site-to-site VPN between Network 1 and Network 2.

With the setup below, I am able to ping from within the container each other network:

  • from docker container 1 I can ping an address 192.168.1.1
  • from docker container 2 I can ping the address 192.168.10.1

But if I try to ping 192.168.1.1 from the System1 host (192.168.10.100) I have errors (see below image to visualize what I am trying to do).

I understand I have to add a static route on system1 host (192.168.10.100) to direct the traffic for 192.168.1.0/24 through the wireguard container (172.17.0.5), thus I run:

$i p route add 192.168.1.0/24 via 172.17.0.5  $ ip route  default via 192.168.10.1 dev eth0 proto dhcp src 192.168.10.100 metric 100   172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1   172.18.0.0/16 dev br-e19a4f1b7646 proto kernel scope link src 172.18.0.1 linkdown   172.19.0.0/16 dev br-19684dacea29 proto kernel scope link src 172.19.0.1   172.20.0.0/16 dev br-446863cf7cef proto kernel scope link src 172.20.0.1   172.21.0.0/16 dev br-6800ed9b4dd6 proto kernel scope link src 172.21.0.1 linkdown   172.22.0.0/16 dev br-8f8f439a7a28 proto kernel scope link src 172.22.0.1 linkdown   192.168.1.0/24 via 172.17.0.5 dev docker0   192.168.10.0/24 dev eth0 proto kernel scope link src 192.168.10.100   192.168.10.1 dev eth0 proto dhcp scope link src 192.168.10.100 metric 100   

but the ping to 192.168.1.1 still fails.

by running tcpdump on the container 2 I see that some packets are indeed reaching the container :

root@936de7c0d7eb:/# tcpdump -n -i any  tcpdump: verbose output suppressed, use -v or -vv for full protocol decode  listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes  10:11:19.885845 IP [publicIPsystem1].56200 > 172.17.0.6.56100: UDP, length 128  10:11:30.440764 IP 172.17.0.6.56100 > [publicIPsystem1].56200: UDP, length 32  10:11:35.480625 ARP, Request who-has 172.17.0.1 tell 172.17.0.6, length 28  10:11:35.480755 ARP, Reply 172.17.0.1 is-at 02:42:24:e5:ac:38, length 28  

so I guess it is not a routing problem on system 1.

Can anyone tell me how to diagnose this further?

enter image description here

Site 1 Site 2
Network 1 IP range 192.168.10.0/24 192.168.1.0/24
host system address 192.168.10.100 192.168.1.100
bridge docker0 range 172.17.0.0/16 172.17.0.0/16
container address 172.17.0.5 172.17.0.6

System 1 - wg0.conf

[Interface]  Address = 10.13.18.2  PrivateKey = *privatekey*  ListenPort = 56200  PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE  PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE    [Peer]  PublicKey = *publickey*  Endpoint = *system2address*:56100  AllowedIPs = 10.13.18.1/32 , 192.168.1.0/24  

System 2 - wg0.conf

[Interface]  Address = 10.13.18.1  ListenPort = 56100  PrivateKey = *privatekey*  PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE  PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE    [Peer]  # peer_casaleuven  PublicKey = *publickey*  AllowedIPs = 10.13.18.2/32 , 192.168.10.0/24  Endpoint = *system1address*:56200  

OpenVidu/Kurento: Unable to create media pipeline for session

Posted: 13 Jun 2021 12:22 AM PDT

Our OV 2.17.0 on premises (Ubuntu 18 server) works well for a while (a day or two), then stop working. I can create a new session, etc using REST, but any attempt to join newly created session failed with the server event "unable to create media pipeline for session XXX". Restart the server helps. Then it works for another 2 days and everything repeats.

I also see that all old sessions stay in memory (I have 10-11 sessions after the crash), although it's obvious that at that moment no connections were made to them for hours. I expected based on the another thread in this forum, that old sessions should be auto-destroyed. Not sure if that connected to the issue I'm facing.

Please find the logs of both Kurento and OpenVidu here.

Logs were recorded after the moment when server was failed for a while, before the restart.

finding which tier 1 or isp to connect to to reduce latency

Posted: 12 Jun 2021 10:40 PM PDT

I am looking to connect to 4 location p,q,r,s. I a ntrying to find the set of locations where I should connect to (isp or pop) to minimize latency . Is it lower latency to connect to a tier 1 network which would connect to 4 ip p,p,r,s ? Is there a lower latency path to connect p,q,r,s through a tier 2 network ? how do I find this?

How do I configure routing for non-knative service in a Knative & Istio installed k8 cluster?

Posted: 12 Jun 2021 09:23 PM PDT

I have a Knative installed with Istio as networking layer (without injection) The kubernetes cluster is using Istio ingress gateway as default ingress. Most Knative service's routing are managed automatically by Knative & Istio.

However I am trying to run a nifi native kubernetes services on the same cluster, how do I setup the ingress configuration on Istio ingress gateway for the services. Any reference to share?

Or is it possible to setup 2 ingress (1 Istio, 1 nginx) in the cluster, and have the native k8 service uses the nginx ingress?

I'm doing that cause istio is quite new to me and Knative abstracted the Istio networking element when deploying knative services but not the native k8 services.

Hope my question makes sense. Thank you.

Double check if an SSH account is SFTP-only and chrooted

Posted: 12 Jun 2021 08:07 PM PDT

Note that this question is not about how to do chroot or make an account SFTP only. The question is about whether there are specific ways for a sysadmin to check if a chrooted and SFTP-only account is correctly set.

Usually I do chroot or SFTP-only settings following some online resources such as this one: https://wiki.archlinux.org/title/SFTP_chroot. But the issue is, unlike simply changing an option from No to Yes in a configuration file, I need to complete multiple steps to finish the chroot or SFTP-only settings. Since this is such a fundamentally important security setting, I am always thinking: Is my configuration correct? Do I miss something minor but critical?

Currently what I am doing to verify the correctness is very simple:

  • To validate an account is SFTP-only, I just try to login as a normal user and see if I can see a This service allows sftp connections only. message and get rejected.
  • To validate an account is properly chrooted, I login as an SFTP user and check if I can switch to a directory which the account is not supposed to get in (usually I just double-click many many times the .. item at the top of a file list on an SFTP client's GUI).

enter image description here

Are these two things the only things a sysadmin needs to do to be 100% sure that the settings are correct?

nginx: Use of proxy_set_header results in failed upstream connections

Posted: 12 Jun 2021 08:02 PM PDT

I have a very basic nginx reverse proxy setup for openstreetmaps:

worker_processes  1;    error_log  logs/error.log  notice;  pid        logs/nginx.pid;    events {      worker_connections  1024;  }    http {      postpone_output 0;        log_format logresponsetime '$remote_addr - $remote_user [$time_local] "$request" $status $bytes_sent "$http_referer" "$http_user_agent" $request_time $upstream_response_time';        access_log logs/access.log logresponsetime;    resolver 192.168.0.1 ipv6=off;      #default proxy settings:    proxy_http_version 1.1;    proxy_set_header Connection "";    proxy_read_timeout 600;    proxy_ssl_server_name on;      upstream tile.openstreetmap.org {      server tile.openstreetmap.org:443;      keepalive 10;      keepalive_time 5m;    }         server {      listen 480;      access_log logs/osm.http.access.log logresponsetime;      server_name $hostname;        location / {        resolver 192.168.0.1 ipv6=off;                proxy_set_header User-Agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36";          proxy_pass https://tile.openstreetmap.org;      }    }  }  

There is a line to set User-Agent header because OSM requires it and I need compatibility with a client that doesn't send a user agent string. However, when nginx sets this header, approximately 10% of requests fail (nginx returns 502 to client), and my nginx error log fills up with this:

2021/06/13 14:37:49 [error] 67240#87020: *71 connect() failed (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 127.0.0.1, server: server, request: "GET /16/64153/41313.png HTTP/1.1", upstream: "https://151.101.166.217:443/16/64153/41313.png", host: "localhost:480"  

Without the proxy_set_header, everything is fine. The requests in this case are all being made from chrome, so the User-Agent as seen by the OSM servers should be the same in both cases. nginx version is 1.19.10 (windows). What am I doing wrong?

Nginx location matching with regex year/month/day/*

Posted: 13 Jun 2021 12:03 AM PDT

I have some old url pattern to redirect to new location in nginx.

A typical clean url looks like example.com/2021/06/13/78676.html?..

Im roughly trying to match number of digit in each block like:

location ~ "^[0-9]{4}/[0-9]{2}/[0-9]{2}/([0-9]+).html" {     rewrite ^ /archive.php?q=$1;  }  

Where exactly Im going wrong please..

Amavis and Spamassassin error with '.pre' files (using iRedMail)

Posted: 12 Jun 2021 11:30 PM PDT

I installed iRedMail which would install amavis and spamassassin. When I test sending and receiving email, I have an error in the /var/log/mail.log, I see this line of error:

postfix/amavis/smtp[14582]: connect to 127.0.0.1[127.0.0.1]:10026: Connection refused

when I run this line: $sudo amavisd-new debug I see at the end of the output:

files are in the config directory.\nAt a minimum, v320.pre loads the Check plugin which is required. Jun 12 11:58:25.764 mail.example.com /usr/sbin/amavisd-new[20040]: sd_notify (no socket): STOPPING=1\nSTATUS=TROUBLE in pre_loop_hook: Timeout::_run: check: no loaded plugin implements 'check_main': cannot scan!\nCheck that the necessary '.pre' files are in the config directory.\nAt a minimum, v320.pre loads the Check plugin which is required. Jun 12 11:58:25.764 mail.example.com /usr/sbin/amavisd-new[20040]: (!)_DIE: Suicide () TROUBLE in pre_loop_hook: Timeout::_run: check: no loaded plugin implements 'check_main': cannot scan!\nCheck that the necessary '.pre' files are in the config directory.\nAt a minimum, v320.pre loads the Check plugin which is required. Suicide () TROUBLE in pre_loop_hook: Timeout::_run: check: no loaded plugin implements 'check_main': cannot scan! Check that the necessary '.pre' files are in the config directory. At a minimum, v320.pre loads the Check plugin which is required.

This is also the output of $spamassassin --lint -D:

Timeout::_run: check: no loaded plugin implements 'check_main': cannot scan! Check that the necessary '.pre' files are in the config directory. At a minimum, v320.pre loads the Check plugin which is required

I looked up in the /etc/mail/spamassassin directory and I can't see any '.pre' files in it. I also searched for v320.pre file using this: $sudo find / -iname v320.pre with no result.

If I disbale the amavis using: $sudo nano /etc/amavis/conf.d/50-user and changing these two lines:

@bypass_virus_checks_maps = (1); @bypass_spam_checks_maps = (1);

and then restarting the service: $sudo systemctl restart amavis and then processing the mail queue: $postqueue -f the mail server would work perfectly fine! So it is obvious that I should put some '.pre' files in the /etc/mail/spamassassin directory. I found out that there are some '.pre' files in this url: https://apache.googlesource.com/spamassassin/+/trunk/rules My question is: Is it safe to download these files and put them in my directory? Or in general where can I find '.pre' files or generate them?

Filesystem to protect the storage medium

Posted: 12 Jun 2021 07:15 PM PDT

I'm working on an embedded system which will act as a server, the problem is the environment where it will run is so aggressive and it will suffer abrupt power interruptions. So I'm planning to mount the root filesystem as fake-writable using OverlayFS. The idea comes from RaspberryPi, where the devs have a mechanism to enable/disable the mounting of rootfs as OverlayFS (as you can see it can be enabled by using raspi-config script)

My question is ... would this help to protect the physical device from corruption? Or even the filesystem itself? My idea is to extend the life of the physical device and I think I can do this avoiding write operations, but the system cannot be purely read-only because some programs need to see the FS as writable, that's why I'm thinking in OverlayFS.

What do you think? Do you have some other idea on how to tackle this problem? Thank you all.

PS: The system I have to use is Debian Buster.

Kubernetes network polices are not enforced unless the network-plugin daemon-sets are restarted. Why?

Posted: 13 Jun 2021 02:42 AM PDT

I have only one network policy in my cluster in prod namespace that allows only ingress rules. The network plugin is weave-net. No rules are configured for Egress so I am expecting egress traffic will be blocked. But until I restart the network daemon-set pods the rule has no effect. I know by best practices I should have default ingress and egress rules. But I want to understand the reason of this behavior. Is this step always required to restart the network-plugin pods?

1. Network Policy Definition

apiVersion: networking.k8s.io/v1  kind: NetworkPolicy  metadata:    name: test-network-policy    namespace: prod  spec:    ingress:    - {}    podSelector:      matchLabels:        run: prod-nginx    policyTypes:    - Ingress    - Egress  

2. Checking the netpol object

Name:         test-network-policy  Namespace:    prod  Created on:   2021-06-06 10:16:50 +0000 UTC  Labels:       <none>  Annotations:  <none>  Spec:    PodSelector:     run=prod-nginx    Allowing ingress traffic:      To Port: <any> (traffic allowed to all ports)      From: <any> (traffic not restricted by source)    Allowing egress traffic:      <none> (Selected pods are isolated for egress connectivity)    Policy Types: Ingress, Egress  

3. Testing egress traffic to nginx server (This is unexpected to my understanding)

Note: 10.39.0.5 is the IP of the nginx server running in 'test' namespace

Command : kubectl -n prod exec -it prod-nginx -- curl http://10.39.0.5 | grep successfully #egress  Response: <p>If you see this page, the nginx web server is successfully installed and  

4. Restarted the weave-net pods

5. Retesting egress connection to same nginx server (expected)

Note: 10.39.0.5 is the IP of the nginx server running in 'test' namespace

Command: kubectl -n prod exec -it prod-nginx -- curl http://10.39.0.5 | grep successfully #egress**  Response: No connection  

Cannot ping succesfully from PC to another PC

Posted: 13 Jun 2021 02:21 AM PDT

here is the image of the topologyhttps://mega.nz/file/xWpXmC5K#fchoMl5TjGyfIJTTpxMgiOqUdw5qERxtGAUj0XTg2HI Here is my file of my cisco packet tracer project where I configured routers, PCs Ip addresses, masks, exit gateways but I still can't ping from PC to the other PC where is the problem? When I tried it I succesfully pinged to the first router but when I tried to ping to the second router it was failed. here is the image of the topology

cisco sg550X support m-lag and

Posted: 13 Jun 2021 02:29 AM PDT

Please tell me

  1. Support MC-LAG (Multichassis Link Aggregation Groups) model cisco sg550x?
  2. can i use at the same time in stack for example: 1/1-2/1: M-LAG (LAG1) and 1/19-2/20,1/20-2/19: for stack ports in LAG2(or in stack ports LAG not needed and works automatically)

I want to buy sg550X, but dont know function support.

can look at Cisco C9300-24UX-E(M-LAG, StackWise-480)?

Strongswan to Cisco ASA with multiple right subnet

Posted: 12 Jun 2021 08:03 PM PDT

I've got an ikev2 tunnel up, initiated on the left from an ubuntu box with strongswan going to a cisco asa. Using ASA to ASA multiple networks work but I can not get it with strongswan.

#config setup      # strictcrlpolicy=yes      # uniqueids = no  config setup      charondebug="all"      uniqueids=yes      strictcrlpolicy=yes  # Add connections here.  conn host2      left=8.8.8.8 #Changed from real for this example      leftsubnet=172.27.1.0/20      right=8.8.4.4 # changed      rightsubnet=192.168.1.0/24,192.168.2.0/24      ike=aes256-sha512-modp2048s256      esp=aes256-sha512      keyingtries=0      ikelifetime=1h      lifetime=8h      dpddelay=30      dpdtimeout=120      dpdaction=restart      authby=secret      auto=add      keyexchange=ikev2      type=tunnel  

after connecting: ip xfm policy

src 192.168.1.0/24 dst 8.8.8.8/32      dir fwd priority 185664      tmpl src 4.4.4.4 dst 8.8.8.8          proto esp reqid 1 mode tunnel  src 192.168.1.0/24 dst 8.8.8.8/32      dir in priority 185664      tmpl src 4.4.4.4 dst 8.8.8.8          proto esp reqid 1 mode tunnel  src 8.8.8.8/32 dst 192.168.1.0/24      dir out priority 185664      tmpl src 8.8.8.8 dst 4.4.4.4          proto esp reqid 1 mode tunnel  src 0.0.0.0/0 dst 0.0.0.0/0      socket in priority 0  src 0.0.0.0/0 dst 0.0.0.0/0      socket out priority 0  src 0.0.0.0/0 dst 0.0.0.0/0      socket in priority 0  src 0.0.0.0/0 dst 0.0.0.0/0      socket out priority 0  src ::/0 dst ::/0      socket in priority 0  src ::/0 dst ::/0      socket out priority 0  src ::/0 dst ::/0      socket in priority 0  src ::/0 dst ::/0      socket out priority 0      $ipsec statusall  Status of IKE charon daemon (strongSwan 5.5.1, Linux 4.13.0-37-generic, x86_64):    uptime: 119 seconds, since Mar 23 09:08:33 2018    malloc: sbrk 2297856, mmap 532480, used 1224384, free 1073472    worker threads: 11 of 16 idle, 5/0/0/0 working, job queue: 0/0/0/0, scheduled: 2    loaded plugins: charon test-vectors unbound ldap pkcs11 aes rc2 sha2 sha1 md4 md5 mgf1 rdrand random nonce x509 revocation constraints acert pubkey pkcs1 pkcs7 pkcs8 pkcs12 pgp dnskey sshkey dnscert ipseckey pem gcrypt af-alg fips-prf gmp chapoly xcbc cmac hmac ctr ccm ntru bliss curl soup mysql sqlite attr kernel-netlink resolve socket-default farp stroke updown eap-identity eap-sim eap-sim-pcsc eap-aka eap-aka-3gpp2 eap-simaka-pseudonym eap-simaka-reauth eap-md5 eap-gtc eap-dynamic eap-radius eap-tls eap-ttls eap-peap eap-tnc xauth-eap xauth-pam xauth-noauth tnc-tnccs tnccs-20 tnccs-11 tnccs-dynamic dhcp whitelist lookip error-notify certexpire led radattr addrblock unity  Listening IP addresses:    8.8.8.8    172.27.1.3  Connections:         host2:  8.8.8.8...4.4.4.4  IKEv2         host2:   local:  [8.8.8.8] uses pre-shared key authentication         host2:   remote: [4.4.4.4] uses pre-shared key authentication         host2:   child:  8.8.8.8/32 === 192.168.1.0/24 192.168.2.0/24   TUNNEL  Security Associations (1 up, 0 connecting):         host2[1]: ESTABLISHED 115 seconds ago, 8.8.8.8[8.8.8.8]...4.4.4.4[4.4.4.4]     host2[1]: IKEv2 SPIs: 1f4ce050e3e482ac_i* 35d68fd4c114ef25_r, pre-shared key reauthentication in 2 hours     host2[1]: IKE proposal: AES_CBC_256/HMAC_SHA2_512_256/PRF_HMAC_SHA2_512/MODP_2048_256     host2{1}:  INSTALLED, TUNNEL, reqid 1, ESP SPIs: ca77e9b9_i a6993362_o     host2{1}:  AES_CBC_256/HMAC_SHA1_96, 0 bytes_i, 0 bytes_o, rekeying in 40 minutes     host2{1}:   8.8.8.8/32 === 192.168.2.0/24  

The ASA after successful connection:

asa-fw1# show crypto ipsec sa peer 8.8.4.4 | include ident    local ident (addr/mask/prot/port): (192.168.2.0/255.255.255.0/0/0)    remote ident (addr/mask/prot/port): (172.27.1.0/255.255.240.0/0/0)  

And a different tunnel between 2 ASAs:

      local ident (addr/mask/prot/port): (10.1.2.0/255.255.255.252/0/0)        remote ident (addr/mask/prot/port) : (192.168.10.2/255.255.255.255/0/0)        local ident (addr/mask/prot/port): (192.168.1.0/255.255.255.0/0/0)        remote ident (addr/mask/prot/port): (192.168.10.2/255.255.255.255/0/0)        local ident (addr/mask/prot/port): (192.168.2.0/255.255.255.0/0/0)        remote ident (addr/mask/prot/port): (192.168.10.2/255.255.255.255/0/0)        local ident (addr/mask/prot/port): (192.168.4.0/255.255.255.0/0/0)        remote ident (addr/mask/prot/port): (192.168.10.2/255.255.255.255/0/0)  

I have also tried putting additional right subnets on their own, such as follows:

conn host2      left=8.8.8.8 #Changed from real for this example      leftsubnet=172.27.1.0/20      right=4.4.4.4 # changed      rightsubnet=192.168.1.0/24      ike=aes256-sha512-modp2048s256      esp=aes256-sha512      keyingtries=0      ikelifetime=1h      lifetime=8h      dpddelay=30      dpdtimeout=120      dpdaction=restart      authby=secret      auto=add      keyexchange=ikev2      type=tunnel    conn host2-2      also=host2      rightsubnet=192.168.2.0/24  

after connection:

$ipsec statusall  Status of IKE charon daemon (strongSwan 5.5.1, Linux 4.13.0-37-generic, x86_64):    uptime: 52 seconds, since Mar 23 09:02:22 2018    malloc: sbrk 2293760, mmap 532480, used 1203936, free 1089824    worker threads: 11 of 16 idle, 5/0/0/0 working, job queue: 0/0/0/0,   scheduled: 2    loaded plugins: charon test-vectors unbound ldap pkcs11 aes rc2 sha2 sha1 md4 md5 mgf1 rdrand random nonce x509 revocation constraints acert pubkey pkcs1 pkcs7 pkcs8 pkcs12 pgp dnskey sshkey dnscert ipseckey pem gcrypt af-alg fips-prf gmp chapoly xcbc cmac hmac ctr ccm ntru bliss curl soup mysql sqlite attr kernel-netlink resolve socket-default farp stroke updown eap-identity eap-sim eap-sim-pcsc eap-aka eap-aka-3gpp2 eap-simaka-pseudonym eap-simaka-reauth eap-md5 eap-gtc eap-dynamic eap-radius eap-tls eap-ttls eap-peap eap-tnc xauth-eap xauth-pam xauth-noauth tnc-tnccs tnccs-20 tnccs-11 tnccs-dynamic dhcp whitelist lookip error-notify certexpire led radattr addrblock unity  Listening IP addresses:    8.8.8.8    172.27.1.3  Connections:         host2:  8.8.8.8...4.4.4.4  IKEv2         host2:   local:  [8.8.8.8] uses pre-shared key authentication         host2:   remote: [4.4.4.4] uses pre-shared key authentication         host2:   child:  8.8.8.8/32 === 192.168.1.0/24 TUNNEL        host2-2:   child:  8.8.8.8/32 === 192.168.2.0/24 TUNNEL  Security Associations (1 up, 0 connecting):         host2[1]: ESTABLISHED 50 seconds ago,   8.8.8.8[8.8.8.8]...4.4.4.4[4.4.4.4]     host2[1]: IKEv2 SPIs: 98cf15596219b433_i* 8177dc2c8f0605d8_r, pre-shared key reauthentication in 2 hours     host2[1]: IKE proposal: AES_CBC_256/HMAC_SHA2_512_256/PRF_HMAC_SHA2_512/MODP_2048_256    host2-2{1}:  INSTALLED, TUNNEL, reqid 1, ESP SPIs: ccc8bf25_i 1cec9278_o    host2-2{1}:  AES_CBC_256/HMAC_SHA1_96, 336 bytes_i (4 pkts, 40s ago), 336 bytes_o (4 pkts, 40s ago), rekeying in 41 minutes    host2-2{1}:   8.8.8.8/32 === 192.168.2.0/24  

and the ip xfrm policy:

src 192.168.2.0/24 dst 8.8.8.8/32      dir fwd priority 185664       tmpl src 4.4.4.4 dst 8.8.8.8          proto esp reqid 1 mode tunnel  src 192.168.2.0/24 dst 8.8.8.8/32      dir in priority 185664      tmpl src 4.4.4.4 dst 8.8.8.8          proto esp reqid 1 mode tunnel   src 8.8.8.8/32 dst 192.168.2.0/24      dir out priority 185664      tmpl src 8.8.8.8 dst 4.4.4.4          proto esp reqid 1 mode tunnel  src 0.0.0.0/0 dst 0.0.0.0/0      socket in priority 0  src 0.0.0.0/0 dst 0.0.0.0/0      socket out priority 0  src 0.0.0.0/0 dst 0.0.0.0/0      socket in priority 0  src 0.0.0.0/0 dst 0.0.0.0/0      socket out priority 0   src ::/0 dst ::/0      socket in priority 0  src ::/0 dst ::/0      socket out priority 0  src ::/0 dst ::/0      socket in priority 0   src ::/0 dst ::/0      socket out priority 0  

When using the above method, I can access 192.168.2.0 but no longer 192.168.1.0
Regardless, the xfrm policy is the same, and i can only access 192.168.2.0/24

I've tried generating traffic to the subnets without success. Can anyone help determine why I can only access ONE remote subnet on the right side?

Virtnetwork Cannot Start Virtualizor KVM

Posted: 13 Jun 2021 12:05 AM PDT

I have a problem with my virtnetwork. I have set the correct network interface on master setting Virtualizor but it said

/etc/sysconfig/: error fetching interface information: Device not found Error: No ip address found.

when I try to run

service virtnetwork start  

Does anyone can help me? Here is my network interface "ifcfg-ens9"

NAME="ens9"  DEVICE="ens9"  ONBOOT=yes  NETBOOT=yes  UUID="805c90c6-a8d2-49f1-8707-44696466a9fa"  IPV6INIT=yes  BOOTPROTO=none  TYPE=Ethernet  DNS1=127.0.0.1  DEFROUTE=yes  IPV4_FAILURE_FATAL=no  IPV6_AUTOCONF=yes  IPV6_DEFROUTE=yes  IPV6_FAILURE_FATAL=no  IPADDR=xxx.xxx.187.234  PREFIX=29  GATEWAY=xxx.xxx.187.233  IPV6_PEERDNS=yes  IPV6_PEERROUTES=yes  

Looking forward for the solution. I don't know whats wrong the setting above.

Windows 10 arp cache getting stuck after failed attempts when target machines are offline

Posted: 12 Jun 2021 09:06 PM PDT

After upgrading our development team to Windows 10 from 7, we are experiencing an issue with the ARP cache where a machine has the correct IP-MAC mapping cached, but the type is invalid due to failed connections during a power cycling of the target machine. On Windows 10, but not Windows 7, the target machine cannot be connected to until the ARP cache is cleared. I can have reproduce the issue as follows, where 10.10.10.10 is the correct IP address and 01:23:45:67:89:AB is the correct MAC address of the target machine in question:

  1. Start with the target machine powered off, and ping it through the entire test:

    ping -t 10.10.10.10  

Ping is replying with "Request timed out" and the ARP cache contains, as expected

10.10.10.10    00:00:00:00:00:00    invalid  
  1. Power on the target machine. Ping starts getting replies, and the ARP cache updates to

    10.10.10.10    01:23:45:67:89:AB    dynamic  

So far so good.

  1. Power off target machine. Ping starts reporting "Request timed out" and the ARP cache remains

    10.10.10.10    01:23:45:67:89:AB    dynamic  
  2. After about 40 seconds, the ping replies with "Destination host unreachable" for one request, then returns to reporting "Request timed out", and the ARP cache changes to

    10.10.10.10    01:23:45:67:89:AB    invalid  
  3. Power on the target machine, and ping (and any other connection) will not find it until you clear ARP cache, or at least delete the offending entry with the correct IP-MAC mapping with invalid type.

How do I prevent the ARP cache from getting into this state, given that the target machine in the development environment does tend to require power cycling during the development process? Manually manipulating the ARP cache is not sustainable, and nobody reported this issue before moving to Windows 10.

Windows 7 functions as one would expect, which is to say, what we desire: The ARP cache goes through the same stages as above. Ping starts by replying "Destination host unreachable" before the target is powered on, as opposed to Windows 10's "Request timed out" and returns to "Destination host unreachable" continually after it is powered off, as opposed to Windows 10 only reporting that once. When the machine is powered on, the connection is immediately established and the ARP cache returns to

10.10.10.10    01:23:45:67:89:AB    dynamic  

without any need to clear any entries first.

The developers' specific setup is a Windows workstation connected to several Beaglebone Blacks (small ARM based embedded boards running Linux) through a simple unmanaged 8 port gigabit switch. IP addresses are assigned by reserved DHCP, and addresses are picked up successfully each time the Beaglebones are powered on. When one Windows 10 machine has the invalid ARP entry that needs deleting, other machines without the Beaglebone in the ARP cache can successfully connect to the target machine.

How to extract specific emails from Exchange Online using PowerShell and move or sort them?

Posted: 13 Jun 2021 03:14 AM PDT

In Exchange Online (Office 365), I need to extract emails, from particular sending addresses, from a handful of user mailboxes, to another user mailbox folder.

I've been reading about the Export-Mailbox PowerShell cmdlet, which seems to be able to do what I want, but I am not sure if it is possible to use on Office 365.

logoff sessions except console

Posted: 13 Jun 2021 12:05 AM PDT

There is an application in a multi-user environment that can only be open in one session on a workstation. The users move around frequently from PC to PC, leaving the application open, and the workstation locked. Disabling user switching is determinant to productivity. I need the system to force logoff any user besides the Consul session. The session ID is a variable that cannot be predicted. This is what I got so far...

@ echo off    query session > c:\users\session.txt    powershell -Command "Get-Content c:\users\session.txt | Where-Object {$_ -notmatch 'console'} | Set-Content c:\users\session2.txt"    for /f "skip=2 tokens=2," %i in (c:\users\session2.txt) DO C:\Windows\System32\logoff.exe %i  

The goal is to put this into a .bat to run at user logon so whoever is ACTUALLY using the computer can use the applicaton. Dataloss of the inactive session is no concern. Ideally, rdp-tcp and services would stay active sessions as well.

Ubuntu 14.04 can only access outside networks if using DHCP, not static IPs

Posted: 12 Jun 2021 10:04 PM PDT

I am configuring some server on Ubuntu Server 14.04 (no GUI) and I am have the following configuration:

auto lo  iface lo inet loopback      ## Management network eth0  auto eth0  iface eth0 inet static  address 10.0.0.11  netmask 255.255.255.0  gateway 10.0.0.1  dns-nameservers 8.8.8.8 8.8.4.4  

Unfortunately, when using this configuration I can only access the LAN, any attempt to ping or access anything outside of our network fails.

If I use DHCP and just take what ever IP address the router gives me, I can access internal and external networks. For testing sake I've been attempting to use "ping google.com" to test outside connectivity.

One other note, in the router if I bind the IP to the MAC Address it appears to work just fine, but I don't want these rules to live in my router, I'd much rather they be configured on the server.

Raid 10, Logical device are missing

Posted: 12 Jun 2021 11:05 PM PDT

I have a problem with a RAID 10, I have 4 disks on raid. A disc has just been changed (0,3). But I can not rebuild the array. Logical device are setted as "Missing".

All commands return to me the following error

  /usr/StorMan# /usr/StorMan/arcconf setstate 1 device 0 3 rdyControllers found: 1  The device specified does not exist.    Command aborted.  
  /usr/StorMan# /usr/StorMan/arcconf getconfig 1   Controllers found: 1  ----------------------------------------------------------------------  Controller information  ----------------------------------------------------------------------     Controller Status                        : Optimal     Channel description                      : SAS/SATA     Controller Model                         : Adaptec 2405     Controller Serial Number                 : 2D2711FE327     Physical Slot                            : 16     Temperature                              : 68 C/ 154 F (Normal)     Installed memory                         : 128 MB     Copyback                                 : Disabled     Background consistency check             : Disabled     Automatic Failover                       : Enabled     Global task priority                     : High     Performance Mode                         : Default/Dynamic     Stayawake period                         : Disabled     Spinup limit internal drives             : 0     Spinup limit external drives             : 0     Defunct disk drive count                 : 0     Logical devices/Failed/Degraded          : 1/0/1     SSDs assigned to MaxIQ Cache pool        : 0     Maximum SSDs allowed in MaxIQ Cache pool : 8     MaxIQ Read Cache Pool Size               : 0.000 GB     MaxIQ cache fetch rate                   : 0     MaxIQ Cache Read, Write Balance Factor   : 3,1     NCQ status                               : Enabled     Statistics data collection mode          : Enabled     --------------------------------------------------------     Controller Version Information     --------------------------------------------------------     BIOS                                     : 5.2-0 (18937)     Firmware                                 : 5.2-0 (18937)     Driver                                   : 1.1-7 (28000)     Boot Flash                               : 5.2-0 (18937)    ----------------------------------------------------------------------  Logical device information  ----------------------------------------------------------------------  Logical device number 0     Logical device name                      :      RAID level                               : 10     Status of logical device                 : Degraded     Size                                     : 3809270 MB     Stripe-unit size                         : 256 KB     Read-cache mode                          : Enabled     MaxIQ preferred cache setting            : Enabled     MaxIQ cache setting                      : Disabled     Write-cache mode                         : Enabled (write-back)     Write-cache setting                      : Enabled (write-back)     Partitioned                              : Yes     Protected by Hot-Spare                   : No     Bootable                                 : Yes     Failed stripes                           : Yes     Power settings                           : Disabled     --------------------------------------------------------     Logical device segment information     --------------------------------------------------------     Group 0, Segment 0                       : Present (0,1)             W1F20KQ9     Group 0, Segment 1                       : Present (0,0)             Z34063KS     Group 1, Segment 0                       : Present (0,2)             W1E2PW1C     Group 1, Segment 1                       : Missing      ----------------------------------------------------------------------  Physical Device information  ----------------------------------------------------------------------        Device #0           Device is a Hard drive           State                              : Online           Supported                          : Yes           Transfer Speed                     : SATA 3.0 Gb/s           Reported Channel,Device(T:L)       : 0,0(0:0)           Reported Location                  : Connector 0, Device 0           Vendor                             :            Model                              : ST2000DM001-1CH1           Firmware                           : CC24           Serial number                      : Z34063KS           Size                               : 1907729 MB           Write Cache                        : Enabled (write-back)           FRU                                : None           S.M.A.R.T.                         : No           S.M.A.R.T. warnings                : 0           Power State                        : Full rpm           Supported Power States             : Full rpm,Powered off,Reduced rpm           SSD                                : No           MaxIQ Cache Capable                : No           MaxIQ Cache Assigned               : No           NCQ status                         : Enabled        Device #1           Device is a Hard drive           State                              : Online           Supported                          : Yes           Transfer Speed                     : SATA 3.0 Gb/s           Reported Channel,Device(T:L)       : 0,1(1:0)           Reported Location                  : Connector 0, Device 1           Vendor                             :            Model                              : ST2000DM001-1CH1           Firmware                           : CC24           Serial number                      : W1F20KQ9           Size                               : 1907729 MB           Write Cache                        : Enabled (write-back)           FRU                                : None           S.M.A.R.T.                         : No           S.M.A.R.T. warnings                : 0           Power State                        : Full rpm           Supported Power States             : Full rpm,Powered off,Reduced rpm           SSD                                : No           MaxIQ Cache Capable                : No           MaxIQ Cache Assigned               : No           NCQ status                         : Enabled        Device #2           Device is a Hard drive           State                              : Online           Supported                          : Yes           Transfer Speed                     : SATA 3.0 Gb/s           Reported Channel,Device(T:L)       : 0,2(2:0)           Reported Location                  : Connector 0, Device 2           Vendor                             :            Model                              : ST2000DM001-1CH1           Firmware                           : CC24           Serial number                      : W1E2PW1C           Size                               : 1907729 MB           Write Cache                        : Enabled (write-back)           FRU                                : None           S.M.A.R.T.                         : No           S.M.A.R.T. warnings                : 0           Power State                        : Full rpm           Supported Power States             : Full rpm,Powered off,Reduced rpm           SSD                                : No           MaxIQ Cache Capable                : No           MaxIQ Cache Assigned               : No           NCQ status                         : Enabled  

How can I start the rebuilding of the array?

nginx sending incomplete response

Posted: 12 Jun 2021 11:05 PM PDT

Without restart or modification of config, nginx is sending incomplete responses sometimes. Today, I could reproduce well, but still don't know what's wrong or how to fix.

I put a 5MB file to the site's location/alias path that nginx is configured to use. There is no php5-fpm, modules etc. only nginx for serving static files.

When testing, there is no other user accessing the server, no http access except my test requests.

The download fails and Google Chrome shows in traffic log, that there were 2 requests, although I put the http url for the download only ONCE and there was no redirect or other 2nd request initiated by myself.

Same issue at server's access.log, too:

TEST1

[14/May/2014:14:06:53 +0200] "GET /dev/test_test.m4v HTTP/1.1" 206 1 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"

[14/May/2014:14:06:53 +0200] "GET /dev/test_test.m4v HTTP/1.1" 200 130680 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.10

[14/May/2014:14:07:15 +0200] "GET /dev/test_test.m4v HTTP/1.1" 206 1 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"

[14/May/2014:14:07:15 +0200] "GET /dev/test_test.m4v HTTP/1.1" 200 114684 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.10

You can see that theere is always one request with response size=1 and another one with mixed size, but >1. However, the result in the browser is always the same. => broken response, failed download.

For making sure, it's not related to http status/response 206, I add max_ranges 0; to the config and retry -> test2.

TEST2

[14/May/2014:14:11:36 +0200] "GET /dev/test_test.m4v HTTP/1.1" 200 152460 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"

[14/May/2014:14:11:38 +0200] "GET /dev/test_test.m4v HTTP/1.1" 200 142296 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36"

Same result in the browser. Always failed download/request and the size in access.log is always different, like random chunk or response size.

server status: iowait, RAM, cpu are almost idle. There is no high load or limitation.

Is this a known issue or bug or do You know how to fix this?

On a system with 64GB mem the Linux Buffer run full while copying with dd to dev null and io stops till manual drop_caches

Posted: 13 Jun 2021 01:08 AM PDT

I am running a server with linux software raid 10. It is a dual CPU system with 64GB Ram. 2x16GB dimms related to each of the CPUs. I want to use dd to backup kvm virtual machines and run into a serious io problem. First I thought is related to the raid but it's a problem of the linux memory management. Here is an example:

  1. Memory is fine: http://i.stack.imgur.com/NbL60.jpg
  2. I start dd: http://i.stack.imgur.com/kEPN2.jpg
  3. You see also nmon shows the disk access: http://i.stack.imgur.com/Njcf5.jpg
  4. After a while the "buffers" are big and the copy progress stops http://i.stack.imgur.com/HCefI.jpg
  5. Here is meminfo: http://i.stack.imgur.com/KR0CE.jpg
  6. Here the dd output: http://i.stack.imgur.com/BHjnR.jpg
  7. I can manually resolve temporary the problem and force dropping the cache: "sync; echo 3 > /proc/sys/vm/drop_caches"
  8. The call needs few seconds and instantly after that the dd speed reach normal level. Sure I can a cronjob every min or such things but thats not a real solution. http://i.stack.imgur.com/zIDRz.jpg http://i.stack.imgur.com/fO8NV.jpg

Does anybody have a solution or a configuration hint? Here is also my sysctl but all values are centos defaults: http://i.stack.imgur.com/ZQBNG.jpg

Edit1

I make a other test and make a dd to disk instead /dev/null. This time also in one command without pv. So its only one process. dd if=/dev/vg_main_vms/AppServer_System of=AppServer_System bs=4M

  1. It start with reading without writing (target is not on the same disks) http://i.stack.imgur.com/jJg5x.jpg
  2. After a while the writing starts and the reading slow down http://i.stack.imgur.com/lcgW6.jpg
  3. After that a writing only time comes: http://i.stack.imgur.com/5FhG4.jpg
  4. Now starts the main problem. The copy process slow down to below 1mbs und nothing happend: http://i.stack.imgur.com/YfCXc.jpg
  5. The dd process now needs 100% cpu time (1 core) http://i.stack.imgur.com/IZn1N.jpg
  6. And again I can manually resolve temporary the problem and force dropping the cache: sync; echo 3 > /proc/sys/vm/drop_caches. After that the same game starts again...

Edit2

For the local dd I can workaround with the parameter iflag=direct and oflag=direct. But this is no universal solution because there is also other file access like copy files to the local samba shares from a vm and there I cant use such parameters. There must be a tweak of the system file cache rules, because it cant be normal that you cant copy large files without such problems.

Connection refused HTTPS on Apache

Posted: 12 Jun 2021 07:39 PM PDT

I'm currently trying out HTTPS on one of my sites, and I got a trial certificate from a trusted CA. I've gone through the following checklist:

  • Copied all the cert files according to the CA's instructions
  • Enabled mod_ssl on apache with a2enmod ssl
  • Checked PHP has OpenSSL enabled
  • Made a new virtual host in Apache listening to 443
  • Inputted the SSL directives:

    SSLEngine on

    SSLCertificateKeyFile /etc/ssl/ssl.key/server.key

    SSLCertificateFile /etc/ssl/ssl.crt/api_my_site_com.crt

    SSLCertificateChainFile /etc/ssl/ssl.crt/apimysite.com-bundle

  • Checked only apache was listening to port 443 with lsof

  • Check locally and from my own PC with telnet if I could connect to 443 (to the IP of the server, not domain; trying to connect to my-site.com:443 gave me connect failed)

However, when I try to browse to https://my-site.com (obviouslly not the real domain), I get a 'Connection Refused' error. This is what Apache logs:

[Sat Jul 20 22:50:34 2013] [info] Loading certificate & private key of SSL-aware server  [Sat Jul 20 22:50:34 2013] [info] Configuring server for SSL protocol  [Sat Jul 20 22:50:34 2013] [info] RSA server certificate enables Server Gated Cryptography (SGC)  [Sat Jul 20 22:50:34 2013] [info] [client ::1] Connection to child 0 established (server my-site.com:443)  [Sat Jul 20 22:50:34 2013] [info] Seeding PRNG with 656 bytes of entropy  [Sat Jul 20 22:50:34 2013] [info] [client ::1] SSL library error 1 in handshake (server my-site:443)  [Sat Jul 20 22:50:34 2013] [info] SSL Library Error: 336027900 error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol speaking not SSL to HTTPS port!?  [Sat Jul 20 22:50:34 2013] [info] [client ::1] Connection closed to child 0 with abortive shutdown (server my-site:443)  

Any ideas why this is happening?

Configuration files:

ports.conf

Listen 443  NameVirtualHost *:80  Listen 80  

virtualhost config

<VirtualHost *:443>  DocumentRoot /var/www/mysite/sandbox/api  ServerName api.my-site.com  RewriteEngine on  RewriteRule ^/v1/* /v1/api.php [L]  RewriteRule ^/* /index.php [L]  <Directory "/var/www/mysite/sandbox/api">  allow from all  </Directory>  Options -MultiViews  ErrorDocument 404 /404.html  AddDefaultCharset utf-8  <IfModule mod_mime>   AddCharset utf-8 .atom .css .js .json .rss .vtt .webapp .xml  </IfModule>   <IfModule mod_rewrite>   Options +FollowSymlinks  RewriteCond %{HTTPS} !=on  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]  RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]  </IfModule>   <IfModule mod_autoindex>   Options -Indexes  </IfModule>   <IfModule mod_rewrite>   RewriteCond %{SCRIPT_FILENAME} -d [OR]  RewriteCond %{SCRIPT_FILENAME} -f  RewriteRule "(^|/)\." - [F]  </IfModule>   <FilesMatch "(^#.*#|\.(bak|config|dist|fla|inc|ini|log|psd|sh|sql|sw[op])|~)$">  Order allow,deny  Deny from all  Satisfy All  </FilesMatch>  FileETag None  SSLEngine on  SSLCertificateKeyFile /etc/ssl/ssl.key/server.key  SSLCertificateFile /etc/ssl/ssl.crt/api_my_site_com.crt  SSLCertificateChainFile /etc/ssl/ssl.crt/apimysite.com-bundle  ErrorLog /var/www/mysite/api.log  LogLevel info  </VirtualHost>  

installed post-installation script returned error exit status 1

Posted: 13 Jun 2021 02:08 AM PDT

I found many complains with same error but for different packages. However, i couldn't understand essence of this error and how to fix it. Pls. help if you have any clue about it.

It appeared first when i tried to install rsyslog.

# dpkg --configure -a  Setting up rsyslog (4.6.4-2) ...  insserv: warning: script 'K02ossec' missing LSB tags and overrides  insserv: warning: script 'K02drwebd' missing LSB tags and overrides  insserv: warning: script 'drwebd' missing LSB tags and overrides  insserv: script ctasd_initd: service Parallels already provided!  insserv: script ctasd_initd: service Premium already provided!  insserv: script ctasd_initd: service Outgoing already provided!  insserv: script ctasd_initd: service Antispam already provided!  insserv: warning: script 'ctmilter_initd' missing LSB tags and overrides  insserv: warning: script 'ossec' missing LSB tags and overrides  insserv: There is a loop between service munin-node and ctmilter_initd if stopped  insserv:  loop involving service ctmilter_initd at depth 2  insserv:  loop involving service munin-node at depth 1  insserv: Stopping ctmilter_initd depends on munin-node and therefore on system facility `$all' which can not be true!  insserv: exiting now without changing boot order!  update-rc.d: error: insserv rejected the script header  dpkg: error processing rsyslog (--configure):   subprocess installed post-installation script returned error exit status 1  Errors were encountered while processing:   rsyslog  

Running su with -c gives unrecognized command error

Posted: 12 Jun 2021 10:04 PM PDT

I am trying to run a command as another user in Linux. Here is what I run:

su user1 -c '/bin/mkdir /tmp/zz'  

However, this gives me this error:

fatal: unrecognized command '/bin/mkdir /tmp/zz'  

What would cause a PHP app to segfault intermittently under load?

Posted: 13 Jun 2021 03:04 AM PDT

Posted this on stackoverflow but it seems more relevant over here... I'm doing some load testing (using jMeter) on a PHP app (it's a symfony app, if that matters). I've tested it under both apache/mod_php and nginx/php_fpm setups, and with multiple versions of php, apache, nginx, and linux and the logs are full of errors like these. I'm struggling to work out why these segfaults are occurring:

[Wed Mar 13 00:54:47 2013] [notice] child pid 18830 exit signal Bus error (7), possible coredump in /tmp/apache2-gdb-dump

[Wed Mar 13 00:54:55 2013] [notice] child pid 19016 exit signal Bus error (7), possible coredump in /tmp/apache2-gdb-dump

[Wed Mar 13 00:54:56 2013] [notice] child pid 19002 exit signal Bus error (7), possible coredump in /tmp/apache2-gdb-dump

[Wed Mar 13 00:54:58 2013] [notice] child pid 19041 exit signal Bus error (7), possible coredump in /tmp/apache2-gdb-dump

When I generate a backtrace from the core dumps I get

[New LWP 588] [Thread debugging using libthread_db enabled] Using host libthread_db library

"/lib/i386-linux-gnu/tls/i686/nosegneg/libthread_db.so.1". Core was generated by `/usr/sbin/apache2 -k start'. Program terminated with signal 7, Bus error.

0 lex_scan (zendlval=0xb6d2ce38) at /build/buildd/php5-5.4.6/Zend/zend_language_scanner.c:2260

Thread 1 (Thread 0xb7485700 (LWP 588)):

0 lex_scan (zendlval=0xb6d2ce38) at /build/buildd/php5-5.4.6/Zend/zend_language_scanner.c:2260

So perhaps it's something to do with parsing? I know little about php internals however, so am uncertain. What might be causing this?

Publishing a web app listening on two different ports with TMG

Posted: 12 Jun 2021 08:03 PM PDT

We have an internal web app built on some custom Java stuff. The app listens on port 8080, but also uses IIS on port 80 to get user authentication.

Opening the site in a browser produces HTTP GETs to both ports/urls.

Is a case like this possible to publish with TMG?

iptables forwarding a port between 2 networks with 2 ethernet cards

Posted: 13 Jun 2021 03:04 AM PDT

I have a server handling several services. For the purposes of this questions, suppose one of them is mail. If mail goes down, I want to forward it to another host. My network looks like this:

-- Network 1 --    Box 1  eth1: 192.168.1.5  eth0: 10.10.10.3    -- Network 2 --    Box 2  eth0: 10.10.10.5  

So... Incoming requests are coming to the 192.168.1.5 address on eth1 on box 1. Instead of stopping there, I want to forward them over eth0 to box 2 and let that handle it.

I've tried the following iptables rules:

iptables -t nat -A PREROUTING -p tcp -m tcp -d 192.168.1.5 --dport 25 -j DNAT --to-destination 10.10.10.5:25  iptables -A FORWARD -m state -p tcp -d 10.10.10.5 --dport 25 --state NEW,ESTABLISHED,RELATED -j ACCEPT  iptables -t nat -A POSTROUTING -p tcp -m tcp -s 10.10.10.5 --sport 25 -j SNAT --to-source 192.168.1.5  

... To no avail. Using tcpdump, I can see the request come in on the 2nd box, but nothing happens on the requesting computer.

Please help. Thanks!

SSH connection gives no prompt, unresponsive

Posted: 13 Jun 2021 02:08 AM PDT

I'm ssh'ing from my OSX laptop to an OSX server. It worked a couple of days ago. Now, when I try and connect, no text is output. My session (with -v option) looks like:

 ~ $ ssh myserver  

...

debug1: Next authentication method: keyboard-interactive  Password:  debug1: Authentication succeeded (keyboard-interactive).  debug1: channel 0: new [client-session]  debug1: Requesting no-more-sessions@openssh.com  debug1: Entering interactive session.  _  

Where _ is the cursor.

So it looks to me like I've connected, but something is wrong with the shell - it hasn't started up, or something. Could I have broken my .bash_profile? Are there other common causes of this behaviour?

I don't have root access on this box, and I'd like to be able to give the sysadmins specific things to check for if possible.

EDIT: It's actually an OSX server, not RHEL. (Confusion as it hosts a RHEL VM which I also often connect to.)

I have been sent some server logs:

...  Jan 19 11:30:09 myserver sshd[2545]: in pam_sm_authenticate(): Kerberos 5 error  Jan 19 11:30:09 myserver sshd[2545]: in pam_sm_authenticate(): Kerberos 5 refuses you  Jan 19 11:30:09 myserver sshd[2541]: Accepted keyboard-interactive/pam for stevebennett from xx.xx.xx.xx port 65411 ssh2  Jan 19 11:30:09 myserver com.apple.SecurityServer[39]: Session 0x2114691 created  Jan 19 11:30:09 myserver com.apple.SecurityServer[39]: Session 0x2114691 attributes 0x20  

Is the Kerberos 5 error relevant?

asterisk system function not working in dialplan

Posted: 13 Jun 2021 01:08 AM PDT

After a call hangs up, I've setup several lines in my dialplan to execute system commands. For instance, I have this in my dialplan:

exten => h,1,System(echo yo)  exten => h,n,System(echo yo)  exten => h,n,System(echo yo)  

In my logs, all I'm seeing is one System command running:

[Aug 25 16:04:54] DEBUG[24437] pbx.c: Launching 'System'  [Aug 25 16:04:54] VERBOSE[24437] pbx.c:     -- Executing [h@fax-tx:4]     System("SIP/flowroute-00000014", "echo yo") in new stack  [Aug 25 16:04:54] DEBUG[778] devicestate.c: No provider found, checking channel drivers for SIP - flowroute  

The rest are not running and the dialplan seems to just stop. I don't see any additional errors occuring. WTF is going on?

I'm running Asterisk 1.8.5.

IIS Admin Service stuck at "Starting" status

Posted: 12 Jun 2021 09:06 PM PDT

I'm having some trouble restarting IIS, and I took a look and see that the IIS Admin Service is in the "Starting" status. I'm not able to Start/Stop it manually. All of the context menu options for this are disabled. Any ideas?

My system settings are:

IIS7 on Windows 7 I have the following ISAPI/CGI Restrictions: ASP.NET v2.0.50727 x32/x64 ASP.NET v4.0.30319 x32/x64

OSCHINA 社区最新新闻

Posted: 13 Jun 2021 01:25 AM PDT

OSCHINA 社区最新新闻


谷歌停止 Chrome 简化 URL 的实验

Posted: 12 Jun 2021 06:30 PM PDT

Chrome 终于不再折腾 URL 了。 Chromium 近期合并的一个 commit 显示,其开发团队已删除简化 URL 的功能代码。理由是此项实验性功能对相关安全指标没有推动效果,所以不打算正式上线。 此处提到的安全指标来自谷歌过去一年运行的一系列实验室测试,详情点此查看。 Delete simplified domain experiment This experiment ...

每日一博 | 教你认识 Vuex 状态机

Posted: 12 Jun 2021 05:32 PM PDT

简单来说,Vuex 就是实现组件全局状态(数据)管理的一种机制,可以方便的实现组件之间数据的共享。

Linux 上的 RISC-V 将支持 Transparent Hugepages

Posted: 12 Jun 2021 05:19 PM PDT

根据最新的提交显示,Linux 内核的 RISC-V 即将获得 Transparent Hugepages(THP)支持。 Linux 内核的 RISC-V 继最近添加原地执行 XIP、对 KProbes 和其他功能的支持以及硬件特定工作如 SiFive FU740 SoC 支持后,由华为工程师提供的 Transparent Hugepages 支持现在也已准备就绪。 Transparent Hugepages 是 Linux 的内...

D3.js 7.0 正式发布,数据可视化 JavaScript 库

Posted: 12 Jun 2021 05:15 PM PDT

D3(或者叫 D3.js)7.0 已正式发布。 从该版本起,D3 以 ESM 形式提供,因此会要求使用环境安装了 Node.js 12 或更高版本。关于此变化,详情查看 Sindre Sorhus's FAQ。 此外,d3.bin 现在会忽略空值,d3.ascending 和 d3.descending 也不再考虑空值的可比性(null comparable)。 Ordinal scales 现在使用 InternMap 作为...

Gitee 推荐 | 跨平台 MQTT 5.0 客户端工具 MQTT X

Posted: 12 Jun 2021 04:47 PM PDT

MQTT X 是 EMQ 开源的一款跨平台 MQTT 5.0 客户端工具,它支持 macOS, Linux, Windows,并且支持 MQTT 消息格式转换。MQTT X 的用户界面借助聊天软件的形式简化了页面的操作逻辑,用户可以快速创建连接保存并同时建立多个连接客户端,方便用户快速测试 MQTT/TCP、MQTT/TLS、MQTT/WebSocket 的 连接/发布/订阅 功能及其他...

yadcc —— C++ 分布式编译系统

Posted: 12 Jun 2021 04:36 PM PDT

yadcc(Yet Another Distributed C++ Compiler)是一套腾讯广告自研的分布式编译系统,用于支撑腾讯广告的日常开发及流水线。相对于已有的同类解决方案,其针对实际的工业生产环境做了性能、可靠性、易用性等方面优化。

Nvidia 计划停止支持 Windows7 和 Windows 8/8.1

Posted: 12 Jun 2021 04:32 PM PDT

根据 Nvidia 的最新公告显示,其已经计划结束对 Windows7 和 Windows 8/8.1的支持。 Windows 7 已经推出超过 11 年了,在其 12 周年纪念日之前,显卡生产商 Nvidia 将停止支持这个老化的操作系统。一份针对 Windows 7 和 Windows 8/8.1的支持计划显示,从 2021 年 10 月开始,Game Ready Driver 的升级,包括性能增强、新...

Recent Questions - Unix & Linux Stack Exchange

Posted: 13 Jun 2021 01:03 AM PDT

Recent Questions - Unix & Linux Stack Exchange


Printing content of file from nth line to nth line [Shell Scripting] [duplicate]

Posted: 13 Jun 2021 12:09 AM PDT

**

> Hey buddies I have a file having names of 200 countries.I want to print names of countries from 50th line to 80th line .How can i do so in bash??

**

Set Windows like default entry with efibootmgr, but showing menu

Posted: 12 Jun 2021 11:40 PM PDT

I have this menu starting my laptop. As you can see, I have multiple entries for CentOS 8. But, I want to set like default, my Windows Boot Manager (on /dev/nvme01p1) entry…

I was thinking in efibootmgr.

Reading this article https://www.lifewire.com/change-the-efi-boot-order-efibootmgr-4028027

Is it possible to keep the menu entries, changing to Windows with efibootmgr?

enter image description here

Automatic reboot after suspend

Posted: 12 Jun 2021 11:39 PM PDT

I'm a new user to Linux Mint and I've had issues with the graphic driver. I updated the kernel to 5.8 which solves the problem of adjusting the brightness or being able to wake up from suspend. But now my new problem is that after waking up from suspend, the computer automatically restarts just in a few minutes. Can anyone suggest what I should do? Thanks!

The following is what I got from

inxi -Fxxxrz          System:    Kernel: 5.8.0-55-generic x86_64 bits: 64 compiler: N/A     Desktop: Cinnamon 4.8.6 wm: muffin 4.8.1 dm: LightDM 1.30.0     Distro: Linux Mint 20.1 Ulyssa base: Ubuntu 20.04 focal   Machine:    Type: Laptop System: LENOVO product: 20TA005GIV v: ThinkPad E14 Gen 2     serial: <filter> Chassis: type: 10 serial: <filter>     Mobo: LENOVO model: 20TA005GIV serial: <filter> UEFI: LENOVO     v: R1EET34W(1.34 ) date: 02/25/2021   Battery:    ID-1: BAT0 charge: 36.1 Wh condition: 45.0/45.0 Wh (100%) volts: 12.2/11.3     model: Celxpert 5B10X026 type: Li-poly serial: <filter>     status: Discharging cycles: 2   CPU:    Topology: Quad Core model: 11th Gen Intel Core i7-1165G7 bits: 64     type: MT MCP arch: Tiger Lake rev: 1 L2 cache: 12.0 MiB     flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx     bogomips: 44851     Speed: 1200 MHz min/max: 400/4700 MHz Core speeds (MHz): 1: 1200 2: 1200     3: 1200 4: 1200 5: 1200 6: 1200 7: 1199 8: 1195   Graphics:    Device-1: Intel vendor: Lenovo driver: i915 v: kernel bus ID: 00:02.0     chip ID: 8086:9a49     Display: x11 server: X.Org 1.20.9 driver: modesetting unloaded: fbdev,vesa     resolution: 1920x1080~60Hz     OpenGL: renderer: Mesa Intel Xe Graphics (TGL GT2) v: 4.6 Mesa 20.2.6     direct render: Yes   Audio:    Device-1: Intel vendor: Lenovo driver: snd_hda_intel v: kernel     bus ID: 00:1f.3 chip ID: 8086:a0c8     Sound Server: ALSA v: k5.8.0-55-generic   Network:    Device-1: Intel driver: iwlwifi v: kernel port: 4000 bus ID: 00:14.3     chip ID: 8086:a0f0     IF: wlp0s20f3 state: up mac: <filter>     Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet     vendor: Lenovo driver: r8169 v: kernel port: 3000 bus ID: 04:00.0     chip ID: 10ec:8168     IF: enp4s0 state: down mac: <filter>   Drives:    Local Storage: total: 476.94 GiB used: 66.47 GiB (13.9%)     ID-1: /dev/nvme0n1 vendor: Samsung model: MZALQ512HALU-000L1     size: 476.94 GiB speed: 31.6 Gb/s lanes: 4 serial: <filter> rev: BL1QFXV7     scheme: GPT   Partition:    ID-1: / size: 467.96 GiB used: 66.46 GiB (14.2%) fs: ext4     dev: /dev/nvme0n1p2   Sensors:    System Temperatures: cpu: 45.0 C mobo: 42.0 C     Fan Speeds (RPM): cpu: 0   Repos:    No active apt repos in: /etc/apt/sources.list     Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list     1: deb http://packages.linuxmint.com ulyssa main upstream import backport #id:linuxmint_main    2: deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse    3: deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse    4: deb http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse    5: deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse    6: deb http://archive.canonical.com/ubuntu/ focal partner  Info:    Processes: 248 Uptime: 5m Memory: 15.35 GiB used: 1.36 GiB (8.9%)     Init: systemd v: 245 runlevel: 5 Compilers: gcc: 9.3.0 alt: 9 Shell: bash     v: 5.0.17 running in: gnome-terminal inxi: 3.0.38   

The weird order when concating variables and string with '_' [duplicate]

Posted: 12 Jun 2021 10:38 PM PDT

I tried to concat the variable and string.

while read subject;  do  pathproc=/projects/guo_lab/cbis/users/yang/DICA_result  echo  ${pathproc}/${subject}"_"weight  done < /projects/guo_lab/cbis/users/yang/Fulllist_tractography.txt  

The result shows that

_weightrojects/guo_lab/cbis/users/yang/DICA_result/609812419171

Why is this happening, the correct form in my mind is /projects/users/yang/DICA_result/609812419171_weight. How can I get this?

By the way, if I delete the _weight, it just give /projects/users/yang/DICA_result/609812419171.

Thanks so much.

Add more partition to NVMe SoftRAID

Posted: 12 Jun 2021 10:09 PM PDT

I have SoftRAID setup on CentOS on my NVMe Drive (2x1TB) . Issue is I only provisioned 80GB and I now want to provision more for additional space. Can someone please help me do this. Here is output of lsblk https://pastebin.com/6jjvqD9d

Server hang while rebooting Getting below error, what is the issue the environment is rhel 5.4?

Posted: 12 Jun 2021 09:56 PM PDT

Server hang while rebooting Getting below error, what is the issue? Environment is RHEL 5.4

umount2: device or resource busy  umount: /usr : device is busy  umount2: device or resource busy  umount: /tmp : device is busy  umount2: device or resource busy  umount: /tmp : device is busy                                [FAILED]  nfs: server xx.xxx.xx.xxx not responding, still trying  nfs: server xx.xxx.xx.xxx not responding, still trying  nfs: server xx.xxx.xx.xxx not responding, still trying  nfs: server xx.xxx.xx.xxx not responding, still trying  nfs: server xx.xxx.xx.xxx not responding, still trying  nfs: server xx.xxx.xx.xxx not responding, still trying  nfs: server xx.xxx.xx.xxx not responding, still trying  

How to enable broadcasting for loopback

Posted: 12 Jun 2021 09:19 PM PDT

I'm on a linux environment and I'm trying to send a broadcast to my loopback. I wanted to enable broadcast for my loopback interface but I can't see to get it to show on ifconfig.

For example:

eth0      Link encap:Ethernet  HWaddr 00:01:c0:1c:2f:c4            inet addr:192.168.65.100  Bcast:192.168.65.255  Mask:255.255.255.0            UP BROADCAST MULTICAST  MTU:1500  Metric:1            RX packets:71533771 errors:0 dropped:0 overruns:0 frame:0            TX packets:71186348 errors:0 dropped:0 overruns:0 carrier:0            collisions:0 txqueuelen:1000            RX bytes:53742272 (51.2 MiB)  TX bytes:1860694332 (1.7 GiB)            Interrupt:234    lo        Link encap:Local Loopback            inet addr:127.0.0.1  Mask:255.0.0.0            UP LOOPBACK RUNNING  MTU:65536  Metric:1            RX packets:949519134 errors:0 dropped:0 overruns:0 frame:0            TX packets:949519134 errors:0 dropped:0 overruns:0 carrier:0            collisions:0 txqueuelen:0            RX bytes:164243352358 (152.9 GiB)  TX bytes:164243352358 (152.9 GiB)  

eth0 displays UP BROADCAST MULTICAST where as lo displays UP LOOPBACK RUNNING how does one enable broadcast on the loopback interface. I imagine broadcast on loopback would be using address 127.255.255.255?

Extracting *full* linux headers from source

Posted: 12 Jun 2021 07:15 PM PDT

Linux kernel sources are full of quirks to support multiple architectures and scenarios. This means I cannot simply copy all *.h files and use a gcc -S -save-temps trick or anything similar to get preprocessed headers.

I was wondering how can I export full full kernel-space headers from the source tree properly?

  • make headers_install ARCH=i386 INSTALL_HDR_PATH=... builds only user-space/API headers. This will skip for example nameidata struct
  • make deb-pkg builds the kernel binary AND kernel headers (I cannot build the binary for unrelated reasons)

OpenSource Homework script

Posted: 12 Jun 2021 08:27 PM PDT

I need to make a startup script for a user with commands in the Terminal console. The orders are:

  1. Get started with the script and no information or welcome the performer.
  2. Make sure you make a choice in it (eg by means of an if statement)
  3. Make sure the selected web server is installed.
  4. Finally, install all the components you need with your web server:
  5. PHP (required for nextcloud)
  6. Mysql/Mariadb

The installation:

  1. Use the script to install your chosen web server on your linux machine.
  2. Install the necessary modules as well

Unable to validate LUKS encryption

Posted: 12 Jun 2021 11:37 PM PDT

Hello I have a question about LUKS encryption. I have used LUKS to encrypt a disk on my server but when I create a file and add content to it, and cat the file, the content is still in plain text. Even when I create a backup of the file, and put it on the non-encrypted hard drive, the data is in plain text. I'm not sure how I can say that encryption is happening. Am I missing something? Is this how LUKS is supposed to work?

/dev/sdb: UUID="d7f667ed-50a4-4324-8708-6720d390bfd2" TYPE="crypto_LUKS"  [root@host1 ~]# cat /opt/my_encrypted_backup/test12  This is a test  [root@host1 ~]# clear  [root@host1 ~]# lsblk  NAME            MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT  sda               8:0    0    8G  0 disk  ├─sda1            8:1    0    1G  0 part  /boot  └─sda2            8:2    0    7G  0 part    ├─centos-root 253:0    0  6.2G  0 lvm   /    └─centos-swap 253:1    0  820M  0 lvm   [SWAP]  sdb               8:16   0    1G  0 disk  └─mybackup      253:2    0 1022M  0 crypt /opt/my_encrypted_backup  sr0              11:0    1 1024M  0 rom  [root@host1 ~]#  [root@host1 ~]#  [root@host1 ~]# blkid /dev/sdb  /dev/sdb: UUID="d7f667ed-50a4-4324-8708-6720d390bfd2" TYPE="crypto_LUKS"  [root@host1 ~]#  [root@host1 ~]#  [root@host1 ~]# cat /opt/my_encrypted_backup/test12  This is a test  [root@host1 ~]# cp /opt/my_encrypted_backup/test12 /  [root@host1 ~]# cat /test12  This is a test  [root@host1 ~]#  

Ideal ratio of tcp_max_syn_backlog and net.core.somaxconn

Posted: 12 Jun 2021 05:30 PM PDT

Googling about TCP: Possible SYN flooding on port bring a lot of results, some places says to just increase somaxconn, other syn backlog

But there is little information in how those values should be calculated, and what would the ideal ratio between them.

I believe people would benefit from a answer teaching more than just tell people to use an arbitrary value.

Some places says to use 65536 on somaxconn others says only 2048, and so on...

Will this auto-respawn bash script work?

Posted: 12 Jun 2021 04:55 PM PDT

I've been having issues with my eth miner, nsfminer, crashing on me when I leave it on at night. Sometimes this occurs after 2-8 hours of mining, while sometimes it doesn't occur at all. It usually exits with a message that I can't recall off the top of my head. I did some searching on my own and threw together a bash script using an until loop and was wondering if this should work in theory. Usually I would just test it on my own because that's the best way to learn, but considering I may have to wait 8 hours for a crash or it may not even crash at all for several days, I'd like to know if this script will work before I potentially lose $5-10 of profit. It seems to work just fine when I run it, but I don't know if the autorespawn works as I've yet to leave it running for long enough to see if it crashes.

until echo PASSWORD | sudo -S ./nsfminer --cu-block 256 --cu-streams 4 -P stratum+tcp://USERNAME:PWDARGS@domain:PORT; do      echo "nsfminer crashed with exit code $?" >&2      sleep 1  done  

I understand the security implications involved in passing a root password via a bash script, but it's the only way to get the miner to work as it requires root privileges and I have the system partitioned in a way that the installation I use for crypto mining only has mining stuff and i3 installed on it and doesn't have any passwords stored in plaintext in any files. It's otherwise a minimal ubuntu install with most of the applications stripped away. I intend in the future to perhaps go the debian stable route, or maybe start from ubuntu server which I have tried before but I just haven't had the time to get everything working with nvidia drivers being a pain and all. Thanks for any help from anyone more knowledgeable than me.

How networking works with forwarding disabled?

Posted: 12 Jun 2021 04:54 PM PDT

I think on most systems the network forwarding is disabled by default - so the computer cannot act as a router. I wonder, how then does networking inside of the computer work? A few examples:

  • hosting a website locally - when we host the site locally and try to access it locally, we have to send an HTTP request - this request needs to be forwarded back to lo interface
  • virtualization - virtual machines add additional virtual adapters to the computer. It is possible to communicate between various NICs - isn't that also forwarding?

What is then really disabled when network forwarding is disabled in the system?

So, I need to display the total number of files in a directory, so how can I use "ls -la" command in vi editor using functions

Posted: 13 Jun 2021 12:49 AM PDT

Here is the code I have so far:

#! /bin/sh  Hello()  echo "Enter the directory"  read dir  {   echo "The directory $dir has a total of:"  }  Hello()  

Does sudo apt install command also update an already installed app?

Posted: 13 Jun 2021 12:52 AM PDT

I'm new to Linux OS distributions and I came up with a question when I had to update my Visual Studio Code today. I've searched for some solutions to update it through my terminal and every solution involved applying the command sudo apt install code. So here is my question, if I already have the application installed I can simply "install it again"?

How do I extract the digits from a line and save it into a variable?

Posted: 12 Jun 2021 10:40 PM PDT

I feel like this is a really easy question, and when I Google, I find lots of answers for part of the problem, but when I try to put them together, it doesn't work and I can't figure out why.

Here's the scenario:

  1. I have a file with a lot of text in it.
  2. One of those lines matches this pattern: foo = 1700;
  3. I want to extract 1700
  4. I want to save it into a bash script variable so I can refer to it later in the script.

I cannot get past step 3. Here's what I've tried:

sed -nE 's/^foo = //p' file | sed -nE 's/;//p'  

This prints out:

1700  

Great, but what if I need to trim white space or something? If I can't use */+, I wouldn't know how to do that. I learned that you can't use */+ in a substitution on another answer, so I can't figure out how to do this. I looked into the man page of grep, and I didn't see any option for groups when I search for that word. I think I know how to solve this in awk, but I've always found its regex functions to be a little clunky and for the commandline scripts to require too many escapes, so ideally that's not the only way to solve this.

Correcting .zshrc to ~/.zshrc

Posted: 12 Jun 2021 05:45 PM PDT

Is there a way to set some kind of an alias so that when I do:

cd some/directory  vim .zshrc  

It does vim ~/.zshrc?

Question regarding awk 'NF {p=1} p'

Posted: 12 Jun 2021 05:19 PM PDT

Searching for a way to remove blank lines from the beginning and the end of a file, I've stumbled across this one:

awk 'NF {p=1} p'  

How / why does this work?

I understand NF is only true if there are any fields (if the line is not a blank line).

Is it possible to execute commands outside of a rule using GNU Make?

Posted: 12 Jun 2021 07:59 PM PDT

Is it possible to execute commands outside of a rule using GNU Make?

Consider the following Makefile:

x = foo bar baz    ifdef x      @echo $(x)  endif  

This results in Makefile:4: *** commands commence before first target. Stop.

However, if I add a rule, it works:

x = foo bar baz    ifdef x  t:      @echo $(x)  endif  

Is it really necessary to add rules for outputting variables for debugging, etc.?

Bonus:

Why does the removal of ifdef result in Makefile:3: *** missing separator. Stop.?

x = foo bar baz    @echo $(x)  

I can’t get to my CentOS 8, Failed to switch root, '/sysroot'

Posted: 12 Jun 2021 10:46 PM PDT

I have only pictures. And I can't write the Question well.

I was starting my laptop (I have Windows 10 Pro and CentOS8).

systemctl status initrd-switch-root.service

https://i.stack.imgur.com/fuGRU.jpg

https://i.stack.imgur.com/CAQ7Y.jpg

The last image Failed to Start Switch Root. And

Failed to switch root: Specified switch root path '/sysroot' does not seem to be an OS tree. os-release file is missing.  

https://i.stack.imgur.com/onWbr.jpg

Doing a ls -al /sysroot the directory is empty.

With dmesg i got:

enter image description here

any idea why this failure occurs?

And obviously, how I can solve it?

In the image, the only entry working is Rescue The CentOS entry that is above the Windows entry CentOS Linux (0-rescue-***) enter image description here

Please help.

EDIT 1 Using described on https://unix.stackexchange.com/a/212710/117555

  1. Check dev -> ls -al /dev/s*
  2. Insert the USB stick
  3. Check Again -> ls -al /dev/s*
  4. Create Mounting Directory -> mkdir -p /mnt/logError_SwitchRoot
  5. Mount the stick -> mount /dev/sd[letter][number] /mnt/logError_SwitchRoot
  6. Copy the File -> cp /run/initramfs/rdsosreport.txt /mnt/logError_SwitchRoot
  7. Umount the stick -> umount /mnt/logError_SwitchRoot

I have now on rdsosreport.txt file on https://drive.google.com/file/d/1vMK0QAoyMZ7xTibDqn8Y_Y9nohUStN-6/view?usp=sharing

Checking the File:

    /dev/nvme0n1p1: LABEL="SYSTEM_DRV" UUID="5464-19F2" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="31ebd6ef-ec98-42c7-a57b-7855c2c9a1f3"      /dev/nvme0n1p5: LABEL="WINRE_DRV" UUID="C2EC6975EC69651F" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="51363955-3d66-4f95-92de-732ccff36936"      /dev/nvme0n1p6: LABEL="boot_efi" UUID="6E91-210B" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="5291c15b-2f5c-42a0-b3e3-2c69f27b801b"      /dev/nvme0n1p7: UUID="7471a525-f8c8-4a77-819e-65b40c04eaaf" TYPE="ext4" PARTUUID="13b3a31b-193f-4ef5-9076-a083cdc857de"      /dev/nvme0n1p8: UUID="d1ee8d12-37a1-43e7-9f13-0f97544864aa" TYPE="ext4" PARTUUID="88cd29e2-3b20-44e4-bdf4-0ce02d9008d6"      /dev/nvme0n1p9: UUID="54f24598-4a21-4875-bacd-61c060de891f" TYPE="ext4" PARTUUID="d1126852-240f-4e03-a8f3-86f769b3fd77"      /dev/nvme0n1p10: UUID="3fc5f4f8-566b-48e2-85e1-59f5dccdcb57" TYPE="ext4" PARTUUID="b2190e39-3ee8-4a41-a156-6a866ee8ee14"      /dev/nvme0n1p11: UUID="42640b78-ce32-403c-8705-8c12e2d02855" TYPE="swap" PARTUUID="acc07fc2-4876-42c0-9d02-b066c04cfd4f"      /dev/sda1: LABEL="EFI" UUID="67E3-17ED" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="5cd547d2-a0ef-4c51-8a00-9877055342bb"      /dev/nvme0n1: PTUUID="e24c5cda-1faa-490b-b677-7c4792194960" PTTYPE="gpt"      /dev/nvme0n1p2: PARTLABEL="Microsoft reserved partition" PARTUUID="b692aa4c-0d83-40f0-8707-cd0b49290b00"      /dev/nvme0n1p3: PARTLABEL="Basic data partition" PARTUUID="72f573a8-4b1d-40ab-900c-5b2b608fa964"      /dev/nvme0n1p4: PARTLABEL="Basic data partition" PARTUUID="50badba8-609d-4a24-b957-c8f90b8d7d80"      /dev/sda2: PARTUUID="f704e2d2-a0b9-4fa4-9b19-cef07c8b6668"  

And

BOOT_IMAGE=(hd1,gpt7)/vmlinuz-5.8.0-1.el8.elrepo.x86_64  

EDIT 2:

I found some pictures of my installation (5 July 2020 15:05, for my reference)!

DATA      /home      nvme0n1p8    SYSTEM      /boot/efi      nvme0n1p6        /var      nvme0n1p10        /      nvme0n1p9        /boot      nvme0n1p7        swap      nvme0n1p11  

Here my info (After the restart)

[root@centos /]# lsblk -o NAME,MAJ:MIN,RM,SIZE,RO,FSTYPE,UUID,MOUNTPOINT  NAME         MAJ:MIN RM   SIZE RO FSTYPE   UUID                                 MOUNTPOINT  loop0          7:0    0  29.8M  1 squashfs                                      /var/lib/snapd/snap/snapd/8140  loop1          7:1    0    55M  1 squashfs                                      /var/lib/snapd/snap/core18/1754  loop2          7:2    0  29.9M  1 squashfs                                      /var/lib/snapd/snap/snapd/8542  loop3          7:3    0    55M  1 squashfs                                      /var/lib/snapd/snap/core18/1880  loop4          7:4    0    97M  1 squashfs                                      /var/lib/snapd/snap/core/9665  loop5          7:5    0  62.1M  1 squashfs                                      /var/lib/snapd/snap/gtk-common-themes/1506  nvme0n1      259:0    0   477G  0                                                 ├─nvme0n1p1  259:1    0   260M  0 vfat     5464-19F2                              ├─nvme0n1p2  259:2    0    16M  0                                                 ├─nvme0n1p3  259:3    0 115.7G  0                                                 ├─nvme0n1p4  259:4    0   104G  0                                                 ├─nvme0n1p5  259:5    0  1000M  0 ntfs     C2EC6975EC69651F                       ├─nvme0n1p6  259:6    0     1G  0 vfat     6E91-210B                            /boot/efi  ├─nvme0n1p7  259:7    0     1G  0 ext4     7471a525-f8c8-4a77-819e-65b40c04eaaf /boot  ├─nvme0n1p8  259:8    0   174G  0 ext4     d1ee8d12-37a1-43e7-9f13-0f97544864aa /home  ├─nvme0n1p9  259:9    0    32G  0 ext4     54f24598-4a21-4875-bacd-61c060de891f /  ├─nvme0n1p10 259:10   0    24G  0 ext4     3fc5f4f8-566b-48e2-85e1-59f5dccdcb57 /var  └─nvme0n1p11 259:11   0    24G  0 swap     42640b78-ce32-403c-8705-8c12e2d02855 [SWAP]  [root@centos /]#   

I have this list...

/tmp/nvme0n1p6/:  total 16  drwxr-xr-x 4 root root 4096 Jan  1  1970 .  drwxr-xr-x 6 root root  120 Jun 11 02:11 ..  drwxr-xr-x 4 root root 4096 Jul  5  2020 EFI  -rwxr-xr-x 1 root root 4096 Jan  1  1980 FSCK0000.REC  drwxr-xr-x 2 root root 4096 Jul 22  2020 System Volume Information    /tmp/nvme0n1p6/EFI:  total 16  drwxr-xr-x 4 root root 4096 Jul  5  2020 .  drwxr-xr-x 4 root root 4096 Jan  1  1970 ..  drwxr-xr-x 2 root root 4096 Jul  5  2020 BOOT  drwxr-xr-x 3 root root 4096 Aug 23  2020 centos    /tmp/nvme0n1p6/EFI/BOOT:  total 1544  drwxr-xr-x 2 root root    4096 Jul  5  2020 .  drwxr-xr-x 4 root root    4096 Jul  5  2020 ..  -rwxr-xr-x 1 root root 1211224 May  7  2020 BOOTX64.EFI  -rwxr-xr-x 1 root root  356800 May  7  2020 fbx64.efi    /tmp/nvme0n1p6/EFI/centos:  total 5360  drwxr-xr-x 3 root root    4096 Aug 23  2020 .  drwxr-xr-x 4 root root    4096 Jul  5  2020 ..  -rwxr-xr-x 1 root root     134 May  7  2020 BOOTX64.CSV  drwxr-xr-x 2 root root    4096 Apr 14  2020 fonts  -rwxr-xr-x 1 root root    5502 Jul  5  2020 grub.cfg  -rwxr-xr-x 1 root root       0 Aug 23  2020 grubenv  -rwxr-xr-x 1 root root 1877384 Apr 14  2020 grubx64.efi  -rwxr-xr-x 1 root root 1160136 May  7  2020 mmx64.efi  -rwxr-xr-x 1 root root 1205152 May  7  2020 shimx64-centos.efi  -rwxr-xr-x 1 root root 1211224 May  7  2020 shimx64.efi    /tmp/nvme0n1p6/EFI/centos/fonts:  total 8  drwxr-xr-x 2 root root 4096 Apr 14  2020 .  drwxr-xr-x 3 root root 4096 Aug 23  2020 ..    /tmp/nvme0n1p6/System Volume Information:  total 8  drwxr-xr-x 2 root root 4096 Jul 22  2020 .  drwxr-xr-x 4 root root 4096 Jan  1  1970 ..  

And this another List

/tmp/nvme0n1p7/:  total 360344  dr-xr-xr-x 7 root   root      4096 Aug 11  2020 .  drwxr-xr-x 7 root   root       140 Jun 11 02:17 ..  -rw-r--r-- 1 root   root       166 Dec  4  2019 .vmlinuz-4.18.0-147.el8.x86_64.hmac  -rw-r--r-- 1 root   root       172 Jun 10  2020 .vmlinuz-4.18.0-193.6.3.el8_2.x86_64.hmac  drwxrwxrwx 2 nobody 65534     4096 Sep  7  2020 System Volume Information  -rw------- 1 root   root   3838259 Dec  4  2019 System.map-4.18.0-147.el8.x86_64  -rw------- 1 root   root   3910484 Jun 10  2020 System.map-4.18.0-193.6.3.el8_2.x86_64  -rw------- 1 root   root   4654688 Jul  7  2020 System.map-5.7.8-1.el8.elrepo.x86_64  -rw------- 1 root   root   4714527 Aug  2  2020 System.map-5.8.0-1.el8.elrepo.x86_64  -rw-r--r-- 1 root   root    184613 Dec  4  2019 config-4.18.0-147.el8.x86_64  -rw-r--r-- 1 root   root    187643 Jun 10  2020 config-4.18.0-193.6.3.el8_2.x86_64  -rw-r--r-- 1 root   root    197087 Jul  7  2020 config-5.7.8-1.el8.elrepo.x86_64  -rw-r--r-- 1 root   root    201589 Aug  2  2020 config-5.8.0-1.el8.elrepo.x86_64  drwxr-xr-x 2 root   root      4096 Jul  5  2020 efi  drwx------ 2 root   root      4096 Apr 14  2020 grub2  -rw------- 1 root   root  71713525 Jul  5  2020 initramfs-0-rescue-fb78af0a9247484aad9831a10a928084.img  -rw------- 1 root   root  49320247 Jul  6  2020 initramfs-4.18.0-147.el8.x86_64.img  -rw------- 1 root   root  18223920 Jul  6  2020 initramfs-4.18.0-147.el8.x86_64kdump.img  -rw------- 1 root   root  49864041 Jul  6  2020 initramfs-4.18.0-193.6.3.el8_2.x86_64.img  -rw------- 1 root   root  18642820 Jul  6  2020 initramfs-4.18.0-193.6.3.el8_2.x86_64kdump.img  -rw------- 1 root   root  50414753 Jul 15  2020 initramfs-5.7.8-1.el8.elrepo.x86_64.img  -rw------- 1 root   root  50395127 Aug 11  2020 initramfs-5.8.0-1.el8.elrepo.x86_64.img  drwxr-xr-x 3 root   root      4096 Jul  5  2020 loader  drwx------ 2 root   root     16384 Jul  5  2020 lost+found  -rwxr-xr-x 1 root   root   8106744 Jul  5  2020 vmlinuz-0-rescue-fb78af0a9247484aad9831a10a928084  -rwxr-xr-x 1 root   root   8106744 Dec  4  2019 vmlinuz-4.18.0-147.el8.x86_64  -rwxr-xr-x 1 root   root   8913656 Jun 10  2020 vmlinuz-4.18.0-193.6.3.el8_2.x86_64  -rwxr-xr-x 1 root   root   8558528 Jul  7  2020 vmlinuz-5.7.8-1.el8.elrepo.x86_64  -rwxr-xr-x 1 root   root   8742176 Aug  2  2020 vmlinuz-5.8.0-1.el8.elrepo.x86_64    /tmp/nvme0n1p7/System Volume Information:  total 12  drwxrwxrwx 2 nobody 65534 4096 Sep  7  2020 .  dr-xr-xr-x 7 root   root  4096 Aug 11  2020 ..  -rw-rw-rw- 1 nobody 65534   76 Sep  7  2020 IndexerVolumeGuid    /tmp/nvme0n1p7/efi:  total 8  drwxr-xr-x 2 root root 4096 Jul  5  2020 .  dr-xr-xr-x 7 root root 4096 Aug 11  2020 ..    /tmp/nvme0n1p7/grub2:  total 8  drwx------ 2 root root 4096 Apr 14  2020 .  dr-xr-xr-x 7 root root 4096 Aug 11  2020 ..  lrwxrwxrwx 1 root root   25 Apr 14  2020 grubenv -> ../efi/EFI/centos/grubenv    /tmp/nvme0n1p7/loader:  total 12  drwxr-xr-x 3 root root 4096 Jul  5  2020 .  dr-xr-xr-x 7 root root 4096 Aug 11  2020 ..  drwx------ 2 root root 4096 Aug 11  2020 entries    /tmp/nvme0n1p7/loader/entries:  total 28  drwx------ 2 root root 4096 Aug 11  2020 .  drwxr-xr-x 3 root root 4096 Jul  5  2020 ..  -rw-r--r-- 1 root root  395 Jul  5  2020 fb78af0a9247484aad9831a10a928084-0-rescue.conf  -rw-r--r-- 1 root root  323 Jul  5  2020 fb78af0a9247484aad9831a10a928084-4.18.0-147.el8.x86_64.conf  -rw-r--r-- 1 root root  353 Jul  6  2020 fb78af0a9247484aad9831a10a928084-4.18.0-193.6.3.el8_2.x86_64.conf  -rw-r--r-- 1 root root  356 Jul 15  2020 fb78af0a9247484aad9831a10a928084-5.7.8-1.el8.elrepo.x86_64.conf  -rw-r--r-- 1 root root  356 Aug 11  2020 fb78af0a9247484aad9831a10a928084-5.8.0-1.el8.elrepo.x86_64.conf    /tmp/nvme0n1p7/lost+found:  total 20  drwx------ 2 root root 16384 Jul  5  2020 .  dr-xr-xr-x 7 root root  4096 Aug 11  2020 ..  

How I know what is /sysroot?

I haven't /boot/efi mounted, neither /boot directory!

How I can mount /boot/efi?

grub commands aren't working!

EDIT 3

In order to solve this problem

# grub2-editenv list  grub2-editenv: error: invalid environment block.  # grub2-editenv set  grub2-editenv: error: invalid environment block.  #   

I follow https://access.redhat.com/solutions/5622731

# mv /boot/grub2/grubenv /boot/grub2/grubenv.bak  # grub2-set-default 1  # grub2-editenv list  saved_entry=1  # grub2-editenv set  #  

EDIT 4:

https://www.golinuxcloud.com/update-grub2-grubby-grub2-editenv-rhel-8/ Checking https://www.techbrown.com/change-default-grub-entries-timeout-centos-rhel/ Works for me

# grub2-editenv - set "kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro"  

After Restart

[root@centos /]# grub2-editenv list  saved_entry=1  boot_success=1  kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet   [root@centos /]#   

EDIT 5:

[root@centos /]# grub2-editenv list  saved_entry=fb78af0a9247484aad9831a10a928084-4.18.0-193.14.2.el8_2.x86_64  boot_success=1  kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet   boot_indeterminate=1  [root@centos /]#   

For me it's estrange this line:

saved_entry=fb78af0a9247484aad9831a10a928084-4.18.0-193.14.2.el8_2.x86_64  

EDIT 6:

[root@centos /]# ls -al /boot/efi/EFI/centos/  total 5820  drwx------. 3 root root    4096 Jun 11 13:50 .  drwx------. 4 root root    4096 Nov 16  2020 ..  -rwx------. 1 root root     134 Jul 31  2020 BOOTX64.CSV  drwx------. 2 root root    4096 Mar  2 16:03 fonts  -rwx------. 1 root root    5502 Jul  5  2020 grub.cfg  -rwx------. 1 root root       0 Aug 23  2020 grubenv.bak  -rwx------. 1 root root 2285336 Mar  2 16:03 grubx64.efi  -rwx------. 1 root root 1162400 Jul 31  2020 mmx64.efi  -rwx------. 1 root root 1238416 Jul 31  2020 shimx64-centos.efi  -rwx------. 1 root root 1244496 Jul 31  2020 shimx64.efi  [root@centos /]# ls -al /boot/grub2/  total 20  drwx------. 2 root root 4096 Jun 12 22:20 .  dr-xr-xr-x. 7 root root 4096 Jun 11 13:58 ..  -rw-r--r--. 1 root root 5503 Jun 11 05:01 grub.cfg  -rw-------. 1 root root 1024 Jun 12 22:20 grubenv  lrwxrwxrwx. 1 root root   25 Apr 14  2020 grubenv.bak -> ../efi/EFI/centos/grubenv  [root@centos /]# cat /boot/grub2/grubenv  # GRUB Environment Block  saved_entry=fb78af0a9247484aad9831a10a928084-4.18.0-305.3.1.el8.x86_64  boot_success=1  kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet   boot_indeterminate=1  #################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################[root@centos /]#  

enter image description here

Obviously something wrong!!! The /efi/EFI/centos/grubenv file does not exist and /boot/grub2/grubenv seems that is malformed.

According to this link https://bugzilla.redhat.com/show_bug.cgi?id=1435435 The physical file must be located in /efi/EFI/centos/grubenv and a symlink /boot/grub2/grubenv should be pointing to /efi/EFI/centos/grubenv.

How can I create the /efi/EFI/centos/grubenv file, without editing it directly?

And

[root@centos /]# awk -F\' '/^menuentry/ {print $2}' /boot/grub2/grub.cfg  Windows Boot Manager (on /dev/nvme0n1p1)  System setup  [root@centos /]#    [root@centos /]# awk -F\' '/^menuentry/ {print $2}' /boot/efi/EFI/centos/grub.cfg  Windows Boot Manager (on /dev/nvme0n1p1)  System setup  [root@centos /]#    [root@centos /]# grub2-mkconfig -o /boot/grub2/grub.cfg.bck  Generating grub configuration file ...  Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi  Adding boot menu entry for EFI firmware configuration  done  [root@centos /]#    [root@centos /]# awk -F\' '/^menuentry/ {print $2}' /boot/grub2/grub.cfg.bck  Windows Boot Manager (on /dev/nvme0n1p1)  System setup  [root@centos /]#  

Why are the Linux entries not appearing? I follow this link

# ls -al /boot/loader/entries  total 36  drwx------. 2 root root 4096 Jun 11 13:57 .  drwxr-xr-x. 3 root root 4096 Jul  5  2020 ..  -rw-r--r--. 1 root root  395 Jul  5  2020 fb78af0a9247484aad9831a10a928084-0-rescue.conf  -rw-r--r--. 1 root root  358 Jun 11 11:36 fb78af0a9247484aad9831a10a928084-4.18.0-193.14.2.el8_2.x86_64.conf  -rw-r--r--. 1 root root  353 Jul  5  2020 fb78af0a9247484aad9831a10a928084-4.18.0-193.6.3.el8_2.x86_64.conf  -rw-r--r--. 1 root root  336 Jun 11 13:57 fb78af0a9247484aad9831a10a928084-4.18.0-305.3.1.el8.x86_64.conf  -rw-r--r--. 1 root root  366 Jun 11 12:05 fb78af0a9247484aad9831a10a928084-5.12.10-1.el8.elrepo.x86_64.conf  -rw-r--r--. 1 root root  356 Jul 15  2020 fb78af0a9247484aad9831a10a928084-5.7.8-1.el8.elrepo.x86_64.conf  -rw-r--r--. 1 root root  356 Aug 11  2020 fb78af0a9247484aad9831a10a928084-5.8.0-1.el8.elrepo.x86_64.conf  [root@centos /]#  

And following this answer https://stackoverflow.com/a/64637392

I list all # grubby --info=ALL

I view a specific # grubby --info 0

Check what was my default

[root@centos /]# grubby --info DEFAULT  index=3  kernel="/boot/vmlinuz-4.18.0-305.3.1.el8.x86_64"  args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params"  root="UUID=54f24598-4a21-4875-bacd-61c060de891f"  initrd="/boot/initramfs-4.18.0-305.3.1.el8.x86_64.img $tuned_initrd"  title="CentOS Linux (4.18.0-305.3.1.el8.x86_64) 8"  id="fb78af0a9247484aad9831a10a928084-4.18.0-305.3.1.el8.x86_64"  [root@centos /]#  

I was trying to change the default with # grubby --args amd_iommu=on --update-kernel=/boot/vmlinuz-$(uname -r) and with grubby --args amd_iommu=on --update-kernel 2 But it does not work (using # grubby --info DEFAULT)!

Reviewing 0 Entry

[root@centos /]# grubby --info 0  index=0  kernel="/boot/vmlinuz-5.12.10-1.el8.elrepo.x86_64"  args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params amd_iommu=on"  root="UUID=54f24598-4a21-4875-bacd-61c060de891f"  initrd="/boot/initramfs-5.12.10-1.el8.elrepo.x86_64.img $tuned_initrd"  title="Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)"  id="fb78af0a9247484aad9831a10a928084-5.12.10-1.el8.elrepo.x86_64"  [root@centos /]#  

And following https://unix.stackexchange.com/a/394889/400726

Selecting by title:

[root@centos /]# grub2-editenv - set saved_entry='Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)'  [root@centos /]#   

Apparently it changed.

[root@centos /]# grubby --info DEFAULT  index=0  kernel="/boot/vmlinuz-5.12.10-1.el8.elrepo.x86_64"  args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params amd_iommu=on"  root="UUID=54f24598-4a21-4875-bacd-61c060de891f"  initrd="/boot/initramfs-5.12.10-1.el8.elrepo.x86_64.img $tuned_initrd"  title="Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)"  id="fb78af0a9247484aad9831a10a928084-5.12.10-1.el8.elrepo.x86_64"  [root@centos /]#  

Restarting, But it doesn't work either!

Reviewing

[root@centos /]# cmp /boot/efi/EFI/centos/grubenv /boot/grub2/grubenv  /boot/efi/EFI/centos/grubenv /boot/grub2/grubenv differ: byte 38, line 2  [root@centos /]#   

The files has been changed, are different!!

[root@centos /]# cat /boot/efi/EFI/centos/grubenv  # GRUB Environment Block  saved_entry=fb78af0a9247484aad9831a10a928084-4.18.0-305.3.1.el8.x86_64  boot_success=0  kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet   boot_indeterminate=0  #################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################[root@centos /]#       [root@centos /]# cat /boot/grub2/grubenv  # GRUB Environment Block  saved_entry=Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)  boot_success=1  kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet   boot_indeterminate=1  #########################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################[root@centos /]#   

I was trying

[root@centos /]# rm /boot/grub2/grubenv.bak  rm: remove symbolic link '/boot/grub2/grubenv.bak'? y  [root@centos /]#  [root@centos /]# rm /boot/efi/EFI/centos/grubenv.bak  rm: remove regular empty file '/boot/efi/EFI/centos/grubenv.bak'? y  [root@centos /]#    [root@centos /]# ln -s /boot/grub2/grubenv /boot/efi/EFI/centos/grubenv  ln: failed to create symbolic link '/boot/efi/EFI/centos/grubenv': Operation not permitted  [root@centos /]#  

I would have preferred a symlink (But, I undersa tood the situation https://www.linuxquestions.org/questions/suse-opensuse-60/boot-is-not-allowing-symbolic-link-creation-4175682262/#post6166967)!

[root@centos /]# cp /boot/grub2/grubenv /boot/efi/EFI/centos/  [root@centos /]#  

Is there some work around?

[root@centos /]# ls -al /boot/grub2/  total 28  drwx------. 2 root root 4096 Jun 12 23:07 .  dr-xr-xr-x. 7 root root 4096 Jun 11 13:58 ..  -rw-r--r--. 1 root root 5503 Jun 11 05:01 grub.cfg  -rw-r--r--. 1 root root 6956 Jun 12 22:59 grub.cfg.bck  -rw-------. 1 root root 1024 Jun 12 22:59 grubenv  [root@centos /]#    [root@centos /]# ls -al /boot/efi/EFI/centos/  total 5824  drwx------. 3 root root    4096 Jun 12 23:09 .  drwx------. 4 root root    4096 Nov 16  2020 ..  -rwx------. 1 root root     134 Jul 31  2020 BOOTX64.CSV  drwx------. 2 root root    4096 Mar  2 16:03 fonts  -rwx------. 1 root root    5502 Jul  5  2020 grub.cfg  -rwx------. 1 root root    1024 Jun 12 23:06 grubenv  -rwx------. 1 root root 2285336 Mar  2 16:03 grubx64.efi  -rwx------. 1 root root 1162400 Jul 31  2020 mmx64.efi  -rwx------. 1 root root 1238416 Jul 31  2020 shimx64-centos.efi  -rwx------. 1 root root 1244496 Jul 31  2020 shimx64.efi  [root@centos /]#  

date - how to get next weekday (ignore weekends)

Posted: 12 Jun 2021 06:06 PM PDT

I'm setting up a cron job to suspend and wake a server at certian times.

I'm using two commands. One to be run from mondays to thursdays:

rtcwake -m mem -t $(date +%s -d "08:00")  

And another one to be run on fridays:

rtcwake -m mem -t $(date +%s -d "monday 08:00")  

I wonder if it's possible to make this separation unnecessary. If date could understand a statement like next weekday 08:00, it'd simplify things a lot.

I wasn't able to find if this is actually possible or what syntax should I use.

I basically want to avoid my server waking up on saturdays and sundays.

Accessing qemu multicast networks (from Docker containers)

Posted: 13 Jun 2021 12:01 AM PDT

QEMU allows to connect different VMs by using a virtual network based on a common multicast address by specifying -netdev socket,mcast=230.0.0.1:1234 on startup.

This way I can easily connect multiple VMs and join new VMs on the fly.

Is it possible to join that network without using QEMU? Especially is it possible to connect a docker container to that network?

Aws ec2 - How to rsync files between two remotes?

Posted: 12 Jun 2021 07:01 PM PDT

I'm setting up a crontab server to run several jobs to copy files from prod servers to lower environment servers.

I need the cron server job to copy files from one server to another. Here is what I have.

the ip's have been modified

ssh -v -R localhost:50000:1.0.0.2:22 -i host1key.pem ec2-user@1.0.0.1 'rsync -e "ssh -i /home/ec2-user/host2key.pem -p 50000" -vuar /home/ec2-user/test.txt ec2-user@localhost:/home/ec2-user/test.txt'  

I'm using two different pem keys and users. I would think this command would work but I get this error in the debug log. Here is more to it and only show the portion that is erroring. It connects to ec2-user@1.0.0.1 successfully. But errors on the 1.0.0.2:

debug1: connect_next: host 1.0.0.2 ([1.0.0.2]:22) in progress, fd=7  debug1: channel 1: new [127.0.0.1]  debug1: confirm forwarded-tcpip  debug1: channel 1: connected to 1.0.0.2 port 22  Host key verification failed.  debug1: client_input_channel_req: channel 0 rtype exit-status reply 0  debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0  rsync: connection unexpectedly closed (0 bytes received so far) [sender]  rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]  debug1: channel 0: free: client-session, nchannels 2  debug1: channel 1: free: 127.0.0.1, nchannels 1  Transferred: sent 5296, received 4736 bytes, in 0.9 seconds  Bytes per second: sent 5901.2, received 5277.2  debug1: Exit status 12  

How do i make guake start with tmux?

Posted: 12 Jun 2021 06:04 PM PDT

i am using i3wm and guake. I always use tmux inside guake to have split functionality detach function etc is there a way to start guake by default tmux running ?

Postfix does not check "From:" address with sender_login_maps

Posted: 12 Jun 2021 11:04 PM PDT

I am trying to set up a postfix configuration where (virtual) users are allowed to only send with "From:"-addresses they own. So I put reject_authenticated_sender_login_mismatch into smtpd_sender_restrictions.

Using

query = SELECT goto FROM alias WHERE address='%s' and active=1;  

in my sender_login_maps.cf I can send mails with any sender address I want, even something like madeup@not_my_domain.com.

However,

postmap -q "madeup@not_my_domain.com" mysql:/etc/postfix/sql/sender_login_maps.cf   

returns nothing as expected.

Now if I change the query to

SELECT goto FROM alias WHERE address='notinthedatabaseforsure' and active=1;   

I am not able to send any mails at all. So far so good. But the log says

postfix/smtps/smtpd[11683]: NOQUEUE: reject: RCPT from...: 553 5.7.1 <user@domain.com>:     Sender address rejected: not owned by user user@domain.com; from=<user@domain.com> to=<user2@domain.com> proto=ESMTP helo=<[192.168.2.103]>  

even if I try to send from madeup@not_my_domain.com. user@domain.com is the login name, user2@domain.com the recipient.

In a proper setup i would expect something like

postfix/smtps/smtpd[11683]: NOQUEUE: reject: RCPT from ...: 553 5.7.1 <madeup@not_my_domain.com>:     Sender address rejected: not owned by user user@domain.com; from=<madeup@not_my_domain.com> to=<user2@domain.com> proto=ESMTP helo=<[192.168.2.103]>  

So it looks like postfix uses the login name to search for the login name regardless of the sender address, which explains why I can send with any sender address using the query I mentioned first.

Update: I checked my sql logs and indeed, the MySQL server never sees madeup@not_my_domain.com. It only gets queries for the login address and the recipient address user2@domain.com.

Here are the smtps part from master.cf and my main.cf:

  smtps inet n - - - - smtpd    -o syslog_name=postfix/smtps    -o smtpd_tls_wrappermode=yes    -o tls_preempt_cipherlist=yes    -o smtpd_tls_security_level=encrypt    -o smtpd_sasl_auth_enable=yes    -o smtpd_client_restrictions=permit_sasl_authenticated,reject    -o milter_macro_daemon_name=ORIGINATING    -o smtpd_sasl_type=dovecot    -o smtpd_sasl_security_options=noanonymous    -o smtpd_relay_restrictions=reject_non_fqdn_recipient,reject_unknown_recipient_domain,permit_mynetworks,permit_sasl_authenticated,reject    -o milter_macro_daemon_name=ORIGINATING    -o cleanup_service_name=submission-header-cleanup  
  mynetworks = 127.0.0.0/8  inet_interfaces = all  mydomain = domain.com  myhostname = mail.domain.com  myorigin = $mydomain  mydestination =  relayhost =      smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_non_fqdn_recipient    smtpd_recipient_restrictions =   permit_mynetworks,   permit_sasl_authenticated,   reject_non_fqdn_hostname,   reject_non_fqdn_sender,   reject_non_fqdn_recipient,   reject_unauth_destination,   reject_unauth_pipelining,   reject_invalid_hostname    smtpd_sender_restrictions =   reject_non_fqdn_sender,   reject_unknown_sender_domain,   reject_unauth_pipelining,   reject_authenticated_sender_login_mismatch,   permit_sasl_authenticated    smtpd_helo_required = yes  smtpd_helo_restrictions =   permit_mynetworks                              reject_invalid_helo_hostname                              reject_non_fqdn_helo_hostname                              reject_unknown_helo_hostname    smtpd_data_restrictions = reject_unauth_pipelining    smtpd_sasl_auth_enable = yes  smtpd_sasl_security_options = noanonymous, noplaintext  smtpd_sasl_type = dovecot  smtpd_sasl_path = private/auth    postscreen_access_list =        permit_mynetworks                                  cidr:/etc/postfix/postscreen_access  postscreen_blacklist_action = drop  postscreen_greet_action = drop    postscreen_dnsbl_threshold = 2  postscreen_dnsbl_sites = dnsbl.sorbs.net*1, bl.spamcop.net*1, ix.dnsbl.manitu.net*2, zen.spamhaus.org*2  postscreen_dnsbl_action = drop    virtual_alias_maps = mysql:/etc/postfix/sql/aliases.cf  virtual_mailbox_maps = mysql:/etc/postfix/sql/accounts.cf  virtual_mailbox_domains = mysql:/etc/postfix/sql/domains.cf  relay_domains = mysql:/etc/postfix/sql/relay_domains.cf  smtpd_sender_login_maps = mysql:/etc/postfix/sql/sender_login_maps.cf      virtual_uid_maps = static:3000  virtual_gid_maps = static:3000  virtual_mailbox_base = /home/vmail    # Disable NIS lookup warning  alias_maps=hash:/etc/aliases    append_dot_mydomain = no  recipient_delimiter = +  

How to use EXPECT in a loop foor ssh

Posted: 12 Jun 2021 05:04 PM PDT

Our Linux setup doesn't have keygen configured for password less authentication. Hence I am supposed to use only EXPECT for password less authentication in a shell script.

   /usr/bin/expect<<EOF >> ${LOG_FILE}    set timeout 60  spawn   sftp ${EWS_USER}@${EWS_HOST}:${TGT_DIR}  expect "*?assword:"  send "$password\r"  expect "sftp>"  send "put $local_dir/$line\r"  expect "sftp>"  send "bye\r"  expect EOF  EOF            filename=$(basename "$line")          # echo "File Name: $filename"          #Calculate the MD5Sum locally.          local_md5sum=$(md5sum "$line")          #echo "Local MD5Sum: ${local_md5sum}"          #Calculate the MD5sum in remote machine          remote_md5sum=$(ssh ${EWS_USER}@${EWS_HOST} "cd '$TGT_DIR' ; find -name '$filename'  -exec md5sum {} \;" < /dev/null)          #echo "Remote MD5Sum: ${remote_md5sum}"    LOCAL_SUM=`echo ${local_md5sum} | awk {'print $1'}`  REMOTE_SUM=`echo ${remote_md5sum} | awk {'print $1'}`  echo $LOCAL_SUM  echo $REMOTE_SUM  if [ "${LOCAL_SUM}" != "${REMOTE_SUM}" ]  then          echo "SFTP Successfull"  else          echo "SFTP Unsuccessfull"  fi  

I know how to use EXPECT in the below place

sftp ${EWS_USER}@${EWS_HOST} << EOF >> ${LOG_NAME}  put ${LOCAL_DIR}/${line} ${TGT_DIR}/${line}  EOF  

But any idea how to use EXPECT here in the below scenario to make the connection password less?

remote_md5sum=$(ssh ${EWS_USER}@${EWS_HOST} "cd '$TGT_DIR' ; find -name '$filename'  -exec md5sum {} \;" < /dev/null)  

proxify a custom program to proxychains

Posted: 12 Jun 2021 10:06 PM PDT

After some research, I didn't find any solutions. So I post here.

My goal: redirected the HTTPs traffic from my custom program to BurpSuite in order to analyse the server response and debug my program.

  • I have Debian 4.4.3
  • I have two network interfaces : eth0 and tap0, I work on tap0.
  • I have a php program that just send an HTTPS request to a local server (tap0). My php code use CURL to send the request (curl_init(), curl_setopt() etc.)

In a debugging goal, I have thought to send my flows via BurpSuite in order to see the HTTPS requests. So:

  • I launch Burp that listen on all interfaces port 8080
  • I configure /etc/proxychains.conf and in my ProxyList there are:

    socks4 127.0.0.1 8080  socks5 127.0.0.1 8080  socks4 XX.XX.XX.217 8080  socks5 XX.XX.XX.217 8080  

And when I use proxychains:

prochychains php myProgramme.php  

My program is executed but proxychains doesn't "proxify" the flow and so Burp doesn't see nothing...

I think that's because I am in my local network ?

What do you think about the best solution to intercept and see the HTTPS flows to my php program ?

How to disable Wifi Power Save on Kali Linux

Posted: 12 Jun 2021 09:09 PM PDT

I am running kali with virtualbox and my wifi receiver is a usb adapter which is Asus N10 Nano. I made the settings on virtualbox for making the vb recognize my usb wifi adapter. It works but after like 5min my internet drops. Especially during the updates. I figured it out its because the "Wifi Power Save" option is on. I turned it off and tried again. When i turned it off my wifi turned off at the same time. I tried to turn my wifi on but the Wifi Power Save option turned on itself automatically. The usb icon on bottom is like red-green. It needs to be blinking green to work correctly. If i can turn off the Wifi Power Save mod permamently hopefully its gonna be blinking green. I searched for it, I did almost everything like creating directory as /etc/pm/power.d/wireless and editing the file wireless by these commands:

#!/bin/sh  /sbin/iwconfig wlan0 power off  

Then i gave the permission -x for it. It didnt work. Sorry if I had mistake while I was writing this. Thanks for helping!

lspci output:

00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)  00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]  00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)  00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter  00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service  00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01)  00:06.0 USB controller: Apple Inc. KeyLargo/Intrepid USB  00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)  00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)  

It didn't work. In the end sudo depmod rtl8192cu output was: depmod: FATAL: rtl8192cu: not absolute path.

How to detect the incoming httpd Connection Counts of each VHOSTS?

Posted: 12 Jun 2021 08:10 PM PDT

With RHEL and Apache (httpd), is there a way to:

  • Detect which v.host (domain) is gaining how many incoming connections?

Because in this few days, I got a lot of incoming connections on the server being acknowledged by using:

  • ps aux | grep httpd -c

    734

That means I have 734 incoming connections currently being handled by Apache but the problem is I have (lets say) 10 Vhosts (domains).

  • So which domain is getting the high loads?

Read and confirm shell script before piping from curl to sh (curl -s [url] | sh)

Posted: 12 Jun 2021 08:25 PM PDT

Whenever I have to execute a shell script from the web curl -s [url] | sh, I first open url in my web browser to make sure the script isn't malicious and is safe to run.

I remember seeing a command line trick that made it was possible to read the script from the command line and then confirm execution after reading the script. If I recall correctly, it looked something like curl -s [url] | something...here | sh and didn't require any software install.

Does anyone know this trick?

Recent Questions - Mathematics Stack Exchange

Posted: 12 Jun 2021 10:58 PM PDT

Recent Questions - Mathematics Stack Exchange


Counterexamples for Banach *-algebras

Posted: 12 Jun 2021 10:55 PM PDT

  1. Construct an example of a Banach $*$-algebra $\mathcal A$ such that for all $t\in [0,1]$, there exists a character $\chi$ on $\mathcal A$ such that $\|\chi\|=t$.

  2. Find example of a non unital Banach $*$-algebra which has a closed two sided ideals, which is not closed under scalar multiplication. (such example does not exists in a $C^*$-algebra because $C^*$-algebra has approximate identity)

  3. Find example (if possible) of a unital Banach $*$-algebra with a closed two sided ideals, but is not self adjoint.

  4. Example of a unital Banach $*$-algebra $\mathcal A$ with a normal element $a$ such that there does not exists unital $*$-homomorphism from $C(\sigma(a))$ to $\mathcal A$ such that identity map goes to $a$.

These are not homework problems. Such examples don't exists for a $C^*$-algebra and I am unable to prove these in a Banach $*$-algebra.

Inclusive vs Exclusive OR: Tomorrow it ill rain or it will be dry all day?

Posted: 12 Jun 2021 10:51 PM PDT

I'm taking Keith Devlin's course "Introduction to Mathematical Thinking". Currently, I am learning Exclusive-OR and Inclusive-OR.

Keith provides one factoid, that, Exclusive-OR statements can be formatted using "Either-OR". Moving further he provides an example.

(3<5) $\lor$ (1=0) ex.1

Which he indicates that above statement is Inclusive-OR.

But then, he provides following statement and asks student whether it is Inclusive or Exclusive OR.

Let A be the sentence, "It will rain tomorrow".

Let B be the sentence, "It will be dry tomorrow".

Is it same as saying,

"Tomorrow it will rain or it will be dry all day." ex.2

And answer to this questions is "Exclusive-OR.

My question is, given a sentence using 'or', how to determine that it is Inclusive or Exclusive OR?

Because, I think that given limited information it is difficult to determine inclusive or exclusive form of OR.

probability question on drawing ball

Posted: 12 Jun 2021 10:57 PM PDT

I have a bag containing $20$ red balls and $16$ blue balls. I uniformly randomly take balls out from the bag without replacement until all balls of both colors have been removed. If the probability that the last ball I took was red can be represented as $\frac{p}{q}$, where $p$ and $q$ are coprime positive integers. Find $p+q$

My solution: as the last ball is red, that means we have drawn $19$ red balls and $16$ blue balls so far. The total no of ways of doing it is $35 \choose19$. Now total no of ways of drawing all the balls is $36 \choose 20$. The probability is

$$\frac{35\choose19}{36\choose20}=\frac{5}{9}$$ But the answer is $\frac{4}{9}$. Can you please correct my solution?

Derivative of a state variable as an output of an affine system

Posted: 12 Jun 2021 10:41 PM PDT

Given simple system of ODE.

\begin{cases} \dot{x_1}=-x_1+u \\ \dot{x_2}=-x_2-x_1 \end{cases}

As an output, I want to use $y=\dot{x_1}$.

I'm trying to convert to an affine state-space, but in the case of such an output, descriptor matrix is singular (code in Mathematica for example).

asys = AffineStateSpaceModel[{x1'[t] == -x1[t] + u[t], x2'[t] == -x2[t] - x1[t]}, {{x1[t], 1}, {x2[t], 1}}, {u[t]}, {x'[t]}, t] // Simplify  

I got the idea to add a differentiating filter:

\begin{cases} \dot{x_1}=-x_1+u \\ \dot{x_2}=-x_2-x_1 \\ \frac{1}{k}\dot{X}+X=\dot{x_1} \end{cases}

And now $y=X \approx \dot{x_1}$ and $k>>1$.

Are there some simpler ways to modify the equation and get $y=\dot{x_1}$?

Question about a remark in Serre's Linear Representations of Finite Groups

Posted: 12 Jun 2021 10:39 PM PDT

I'm reading the section 11.1 in Serre's Linear Representations of Finite Groups.

My question is about the existence of $\varphi$ in the remark. If $\varphi$ is the function mentioned in the remark, then $\varphi=\sum\limits_{H\in X}\varphi Ind_H^G f_H=\sum\limits_{H\in X}Ind_H^G (f_H Res_H^G\varphi)=\sum\limits_{H\in X}Ind_H^G (f_H \varphi_H)$. Thus we can construct $\varphi$ as $\sum\limits_{H\in X}Ind_H^G (f_H \varphi_H)$. But how to see that the constructed $\varphi$ satisfy that $Res_H^G \varphi=\varphi_H$? I tried direct computation, but I got nowhere. Since Serre didn't give a proof, I guess the result should be obvious. Maybe I'm missing something.

Any help? Thanks!

Fractal dimension of domain wall in Ising model at criticality

Posted: 12 Jun 2021 10:38 PM PDT

Consider the Ising model on an $L \times L$ lattice with periodic boundary conditions in the east/west directions and with spins on the north boundary fixed as $+1$ and the spins on the south boundary fixed as $-1$. Then, if you fix a cold temperature $T < T_c$, as $L \to \infty$ you expect that the domain wall between the $+1$ spin cluster on the top and the $-1$ spin cluster on the bottom approaches a flat line (dimension 1), and exactly at $T = T_c$ you expect there to be some nontrivial behaviour, where you end up with the domain wall being some fractal dimension between $1$ and $2$.

This is just intuition I've gleaned from a talk I attended ~2 years ago, but I can't find any references following this line of thought. Are there any places to look to see experiments in this direction? In particular, I'm mainly curious how to rigorously define what the fractal dimension we are measuring at $T = T_c$ is in the thermodynamic limit, and what this number turns out to be.

As an example of how to formalise what I'm talking about, we can consider the box-counting dimension, and simply define the fractal dimension of the domain wall to be: $$\text{dim}_\text{box}(\text{Domain Wall}) = \lim_{\epsilon = \frac{1}{L} \to 0} \frac{\langle\text{Number of sites that the domain wall passes through}\rangle_\text{Gibbs Distribution on L x L lattice}}{\log(1/\epsilon)}$$ There might be other formulations based on the actual thermodynamic limit measure, but this isn't something I'm too familiar with

Different proofs for $A ({\rm adj}A)=\det(A)I$

Posted: 12 Jun 2021 10:38 PM PDT

If $A$ is an $n\times n$ matrix, then ${\rm adj}(A)$ is the the $n\times n$ matrix, whose $(j,i)$-th entry is $(-1)^{i+j}$ times the determinant of a submatrix of $A$ obtained by deleting $i$-th row and $j$-th column. After introduction of ${\rm adj}(A)$, one immediately learns the most important result that $$A{\rm adj}(A)=\det(A)I.$$ Now for proof of this, one way is to proceed with the definition of $\det(A)$ by expansion along any row or column.

Are there any other proofs of this result? I was unable to find in any books.

Finding $\int^1_0 \frac{x\,\mathrm dx}{((2x-1)\sqrt{x^2+x+1} + (2x+1)\sqrt{x^2-x+1})\sqrt{x^4+x^2+1}}$

Posted: 12 Jun 2021 10:49 PM PDT

$$\int^1_0 \frac{x\,\mathrm dx}{((2x-1)\sqrt{x^2+x+1} + (2x+1)\sqrt{x^2-x+1})\sqrt{x^4+x^2+1}}$$

I've tried :

  1. Substitution:
    • $t = x^2$
    • $x = \cos{t}$
  2. Definite Integral Properties like $a+b-x$ (which messes up the integral symmetry)
  3. Partial Integration by breaking integral into into $\frac{x}{\sqrt{\left(x^4+x^2+1\right)}}$
  4. Partial Fractions which are very ugly

As per wolframAlpha, a beautiful elementary closed form exists $$ \frac{\sqrt{\left(x^4+x^2+1\right)}}{3}\left(\frac{1}{\sqrt{\left(x^2-x+1\right)}}- \frac{1}{\sqrt{\left(x^2+x+1\right)}}\right) $$

I'll be happy with solution of just definite integral, bonus points if you get closed form solution too.

If $E|_k$ is a finite extension such that $E^pk=E$, then prove $E^{p^m}k=E$ where $p=$char$(k)$

Posted: 12 Jun 2021 10:36 PM PDT

Here $E^p:=\{x^p:\ x\in E\}$. As $k$ is field of charateristic $p$, $E^p$ is a subfield of $E$.

Now given that $E^pk=E$. I'm trying to show that $E^{p^m}k=E$.

If I can prove that $E^pE^p=E^{2p}$. Then It will follow that $E^{2p}k=E^pE^pk=E^pE=E$. By induction $E^{np}k=E$, hence $E^{p^m}k=E$.

But I'm unable to prove $E^pE^p=E^{2p}$.

Then how to argue $E^{p^m}k=E$. This might look easy but I'm not getting it. Can anyone help me in this regard?

Thanks for help in advance.

Find the mistake in my conditional probability calculation

Posted: 12 Jun 2021 10:52 PM PDT

A meeting has $12$ employees. Given that $8$ of the employees are women, find the probability that all the employees are women?

I just defined the two events $A : 8$ employees are female and $B :$ all employees are female. Thus, we need $P(B|A)=\frac{P(A \cap B)}{P(A)}$.

Now, we know that $P(A \cap B) = P(B)$. So, $P(B)=\frac{1}{2^{12}}$ considering equal probability of male and females. Also, $P(A)={12 \choose 8} \frac{1}{2^{12}}$. On dividing the conditional probability comes out to be $\frac{1}{{12 \choose 8}}$ but it does not match with the answer to this question. Where am I going wrong? Anyone please help!

Creating a D- dimensional array and evaluating a function

Posted: 12 Jun 2021 10:34 PM PDT

I am new to Matlab and could use some help. I want to create a d-dimensional box and evaluate a function $f(x) = \sum_i^d x_i$ over the grid. I am encountering some issues while coding I did some reading and experimentation using $ndgrid$ from Matlab, but I think I am not using it correctly as I get a list and then I cannot evaluate it.

Basically I created $x = linespace(0,1,N)$ then I wanted to create a function that takes the dimension d and x and give me the mesh grid that I can pass to f, and get the function evaluations.

Thank you very much for your time guys.

Discrete Turning Number

Posted: 12 Jun 2021 10:34 PM PDT

There are two equivalent way to define turning number of a immersed closed curve.

  1. The total signed curvature of the curve dividing $2\pi$.

  2. the number of full rotation of $2\pi$ with respect to the tangent of the curve. See Turning number meaning.

For example, according to wikipedia, we have turning number $3$ for the curve below:

enter image description here

Meanwhile, the turning number of a polygonal closed path is defined to be the total discrete curvature of the path dividing $2\pi$. Namely, $\dfrac{\sum_{i=1}^n(\pi-\alpha_i)}{2\pi}$, where $\alpha_i$ are the "internal angles" of the polygon. Note we define interior angles to be the angles you get when you FOLLOW the polygon (the angle could be on the exterior of the shape). Exterior angles are simply the complement of the interior ones. See Theorem 2.1, p.31.

I think the turning number of a polygonal closed path can also defined to be the number of full rotation of $2\pi$ as walking along the polygon and turning at the vertices.

enter image description here

For example, there are two anticlockwise full rotation of $2\pi$ and one clockwise full rotation of $2\pi$ in the left of the above figure. This gives $2(+1)+(-1)=1$ as the turning number. While there is one anticlockwise full rotation of $2\pi$ in the right of the above figure. This gives $+1$ as the turning number.

But I cannot find any references about this definition/interpretation of the discrete turning number. Did anyone have any book/paper about this interpretation?

Find the loan amount borrowed

Posted: 12 Jun 2021 10:43 PM PDT

I am working on the EMI calculator module as part of the current banking project. I find answers for calculating simple interest, EMI, and even tenure but not able to find a formula to calculate the total amount borrowed. I found the below formula to calculate what I want but that is incorrect

source: Find Loan Amount using parameters ROI and Tenure

Here are the loan details,

Monthly EMI: 32530,

Loan tenure: 5 years,

Interest: 10.90

Total loan amount: ?

What is the formula to find the total loan amount?

What i have tried,

enter image description here

Here is the formula i have taken from the above source,

enter image description here

Here is the source

Assume Elliott-Halberstam conjecture, then prove a ANT inequality.

Posted: 12 Jun 2021 10:36 PM PDT

Here is Elliott-Halberstam conjecture.

$$ \sum_{q\leqslant x^{1-\varepsilon}}{\underset{y\leqslant x}{\max}\underset{\begin{array}{c} 1\leqslant a\leqslant q\\ \left( a,q \right) =1\\ \end{array}}{\max}\left| \psi \left( y,q,a \right) -\frac{y}{\varphi \left( q \right)} \right|\ll x}\log ^{-A}x $$

Then show $$ \sum_{2\leqslant p\leqslant x}{\tau _3\left( p-1 \right)}\ll x\log x $$

is true.

Here $$ \tau _3\left( x \right) =\sum_{d\left| x \right.}{d^3} $$

I tried several methods but I don't know how to apply the conjecture appropriately. Looking for hint or answer in detail.

How to write this sum $\sum_{m=0}^\infty (2m+1)^{-2k-1} \sum_{r=1}^\infty (-1)^{r-1} e^{-2(2m+1)r a} $ as a sum over single index?

Posted: 12 Jun 2021 10:48 PM PDT

So I want to write the sum $$\sum_{m=0}^\infty (2m+1)^{-2k-1} \sum_{r=1}^\infty (-1)^{r-1} e^{-2(2m+1)r a} $$ where $a>0$ and $k\in \mathbb{N}$, as a sum over single index which probably uses odd divisors of $(2m+1)\cdot r$.

However, I am quite confused about this method in general. I am trying to learn this concept. If anyone can help me with the logic, it will be highly appreciated.

Normalizing the columns of a matrix through matrix multiplications

Posted: 12 Jun 2021 10:26 PM PDT

Generally the normal equation is derived using a calculus-based approach of minimizing the least squares error. I'm trying to learn the linear algebra approach. My understanding so far is as follows:

Consider the standard linear regression problem: $Ab=y$ or $\sum_iA_{(i)}b^i=y$, where $A$ is an $m\times n$ matrix with $m>n$, and $A_{(i)}$ is the $i$-th column of $A$. Assuming $A$ to be full rank, its columns form a basis $C$ of an $n$-dimensional subspace of $\mathbb{R}^m$.

We already know the standard $\mathbb{R}^m$ basis representation of $y$ and we are trying to find its representation in the $C$ basis, such exact representation is possible to find only if $y\in\text{span}(C)$. Most likely $y$ won't lie in $\text{span}(C)$. In that case, the most natural alternative would be to find the $C$-representation of the next best thing - the projection of $y$ in $\text{span}(C)$. In other words, I need to find $$\hat b^i=\frac{\langle y,A_{(i)}\rangle}{\|A_{(i)}\|}$$ Now if only I had a matrix $\tilde A$ whose columns are the normalized versions of the columns of $A$, i.e., $\tilde A_{(i)}=A_{(i)}/\|A_{(i)}\|$, then I can just write $\hat b=\tilde A^Ty$. The question is: is it possible to get $\tilde A$ from multiplication/transpose/inverse operations performed on $A$?

What is the probability that at least two spinner land on Red

Posted: 12 Jun 2021 10:37 PM PDT

Three spinners are marked with equal amounts of Red, Blue and Yellow. At a particular instance, all three are spun together. What is the probability that at least two of the spinners land on red?

The at least part is confusing me.

My attempt: So if all three lands on red the probability will be: $P(All\space red)=\frac{1}{3}\times\frac{1}{3}\times\frac{1}{3}=\frac{1}{27}$ Having at least two will have a higher probability; two of the spinners should have red and the other can have any colour: $$P(Two\space red\space and\space one\space any)=\frac{1}{3}\times\frac{1}{3}\times\frac{3}{3}=\frac{1}{9}$$

How would you reduce the Tsiolkovsky Rocket Equation to one paragraph?

Posted: 12 Jun 2021 10:24 PM PDT

I'm working on a project where I must describe the Tsiolkovsky Rocket Equation in a short amount of time. As such, I will have to use only the vital parts of the equation and its usages.

Now, I have been researching non-stop (!) about the equation for the past week or so, and have a "sort of" grasp on what it entails. However, I am curious about what YOU all think of it. There could easily be vital points which I miss out on, which I would not want to do.

How would you reduce the rocket equation, or describe it, in just one sentence or paragraph?

(And don't worry, this isn't a text-based project. I won't plagiarize your explanations! ^^;)

I'm not sure if I should be asking this here or on the Physics stackexchange. But still, thank you all in advance! Very curious to see a paraphrased explanation of this rather large subject.

Is there a quartic or quintic formula?

Posted: 12 Jun 2021 10:53 PM PDT

I know about the quadratic formula, and the cubic formula, so I was wondering if there were any more. My teacher said there was no such thing as a quintic formula, so I was wondering that if there was no such thing as one, why.

Thank you.

Integral $\int^{x=\frac{\pi}{4}}_{x=0} \int^{y= \cos{x}}_{y=\sin{x}} dydx$

Posted: 12 Jun 2021 10:55 PM PDT

$$\int^{x=\frac{\pi}{4}}_{x=0} \int^{y= \cos{x}}_{y=\sin{x}} dydx$$

I got the answer $\sqrt{2} - 1 $ but my tutor got $8$? I assumed that I am starting with integrating $1 dydx$, that is how I got my answer.

Is my answer wrong?

Is the inequality $\sqrt{(2^r + 1)(t + 1)} \leq \min(2^r, t)$ false in general?

Posted: 12 Jun 2021 10:55 PM PDT

My question here is pretty basic:

Is the inequality $\sqrt{(2^r + 1)(t + 1)} \leq \min(2^r, t)$ false in general?

I tried asking WolframAlpha for its solutions, it says that no solutions exist.

I also tried asking WolframAlpha for the solutions to the closely related inequality $$\sqrt{(2^r + 1)(t + 1)} \leq \max(2^r, t),$$ it gave the following solutions: $$t \geq \frac{\sqrt{2^{2r} + 3 \times {2^{r+1}} + 5} + 2^r + 1}{2}$$ and $$-1 \leq t \leq \frac{-2^r + 2^{2r} - 1}{2^r + 1}.$$

Note that the first solution is for $t > 2^r$ (and therefore, $\max(2^r, t) = t$), and that the second solution is for $t < 2^r$ (and therefore, $\max(2^r, t) = 2^r$).

Finally, here is the inequality plot for $$\sqrt{(2^r + 1)(t + 1)} \leq \max(2^r, t):$$

enter image description here

What is the limit of $\frac{\sin 2x -2\sin x}{x^3}$ when $x$ tends to $0$?

Posted: 12 Jun 2021 10:51 PM PDT

$$\lim_{x\to 0} \frac{\sin2x -2\sin x}{x^3}$$ I am getting two values for this limit. Can anybody please share their solution so I can cross check my answers?

I see all your answers and yes, I have tried this method. Here is the other method I was talking about

$\lim_{x\to 0} \frac{\sin2x -2\sin x}{x^3}$ Using the formula $\lim_{x\to 0} \frac{\sin x}{x} = 1$ $\lim_{x\to 0} \frac{2}{x^2} - \frac{2}{x^2}$ Which gives the value 0

Definition of $\mathcal O_X$-derivation on scheme $X$ in Vakil

Posted: 12 Jun 2021 10:29 PM PDT

I'm reading Vakil's note about differential sheaf. Let $\pi:X\rightarrow Y$ be a morphism of schemes. He defines $d:\mathcal O_{X}\rightarrow \Omega_{X/Y}$ as follow.

Let $pr_1:X\times_YX\rightarrow X$ and $pr_2:X\times_YX\rightarrow X$ be projections. Then $d$ on open set $U$ is defined by $df = pr_2^*f - pr_1^*f$.

My question:

  1. I don't understand this definition. I think if $f\in\mathcal O_X(U)$, then $pr_1^*f$ is an element of $\mathcal O_{X\times_YX}(U\times_YX)$. But why $df = pr_2^*f - pr_1^*f$ gives an element in $\Omega_{X/Y}(U)$?

  2. How to see $d$ coincides with the Kahler differential module on affine open set? This is one of his exercises.

  3. I try to compute $\Omega_{X/Y}(U)$ for $U = Spec(A)$. Here is my attempt: $\Omega_{X/Y}(U) = \Delta^*(\mathcal I/\mathcal I^2)(Spec(A)) = (I/I^2)\otimes_{A\otimes A}A$ from the definition of pullback where $I^\sim = \mathcal I$. But it seems like the correct thing is $\Omega_{X/Y}(U) = I/I^2$. What's wrong with my computation?

Thank you in advance! enter image description here enter image description here

Clebsch-Gordan coefficients for the real spherical harmonics

Posted: 12 Jun 2021 10:47 PM PDT

There are many online calculators for the Clebsch-Gordan coefficients of the complex spherical harmonics, and many text books on quantum mechanics include tables of Clebsch-Gordan coefficients. I wonder about Clebsch-Gordan coefficients for the real spherical harmonics. Can they be related in some way to the coefficients for the complex spherical harmonics? If not, how can they be derived?

How to know if a system of equations of the form $ y_i = \sum_{j=0}^{n} c_j e^{jx_i}$ is solvable

Posted: 12 Jun 2021 10:55 PM PDT

I was working on a problem and faced a this system of equations ($y_i$ and $x_i$ are givens)

$$ y_i = \sum_{j=0}^{n} c_j e^{jx_i} \quad0 \le i \le n$$

is there a way to determine this system is solvable or not?

How to find the total loan amount borrowed? [closed]

Posted: 12 Jun 2021 10:26 PM PDT

I am working on the EMI calculator module as part of the current banking project. I find answers for calculating simple interest, EMI, and even tenure but not able to find a formula to calculate the total amount borrowed. I found the below formula to calculate what I want but that is incorrect

source: Find Loan Amount using parameters ROI and Tenure

Here are the loan details,

Monthly EMI: 32530,

Loan tenure: 5 years,

Interest: 10.90

Total loan amount: ?

What is the formula to find the total loan amount?

What i have tried,

enter preformatted text here

based on the formula, enter image description here

where 𝐴=EMI (monthly payment)𝑖=interest𝑚=type of installment (12 = monthly, 1 = annually)𝑡=tenure (time)

About the inequality $x^{x^{x^{x^{x^x}}}} \ge \frac12 x^2 + \frac12$

Posted: 12 Jun 2021 10:35 PM PDT

Problem: Let $x > 0$. Prove that $$x^{x^{x^{x^{x^x}}}} \ge \frac12 x^2 + \frac12.$$

Remark 1: The problem was posted on MSE (now closed).

Remark 2: I have a proof (see below). My proof is not nice. For example, we need to prove that $\frac{3x^2 - 3}{x^2 + 4x + 1} + \frac{12}{7} - \frac{24x^{17/12}}{7x^2 + 7} \le 0$ for all $0 < x < 1$ for which my proof is not nice.

I want to know if there are some nice proofs. Also, I want my proof reviewed for its correctness.

Any comments and solutions are welcome and appreciated.

My proof (sketch):

We split into cases:

i) $x \ge 1$:

Clearly, $x^{x^{x^{x^{x^x}}}}\ge x^x$. By Bernoulli's inequality, we have $x^x = (1 + (x - 1))^x \ge 1 + (x - 1)x = x^2 - x + 1 \ge \frac12 x^2 + \frac12$. The inequality is true.

ii) $0 < x < 1$:

It suffices to prove that $$x^{x^{x^{x^x}}}\ln x \ge \ln \frac{x^2 + 1}{2}$$ or $$x^{x^{x^{x^x}}} \le \frac{\ln \frac{x^2 + 1}{2}}{\ln x}$$ or $$x^{x^{x^x}}\ln x \le \ln \frac{\ln \frac{x^2 + 1}{2}}{\ln x}$$ or $$x^{x^{x^x}}\ge \frac{1}{\ln x}\ln \frac{\ln \frac{x^2 + 1}{2}}{\ln x}.$$

It suffices to prove that $$x^{x^{x^x}}\ge \frac{7}{12} \ge \frac{1}{\ln x}\ln \frac{\ln \frac{x^2 + 1}{2}}{\ln x}. \tag{1}$$

First, it is easy to prove that $$x^x \ge \mathrm{e}^{-1/\mathrm{e}} \ge \frac{1}{\ln x}\ln\frac{\ln\frac{7}{12}}{\ln x}.$$ Thus, the left inequality in (1) is true.

Second, let $f(x) = x^{7/12}\ln x - \ln \frac{x^2 + 1}{2}$. We have \begin{align*} f'(x) &= \frac{7}{12x^{5/12}} \left(\ln x + \frac{12}{7} - \frac{24x^{17/12}}{7x^2 + 7}\right)\\ &\le \frac{7}{12x^{5/12}} \left(\frac{3x^2 - 3}{x^2 + 4x + 1} + \frac{12}{7} - \frac{24x^{17/12}}{7x^2 + 7}\right)\\ &\le 0 \tag{2} \end{align*} where we have used $\ln x \le \frac{3x^2 - 3}{x^2 + 4x + 1}$ for all $x$ in $(0, 1]$. Also, $f(1) = 0$. Thus, $f(x) \ge 0$ for all $x$ in $(0, 1)$. Thus, the right inequality in (1) is true.
Note: For the inequality $\frac{3x^2 - 3}{x^2 + 4x + 1} + \frac{12}{7} - \frac{24x^{17/12}}{7x^2 + 7} \le 0$ for all $0 < x < 1$, we let $x = y^{12}$ and it suffices to prove that $11y^{47} + \cdots + 3 \ge 0$ (a polynomial of degree $47$, a long expression) for all $0 < y < 1$.

We are done.

Geometric progression question. Year less?

Posted: 12 Jun 2021 10:13 PM PDT

Here is the math question.

A 100m cliff erodes by 2/7 of its height each year.

(a) What will the height of the cliff be after 10 years?

This is how I worked out the question.

100*(5/7)^10  

Which is 3.46m to 2d.p.

However my teacher said that it is wrong (to the whole class and also insulted me a bit >_>) and that I didn't follow this formula.

Tn = ar^(n-1)  

And that I should have done

100(5/7)^9  

Which is instead 4.84m to 2d.p.


This doesn't make sense because if you used the formula and the question was

What will the height of the cliff be after 1 year?

 100(5/7)^(1-1)  =100(5/7)^0  =100  

That doesn't make sense at all!

Am I right or is the teacher right?

ADDITIONALLY my teacher said his answer is an interpretation of the question. Is his answer a valid interpretation of this question? Or is it just incorrect mathematics?


BTW Also my teacher said my answer has no common sense and that I won't be able to do the HSC well if I keep reading questions wrong.

Closed form for CRT solution using Euler $\phi\,$ (totient)

Posted: 12 Jun 2021 10:42 PM PDT

Can anyone show some hints to this? If $\gcd(a,b)=1$, then $a^{\phi(b)}+b^{\phi(a)}=1 \pmod{ab}$. I know that $a^{\phi(b)}=1 \pmod{b}$, and similarly, $b^{\phi(a)}=1 \pmod{a}$, but then how do I combine the work so that I get the result I need? Thanks!

If $\gcd(a,b) = 1$ and $a,b\mid x$ then $ab\mid x$.

Posted: 12 Jun 2021 10:41 PM PDT

If $\gcd(a,b) = 1$ and $a,b\mid x$ then $ab\mid x$.

My attempt at answering the question:

\begin{align*} x &\equiv 0 \pmod{a}\\\ &\Longrightarrow x\text{ is divisible by $a$}\\\ &\Longrightarrow x = ma\text{ for some integer $m$}\\\ \ \\\ x &\equiv 0 \pmod{b}\\\ &\Longrightarrow x\text{ is divisible by $b$}\\\ &\Longrightarrow x = mb\text{ for some integer $m$}\\\ \ \\\ x^2 &= (ma)(mb)\\\ x^2 &= (m^2)(ab)\\\ x &= \sqrt{m^2ab}\\\ x &= m\sqrt{a}\sqrt{b} \end{align*} Let $m$ be $k\sqrt{a}\sqrt{b}$. Then \begin{align*} x &= kab\\\ &\Longrightarrow x \equiv 0 \pmod{ab} \end{align*}

Is this correct, if not can someone point me in the right direction?

OSCHINA 社区最新专区文章

Posted: 12 Jun 2021 10:39 PM PDT

OSCHINA 社区最新专区文章


Linux 上的 RISC-V 将支持 Transparent Hugepages

Posted: 12 Jun 2021 05:19 PM PDT

根据最新的提交显示,Linux 内核的 RISC-V 即将获得 Transparent Hugepages(THP)支持。 Linux 内核的 RISC-V 继最近添加原地执行 XIP、对 KProbes 和其他功能的支持以及硬件特定工作如 SiFive FU740 SoC 支持后,由华为工程师提供的 Transparent Hugepages 支持现在也已准备就绪。 Transparent Hugepages 是 Linux 的内...

Nvidia 计划停止支持 Windows7 和 Windows 8/8.1

Posted: 12 Jun 2021 04:32 PM PDT

根据 Nvidia 的最新公告显示,其已经计划结束对 Windows7 和 Windows 8/8.1的支持。 Windows 7 已经推出超过 11 年了,在其 12 周年纪念日之前,显卡生产商 Nvidia 将停止支持这个老化的操作系统。一份针对 Windows 7 和 Windows 8/8.1的支持计划显示,从 2021 年 10 月开始,Game Ready Driver 的升级,包括性能增强、新...

KDE Frameworks 5.83.0 发布

Posted: 12 Jun 2021 04:09 PM PDT

KDE Frameworks 5.80.0 已正式发布。KDE Frameworks 是 Qt 的 83 个附加库,它在成熟的、经过同行评审和测试的库中提供了各种常见的功能,并且具有友好的许可条款。 主要更新内容 Baloo 在 KIOSlaves 中嵌入 JSON 元数据 将协议文件转换为 JSON [balooctl] 允许清除已删除的文档 BluezQt 将缺少的 Qt5::DBus 添加到 qml ...

Apache Jackrabbit 2.20.3 发布,可扩展、高性能分层存储库

Posted: 12 Jun 2021 03:59 PM PDT

Apache Jackrabbit 2.20.3 发布了。Jackrabbit Oak 是一种可扩展的高性能分层内容存储库,旨在用作现代世界级网站和其它要求苛刻的内容应用程序的基础。 主要更新内容 webdav:检查 PUT 上的 Content-Range 增加测试覆盖率,以恢复删除混合器的功能 将 Commons VFS 升级到 2.6 将 Jackrabbit 树干更新为 Oak 1.36.0 更新...

Recent Questions - English Language & Usage Stack Exchange

Posted: 12 Jun 2021 06:37 PM PDT

Recent Questions - English Language & Usage Stack Exchange


"If you or your mother need help" or "If you or your mother needs help"? [duplicate]

Posted: 12 Jun 2021 03:54 PM PDT

I've been stuck on this for quite some time and my mind's foggy because of the overthinking.

I would like to check which of these are correct:

  1. If you or your mother need help...
  2. If you or your mother needs help...
  3. If you or your partner is experiencing...
  4. If you or your partner are experiencing...

#1 and #3 sound the most "natural" to me. But according to grammar rules, when "or" is concerned, the verb in the sentence should be singular, as per the last noun. Taking this into consideration, #1 would technically be wrong.

I think the use of "you" is throwing me off. Things seem to be more straightforward when inanimate objects are concerned. For example:

  • If your laptop or computer shuts down without warning...
  • If your pillow or mattress is causing discomfort...

Word that means using a falsehood which can be used as a weapon to advocate for and execute something else

Posted: 12 Jun 2021 03:33 PM PDT

What is a word that means using a falsehood which can be used as a means, as a weapon to advocate for and execute something else

The politician claimed that the government budget had a deficit to defend cuts in welfare and local services like libraries and nurseries. However this deficit did not exist so the politician was being ______

Guinness adverts once claimed that guinness is good for you and will help you be alert if you're driving, studying or doing manual labour. This made it marketed as a health drink which then could be an means to sell it in gyms.

Kyle claimed that his bank account was overdrawn and that he didn't want to receive a daily overdraft fee, which then allowed him to borrow £200 which he otherwise would not of been lent the money if he had been honest about his financial situation. This lie made meant he was ________

Noun for a deep person that always speaks in lots of idiomatic expressions or quotes [closed]

Posted: 12 Jun 2021 01:52 PM PDT

What are the nouns or synonyms for a deeply intellectual person, that always speaks in idiomatic expressions or quotes or phrases.

A person like Panos Panay.

Looking for two synonyms for success/failure which rhyme

Posted: 12 Jun 2021 03:17 PM PDT

I'm looking for two words with the following conditions:

  1. Word A is a synonym of "success" (or is the word "success").
  2. Word B is a synonym of "failure" (or is the word "failure").
  3. Words A and B rhyme.
  4. Words A and B are antonyms (note: you can probably ignore this requirement since I'm pretty sure condition 1 & 2 all but guarantee this condition.)

It might be easier to explain with a hypothetical example… imagine the English language contained the word:

Pizaster | Noun

  • great success

We could then have the solution "Pizaster/Disaster" since they satisfy all 4 conditions: Pizaster means success, disaster means failure, they both rhyme, they are both antonyms.

Unfortunately (or rather fortunately) I can't just add words to the English language like this, so I'm looking for an existing pair of words that actually exist.

If there's nothing that's a perfect synonym for success/failure but still captures the same essence of good/bad, I'll still accept it as an answer. Also the final solution could totally have the word "success" or "failure" in it as well (e.g. if there is already a word which means failure and rhymes with success, then we could have the solution success + this word you're thinking of)

Difference between inculpate and incriminate?

Posted: 12 Jun 2021 12:53 PM PDT

While they appear to have the same meaning, is there an actual difference between the two words?

Are there situations where one is preferred over the other?

Humble v. Humility [closed]

Posted: 12 Jun 2021 12:09 PM PDT

Are "humble" and "humility" from the same root word?

If so, I found it odd that the "b" was dropped from "humility." Not sure if "humbility" looks right either, but was wondering if there's some rule dictating that the "b" would be dropped here in the spelling of "humility."

Five children and it novel.= [closed]

Posted: 12 Jun 2021 11:50 AM PDT

The keeper felt pleased with himself, and owned himself a bold man when he threw open that door>

What does it mean "And owned himself a bold man"

How do you call it when someone makes faces while trying to remember something

Posted: 12 Jun 2021 04:51 PM PDT

I'm writing a book, and I'm trying to describe that the girl is making faces as she's trying to remember something. I'm not quite sure how to describe that. (Seen from the point of view of another character in the book.)

So far, I've got this, but I think my sentence doesn't make sense.

She was trying to remember where she'd seen my aunt. She was making faces while thinking, which made her look so cute.

I thought about "grimaces" but that's not it, since grimace is usually in disgust or disapproval.

Why is the word "pockets" used when referring to certain sections of places in a large area?

Posted: 12 Jun 2021 04:13 PM PDT

Recently, I was reading about something related to geography. And then, I came across the word "pockets" which actually refer to some small areas in a larger area.

But can anyone tell me, why is the word "pockets" used when referring to certain sections of places in a large area.

Word for a person who interprets everything to their advantage

Posted: 12 Jun 2021 04:14 PM PDT

Is there a word for a person (or an attribute to describe a person) who habitually interprets facts and words in such a way that their interpretation proves their argument is correct while others wrong. In other words, a term for a person (or an attribute for a person) who always makes the most self-serving interpretation of the facts to benefit themselves the most.

Example of such person:

  • Politicians who always interpret facts to prove they are correct and to prove that the opposition are not.
  • In quarrels (say between two partners, not just legal quarrels, but say between husband and wife), one may keep saying that opposition's interpretations of facts are wrong and provide his / her version of interpretations (interpretations which will comforts him / proves opposition wrong and him / her correct).

What is the origin of "set" (noun) as used in "television set"? Tubes?

Posted: 12 Jun 2021 05:06 PM PDT

The colloquial (and mostly archaic) term "television set" invokes a narrow use of set (noun). Merriam-Webster defines this as:

(22) an apparatus of electronic components assembled so as to function as a unit

(With "television set" being the only example)

The Cambridge Dictionary offers an even more narrow definition, where set has the specific meaning of "television set".

I am wondering what the etymology of this term is here, and I have a guess: I believe that because televisions--and radios before them-- were constructed principally using a set of vacuum tubes that the set is a sort of metonym.

"Radio set" is easily found as a common term in historic text back when radios were larger standalone devices, or in the context of CB or ham radio, both of which grew from vacuum-tube-based equipment.

And I observe that contra the Merriam-Webster definition, no other kind of "apparatus" I can think of gets this shorthand. We don't speak of a toaster set or a dishwasher set or a personal computer set. The only examples I know of are devices that originated with sets of vacuum tubes.

Maybe I'm overthinking this. Can anyone enlighten the tracing of etymology there? Why are (were) televisions known as television sets?

The "as done by/ through" construction confused me a lot

Posted: 12 Jun 2021 02:02 PM PDT

All these sentences with "as done..." format have been confused me because why not just omitted "as" in these sentences?

Mr. Miller has said he does not support a mandated federal test but does favor public reports on how college students are learning as measured through testing.

The New York Times

It seems to me that "...how college students are learning measured through testing" is enough to express the meaning of it, and it meets my perception of English grammar. Why is there an as?

With his wife he went to Mexico to sample psychedelics at their practical source, as administered by the curanderos and curanderas of the Sierra Mazateca. The New York Times - Magazine

"With his wife he went to Mexico to sample psychedelics administered by the curanderos and curanderas of the Sierra Mazateca at their practical source."Can this sentence be written like this? It seems to me it's a structure used to put clause used to moderate objective in end of the sentence, with an "as" leading the clause.

And the Transportation Department would set new vehicle mileage standards as required by Congress.
The New York Times

We could've just make the sentence "...new vehicle mileage standards required by Congress". Could haven't we?

Why the "oo" in "noon" is pronounced sounding like "you" while the word "moon" isn't? [closed]

Posted: 12 Jun 2021 09:41 AM PDT

I was taught to pronounce the oo in either afternoon or noon as /u:/ ~~the oo in nook~~ until I found some native speakers pronounce the noon sounding like new-n (videos). But the AmE IPA in the dictionary labels it as /nu:n/, instead of what I thought it as /nju:n/ if it's pronounced new-n. To my surprise, the IPA of new is /nu:/ rather than /nju:/. If /u:/ is equivalent to /ju:/, so why the word moon, whose IPA is /mu:n/, is not pronounced as mew-n?

Where does "Whatcha" & "Didja" come from?

Posted: 12 Jun 2021 09:34 AM PDT

Does anyone know where "Whatcha" and/or "Didja" originate from?

Watcha: What did you? Didja: Did you?

Edit: I cannot find these words in my English Grammar books and they are not in my English dictionaries. I don't know enough about them to even ask sensible questions. I myself use them. Yet, when asked about them by a non-native English speaker, I found myself clueless as to why English dropped the word "you" for a sound that had no resemblance to the word "you".

How to understand the meaning of "in which" and "on which" when seeing them standing at the beginning of questions?

Posted: 12 Jun 2021 12:01 PM PDT

I'm doing an IELTS listening sample test and finding confused when seeing two questions below:

In which two ways are the lines distinguished from each other?  On which forms of transport can a one-day travel card be used?  

I'm still confused about them. I'm hopeful that you guys can give me a clear explanation of my problems. Thanks you guys a lot.

"more massive"?

Posted: 12 Jun 2021 03:00 PM PDT

I stumbled upon this sentence in Wikipedia:

Titan is 50% larger than Earth's moon and 80% more massive.

I struggle with the "more massive" part. I find some books do use that phrase. Is it correct, pedantically? Do you recommend using it? Do you use it oftentimes, especially if you are an astronomer?

Which one do you prefer: "more massive" or "more in mass" or just "heavier"? Any other alternative is welcome.

Correct use of adjectival forms for countries

Posted: 12 Jun 2021 11:05 AM PDT

I sometimes proofread documents for my (Dutch) supervisor. When he refers to something that comes from the Netherlands he would, for example, write: the Netherlands windmills as opposed to the Dutch windmills. I have sometimes seen this weird form written elsewhere, but I was wondering if this is really a correct way of saying this.

The spelling "ui" and the pronunciation /uː/ in juice, fruit, bruise, cruise, sluice, suit, nuisance, recruit, bruit

Posted: 12 Jun 2021 09:42 AM PDT

The words juice, fruit, bruise, cruise, sluice, suit, pursuit, suitcase, lawsuit, nuisance, recruit, bruit are spelled with ui and pronounced with the IPA phoneme /uː/.

Full pronunciations from OED:

nuisance: Brit. /ˈnjuːsns/, U.S. /ˈn(j)us(ə)ns/
juice:         Brit. /dʒuːs/, U.S. /dʒus/
cruise:      Brit. /kruːz/, U.S. /kruz/
bruise:      Brit. /bruːz/, U.S. /bruz/
suit:           Brit. /s(j)uːt/, U.S. /sut/
recruit:     Brit. /rᵻˈkruːt/, U.S. /rəˈkrut/, /riˈkrut/
fruit:         Brit. /fruːt/, U.S. /frut/
sluice:       Brit. /sluːs/, U.S. /slus/
bruit:        Brit. /bruːt/, U.S. /brut/ (In sense 5 also) Brit. /ˈbruːi/, U.S. /ˈbrui/

The pronunciation differs from some other similar words spelled with ui like guise, disguise, guide, cuisine, suicide.

Full pronunciations from OED:

guide:       Brit. /ɡʌɪd/, U.S. /ɡaɪd/
guise:       Brit. /ɡʌɪz/, U.S. /ɡaɪz/
cuisine:   /kwiːˈziːn/
suicide:   /ˈs(j)uːɪsʌɪd/

Ruin is kind of an exception to an exception because the pronunciation is different in British English and American English:

Full pronunciations from OED:

ruin: Brit. /ˈruːɪn/, U.S. /ˈruən/, /ˈruˌɪn/

Note: There can be other similar words I might have missed and there can be dialectal/regional differences also.

When I checked the etymology of the word sluice in OED, I found this note:

The spelling with ui (compare juice) did not come into general use until the 18th century.

In fact, when you check the older (pre-1600s) spellings of the word sluice in OED, you can see that it is mostly spelled with u instead of ui. (Of course, there are other irregular spellings also). In OED, the first citation where the word is spelled with ui is from 1611. The word is written as sluice which is same as today and the citation is from Randle Cotgrave · A dictionarie of the French and English tongues · 1st edition.

In OED, the etymology of the word doesn't mention the ui spelling also (except the current Dutch word sluis):

< Old French escluse (-clusse , -clouse , etc.; modern French écluse ), = Spanish esclusa , Portuguese esclusa , late and medieval Latin exclusa (also sclusa , etc.), feminine singular of Latin exclūsus , past participle of exclūdere to shut out, exclude v.
Old French is also the source of Middle Dutch sluse , sluyse , sluus (Dutch sluis , West Frisian slús ), Middle Low German sluse , sluze (Low German slüse , slüs , German schleuse ), Danish sluse , Swedish slus . For the English forms which represent the late Latin clūsa see clow n.1

Historical spellings of sluice from OED:

α.
1340: scluse
1449: Scluces
c1480: scluse
1558: sklus
1583: scluse
1609: scluces
1665 : Scluse
β.
1533: slewssis
1541–2: sloweses
1582: sleuss
?1677: slewces
γ.
1538: sluse
1568: slus
1577: Sluse
1611: sluce
1648: Sluses
1695: Sluces
δ.
1596: Sluyce
1611: Sluice
1699: sluice
1745: Sluices
1785: sluices
1839: sluice
1879: sluices
1794: sluices

You can see a similar pattern for juice, bruise and somewhat cruise also.

In OED, the first citation where juice is spelled as today is from a1626.

Etymology of juice from OED:

< French jus, < Latin jūs broth, sauce, juice of animal or plant. The β forms are normal from French; with the others compare those of duke, flute, jupe, and bruit, fruit.

OED has the note below in the etymology of cruise:

The word is thus ultimately identical with croise v. and cross v.; the current spelling with ui seems to be after Dutch; but the vowel sound is as in Spanish and Portuguese.

Although there isn't an exact pattern, the historical spelling change pattern explained above differs in the words like suit, fruit, recruit but the question and the answer might cover them also. The words in the question is mostly the ones where it has the ui spelling followed by ce and se.

After all these historical notes, what is the question?

Why was ui spelling introduced in words that used to be spelled with u and where the pronunciation is with IPA phoneme /uː/?

Why did it become more prevalent after 18th century?

Note: I know that historical "why" questions are hard to answer. English has a lot of irregularities and changes throughout the history also. There isn't an exact pattern or rule in spelling and orthography; but the spelling is mostly fixed in the traditional orthography.

  • The answer might be related to the English spelling reforms or how Dutch influenced the spelling of the words in these reforms or in the history.
  • Or is there any influential person or publication that might have affected these spellings?
  • Or might the spelling of the word fruit or any other word have influenced the words like juice, sluice? Fruit is an older word but it has historical spellings like frut and the first citation with fruit is from 1549 in OED.
  • Was there a need or a proposition of indicating longer u sound in the spelling reforms?

Replacing "When" With "For / Since" In A Question?

Posted: 12 Jun 2021 04:08 PM PDT

Does "for" or "since" work in place of "when" in this sentence?

Why do you keep buying plants when you just end up killing them?

If not, why?

Thank you.

Do Americans pronounce "transient" as \ˈtran(t)-sh(ē-)ənt\?

Posted: 12 Jun 2021 09:41 AM PDT

Merriam-Webster pronounces "transient" as \ˈtran(t)-sh(ē-)ənt\.

However, most Americans pronounce it as \ˈtran-zē-ənt\.

Is the pronunciation difference between “BrE deuce” vs “AmE deuce” systematic?

Posted: 12 Jun 2021 09:35 AM PDT

While checking the exact pronunciation of the term deuce, I noticed that there is a clear difference between BrE /djuːs/ and NAmE /duːs/.

While it is true that pronunciation has more exceptions than set rules, I'm surprised by the missing "e" (/j/) in the AmE version.

Is it just another exception, or are there other similar examples that might suggest a sort of pattern for similar clusters of letters?

What do people mean by "measurable definition?"

Posted: 12 Jun 2021 01:06 PM PDT

What is the definition of "measurable definition?" What does that mean? I have interns who are victims of verbose, academic language, and they frequently use terms that I don't think they even understand.

In an online pdf titled "A Measurable Definition of Resiliency Using 'Mission Risk' as a Metric" I read this in the abstract, "Part of the problem...lacks a clear definition that supports measurable metrics that would allow two like systems to be compared against each other."

It seems there is no such thing as a "measurable definition," rather there is a phenomenon that can be defined and measured.

Why does Tom Hanks pronounce "stupid" as "st-you-pid" in "The Bonfire of the Vanities"?

Posted: 12 Jun 2021 09:34 AM PDT

This may or may not related to my previous question. In this movie (which is based on another one of Tom Wolfe's novels, The Bonfire of the Vanities), Tom Hanks plays the lead character who is an Ivy League graduate. He doesn't make much of an effort to imitate any of the Harvard, Yale, or Princeton speech patterns and tones, but he does insist on pronouncing the word "stupid" as "styoopid." Why? Where do they speak like that?

enter image description here

He's not trying to copy or parody the so-called Mid-Atlantic accent: one, it was already out of vogue in the 1990's, and, two, that's not how Mid-Atlantic sounds, anyway. What is he doing? What point is he trying to get across?

“kinda”, “sorta”, “coulda”, “shoulda”, “lotta”, “oughta”, “betcha”, "tseasy" etc. What are these?

Posted: 12 Jun 2021 09:43 AM PDT

In linguistics, is there a term describing this phenomenon, i.e., when the syllables of two words are slurred together in the spoken language? They are not contractions. While contractions are acceptable in any register, this combination of words is very informal and hardly ever found in formal writing.

kinda (kind of)

sorta (sort of)

coulda (could have)

shoulda (should have)

lotta (lot of)

oughta (ought to)

betcha (bet you)

lemme (let me)

tseasy (it's easy)

willya (will you)

Inasmuch as English Language speakers (just like the speakers of any natural language) have a tendency to join word sounds in speech, examples abound and a complete list would be hard to produce .

I'm looking for a word or phrase describing this linguistic phenomenon as it occurs in speech.

Why the does 'tu' get pronounced 'tyu' in British English?

Posted: 12 Jun 2021 09:36 AM PDT

Despite being a native Brit, I've always found it an oddity that words like "tutor", "tube", "tumour", and "duty" are pronounced as "tyutor", "tyube", "tyumour", and "duty" in British English. For me, this doesn't seem phonologically simpler/easier at all, and given that it seems to be absent in American English (possibly other forms of English too?) for these sorts of words (beginning with "tu" or "du"), I would suppose it's a somewhat recent innovation in historical linguistic terems, almost surely after the Middle English period. So that's my first question: when and where did this pronunciation originate, and as a bonus, why?

Now, there are certain words that have this "y" sound inserted even in American and other forms of English, though I can't think of any where it's inserted in the "tu" or "du" sound. e.g. "beautiful", "cute", "futile". Notably, this pronunciation seems much more natural to me in these cases, unlike in the "tu" and "du" cases. Of course, the pronunciation of these words in the original Latin (or even the intermediary French when applicable) suggests that this innovation happened within English, and most likely within England itself. (N.B. I can't think of any Anglo-Saxon words with this mode of pronunciation right now, but quite possibly there are some too.) So, my second question is: is there some clear linguistic/phonological reason why the insertion of the 'y' sound is more natural in the non-"tu"/"du" cases, and did this phenomenon originate earlier in the English language?

Are what-cha and arent-cha examples of elision?

Posted: 12 Jun 2021 09:38 AM PDT

Are these words examples of elision? What effect do they create? If a child says them what does this suggest about their language development? Thanks for any help!!

What is the name of the phoneme produced in an upper-class Briton's pronunciation of the word "Duke"? What's different in the articulation?

Posted: 12 Jun 2021 09:40 AM PDT

When someone with a Received Pronunciation accent pronounces the word duke, as in The Duke of York, he doesn't pronounce it with a "hard" 'd', as one might pronounce the word duh, but a softer type 'd', which I can only spell phonetically as "dj", so as to pronounce duke somewhat like "djuke."

My question is composed of two parts:

  • What would a linguist call this phoneme?
  • What is the difference in articulation between it and a "regular" /d/?

How do you pronounce 'news'?

Posted: 12 Jun 2021 09:35 AM PDT

My coworker and I have been having this discussion for a day or two...

What is the most correct way to pronounce 'new' or 'news' ?

Does it rhyme with 'few' ? or 'snooze' ?

Does 'new crew' rhyme?

I know both 'noo' and 'nyoo' are correct, but what are the origins of the two different pronunciations?

Asking around the office, it seems that 'nyoo' might have a British English origin, but I would like to know if anyone is more knowledgeable on this topic.

OSCHINA 社区最新讨论话题

Posted: 12 Jun 2021 06:05 PM PDT

OSCHINA 社区最新讨论话题


docker stack很好用,为什么K8S流行起来了

Posted: 12 Jun 2021 08:43 AM PDT

一直使用docker做部署,最近用了下docker stack的集群部署方案,感觉也挺方便,那为什么K8S反而兴起了呢?(哦,对了还有一个疑问,docker的副本,在一台机器多个副本,到底是怎么解决端口冲突和容器挂载冲突的,这么多个副本,都要用80端口,为什么不冲突了,网上找不到资料,想不通。) 还有K8S宣布后面不支持docker,...

OSCHINA 社区最新专区文章

Posted: 12 Jun 2021 01:53 PM PDT

OSCHINA 社区最新专区文章


docker stack很好用,为什么K8S流行起来了

Posted: 12 Jun 2021 08:43 AM PDT

一直使用docker做部署,最近用了下docker stack的集群部署方案,感觉也挺方便,那为什么K8S反而兴起了呢?(哦,对了还有一个疑问,docker的副本,在一台机器多个副本,到底是怎么解决端口冲突和容器挂载冲突的,这么多个副本,都要用80端口,为什么不冲突了,网上找不到资料,想不通。) 还有K8S宣布后面不支持docker,...

Apache Druid 0.21.1 发布,实时分析数据库

Posted: 11 Jun 2021 04:08 PM PDT

Apache Druid 0.21.1 发布了。Druid 是一个分布式的、支持实时多维 OLAP 分析的数据处理系统。它既支持高速的数据实时摄入处理,也支持实时且灵活的多维数据分析查询。因此 Druid 最常用的场景就是大数据背景下、灵活快速的多维 OLAP 分析。 另外,Druid 还有一个关键的特点:它支持根据时间戳对数据进行预聚合摄入和聚合...

FreeFileSync 11.11 发布,文件夹比较与同步软件

Posted: 11 Jun 2021 04:00 PM PDT

FreeFileSync 11.11 现已发布。FreeFileSync 是一款开源软件,适用于 Windows、macOS 和 Linux。FreeFileSync 本质是一个用于文件夹对比和同步的软件,它可以创建和管理所有重要文件的备份副本。FreeFileSync 不是每次都复制每个文件,而是确定源文件夹和目标文件夹之间的差异,并只传输所需的最低数据量。 主要更新内容...

Apache PDFBox 2.0.24 发布,Java 的 PDF 处理类库

Posted: 11 Jun 2021 03:52 PM PDT

Apache PDFBox 2.0.24 已经发布。Apache PDFBox 库是一个开源的用于处理 PDF 文档的 Java 工具。 主要更新内容 对特定的 PDF 文件渲染缓慢 在 PageDrawer.shadingFill上 的渲染非常缓慢 渲染中丢失字形 对 JPEG 图像的错误分类导致在 pdf 文档中添加空白图像 嵌入文件不能从具有多级 EmbeddedFiles 树的 PDF 文件中提取出...

OSCHINA 社区最新专区文章

Posted: 12 Jun 2021 10:51 AM PDT

OSCHINA 社区最新专区文章


微软表示将在 2025 年停止支持 Windows 10

Posted: 11 Jun 2021 04:14 PM PDT

就在各方都围绕着"微软即将推出下一代 Windows 操作系统"的相关信息讨论得热火朝天之际,微软官方又在此基础上进行了一把火上浇油。根据 Windows 10 家庭版和专业版生命周期页面显示,微软计划于 2025 年 10 月 14 日结束 Windows 10 的支持工作。 官方页面顶部标记为"Important"的横幅指出:"微软将继续支持至少一...

Taro 3.2.11 发布,BAT 小程序、H5 与 RN 端统一框架

Posted: 11 Jun 2021 04:09 PM PDT

Taro 3.2.11 发布了。Taro 是一个开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5 等应用。此版本更新内容包括: 特性 小程序 支持小程序独立分包 补全微信小程序 Textarea 的属性 RN rn 启动支持动态传入参数,跳转指定页面 app 配置增加透传react-navig...

Vivaldi 4.0 发布,引入了翻译、邮件、日历和 RSS 阅读器功能

Posted: 11 Jun 2021 04:07 PM PDT

Vivaldi Technologies 近日发布了旗下浏览器 Vivaldi 4.0 大版本更新。新版本引入了 Vivaldi Translate,一个保护隐私的翻译功能;以及用户期待已久的 Vivaldi 邮件客户端、日历和 RSS 阅读器的测试版本。 Vivaldi 翻译 Vivaldi Translate 是对网络浏览器的一个重要补充。它是一个内置的翻译功能,该技术由 Lingvanex 提...

FreeFileSync 11.11 发布,文件夹比较与同步软件

Posted: 11 Jun 2021 04:00 PM PDT

FreeFileSync 11.11 现已发布。FreeFileSync 是一款开源软件,适用于 Windows、macOS 和 Linux。FreeFileSync 本质是一个用于文件夹对比和同步的软件,它可以创建和管理所有重要文件的备份副本。FreeFileSync 不是每次都复制每个文件,而是确定源文件夹和目标文件夹之间的差异,并只传输所需的最低数据量。 主要更新内容...

Apache PDFBox 2.0.24 发布,Java 的 PDF 处理类库

Posted: 11 Jun 2021 03:52 PM PDT

Apache PDFBox 2.0.24 已经发布。Apache PDFBox 库是一个开源的用于处理 PDF 文档的 Java 工具。 主要更新内容 对特定的 PDF 文件渲染缓慢 在 PageDrawer.shadingFill上 的渲染非常缓慢 渲染中丢失字形 对 JPEG 图像的错误分类导致在 pdf 文档中添加空白图像 嵌入文件不能从具有多级 EmbeddedFiles 树的 PDF 文件中提取出...

CKEditor 5 v28.0.0 发布,修订历史功能上线

Posted: 11 Jun 2021 03:43 PM PDT

CKEditor 5 v28.0.0 已经发布。这是一个顶级的文档版本管理工具,允许用户完全控制编辑过程。该版本带来了期待已久的修订历史功能,允许用户完全控制编辑过程,扩展了表格功能,并且支持标题以及默认的表格和表格单元格样式。此外还包括一些错误修复。 修订历史 这个新功能可以维护完整的文档修订历史记录。它可以让编辑...

V2EX - 技术

Posted: 12 Jun 2021 10:32 AM PDT

V2EX - 技术


小程序开发用什么框架好?

Posted: 12 Jun 2021 10:13 AM PDT

我司之前做了款 CRM 现在打算开发移动版本,老板相中的方案是做小程序,主要针对的平台是钉钉和企业微信,想问下现在开发小程序用哪个框架比较好,请描述下真实感受和所遇到的坑。

我个人目前比较倾向于 taro, 原因是名字看起来简洁有力。顺便问一下如果开发手机版本的话大家会考虑什么方案呢,原生的 Android/iOS 还是 flutter ?

复杂的 Python 目录规范

Posted: 12 Jun 2021 09:18 AM PDT

想知道 Python 有没有具体的比较复杂的目录规范
Google 上大致翻了一下,基本都是比较简单的那种。
平时用的大概文件夹名大概有:
一级:bin,data,src
二级:api,db,lib,utils
三级:具体的模块

另外想问如果和前端(TypeScript)合作是否合适放在一个仓库内,怎么放比较合适。

高中生勿喷,感谢。

关于接口返回值设计问题:服务之间内部调用接口的返回值类型需不需要跟客户端接口保持一致?

Posted: 12 Jun 2021 09:12 AM PDT

现在盛行微服务,有些接口是仅供服务之间内部调用的,有些接口是提供给客户端的,那么问题来了,这两种类型的接口返回值类型需要保持一致吗?你们是怎么设计的?


我为什么会有这么疑问呢,因为我在实际开发中发现,如果返回值类型保持一致的话会有一些不方便的地方,比如,客户端接口的返回值一般会有 code,它的值可能会是 200,404,400,500 等等,但服务之间内部调用接口根本不关注这个,只需返回对象里有个布尔类型的变量告诉我调用其他服务到底成功与否就行了,鉴于此,是否可以设计出两种返回值类型?

protobuf gRPC 这种写配置文件生成代码的形式 "流行"的原因是什么?

Posted: 12 Jun 2021 08:44 AM PDT

再比如 mybatis 用 xml 写 sql.
在比如 spring 初期用 xml 做 IOC...
诸如此类. 这么做的目的是什么?

作为一个 python 程序员不是很习惯.


第二个问题是, 为什么讲 go 和 node 什么的 从 gRPC 里面扯出去新搞了一个仓库.
类似的还有 protoc vs protobuf-gen-go


谢谢大佬们.

如何优雅的停止正在处理队列消息的 worker 呢?

Posted: 12 Jun 2021 08:41 AM PDT

一个发送消息的源头服务器,一个队列,两个 worker 。worker 从队列中拿消息进行处理,处理过程中可能会因为数据源出现了更新,因此 worker 需要停止当前的处理并退出。请问有什么设计模式可以应用的吗?技术栈是 Redis (queue)、worker 是 Node 写的。

我目前想到的一个很笨的方法是还是用将正在处理的任务状态存在 Redis 中,当 worker 开始的时候,将这个 taskId:state 键值对的 state 值改成 processing,如果发送消息的源头出现了数据更新,则源头服务器更新 Redis 中的任务状态为 cancel,worker 处理数据其实是个大 loop,所以每次 loop 的时候先检查任务的 state,如果发现是 cancel 了,那就退出 loop 即退出处理。

又或者用 Redis 的 pubsub ?源头服务推送 cancel 的消息,worker 作为 sub 监听,如果碰到 cancel 的通知,就 process.exit?

不依赖 crontab 带 webui 的 cron 服务

Posted: 12 Jun 2021 08:23 AM PDT

https://github.com/So0ni/cronweb

菜鸡求个 star 。。

迫于小组内唯一会前端的老哥跑路,求前端老哥们给个 VUE 相关的前端速成路线

Posted: 12 Jun 2021 08:01 AM PDT

万年后端开发,js 就日常写过一点 node 玩,知道 ES6 的一些基础语法,求推荐下 VUE 相关的书籍资料以及好用的 webstorm 插件。
顺道问下 css 有相关的成体系的学习内容么。刚写代码的时候粗略的学了些,但是感觉实际写起来完全是靠蒙。

请教目前浏览器 HTTPS 中对称加密使用的是哪种算法?

Posted: 12 Jun 2021 06:55 AM PDT

引言: HTTPS 请求,开始时候是使用 RSA 算法(非对称加密算法)来传输客户端密钥的,后续数据传输,都是使用客户端密钥来加解密(对称加密算法)数据的。

请问这个 HTTPS 请求过程中,使用的 对称加密算法,是哪种对称加密算法?是 DES 吗?

面试被问住了。。。百度了好久,都是只说到,数据部分用了对称加密算法,但是没有具体说,浏览器用的哪种对称加密算法。

还有人记得当年在 V2EX 发《我开发了一款白酒》的程序员吗,融资数亿了

Posted: 12 Jun 2021 06:44 AM PDT

今天在某公众号看人提起观云白酒,描述是"元气旗下,高端线的,将近 1000 一瓶",看得我一愣一愣的,当年老哥在 V2EX 首发宣传我还买过一瓶,口感确实不错。后来出国了也买不到了,没想到几年下来,老哥现在事业做的这么大。

融资新闻: https://www.163.com/dy/article/G1OCL4AV05118O92.html

不知道为什么原来的帖子找不到了,但是多处有提及,应该没记错,是在 V2EX 首发的。

JpaRepository save 方法先查在改(或插入),能限制不查询,仅指定 update 或 insert 么

Posted: 11 Jun 2021 09:00 PM PDT

JpaRepository save 方法默认先查在改(或插入),能限制不查询,仅指定 update 或 insert 么

仿腾讯蓝鲸 CMDB,自己实现了一版 CMDB,已经开源了,欢迎了解,前端 UI 下了功夫,自我感觉不错呢。

Posted: 11 Jun 2021 07:16 PM PDT

github: https://github.com/lanyulei/fiy

演示站点: http://fdevops.com:8060

账号密码:admin/123456

如果觉得不错,还请给一个 star 呢。感谢。

今天碰到一个对接 Java rsa pkcs1 用公钥解密,

Posted: 11 Jun 2021 02:17 PM PDT

python 我搜了好久,都是用私钥解密的, 论坛里的大佬有给个资料的吗?

我实在搜不到了

Android 10 ,未授予任何权限,一些 App 会在某些二级目录创建文件

Posted: 11 Jun 2021 02:05 PM PDT

例如 Download 和 Music

那么

浏览器下载文件就可以不需要存储权限

App 能否读取其创建的文件,还是可以读取或修改所有数据,甚至创建次级目录

Android 目录有什么例外吗

c++一个基础问题

Posted: 11 Jun 2021 01:59 PM PDT

std::string str=std::string("5"); std::regex_search(str,res,std::regex(R"(-?(\d+)|(\d+\.\d+))")); 

上面这个是对的,下面这个编译报错,ide 提示我说找不到匹配的函数

std::regex_search(std::string("5"),res,std::regex(R"(-?(\d+)|(\d+\.\d+))")); 

我不知道如何搜索相关知识点,根据我有限的认知没理解这两个的区别...

这样会不会被搜索引擎惩罚

Posted: 11 Jun 2021 01:07 PM PDT

有个页面,比较复杂,之前用 vue 写的,问题就是搜索引擎无法搜录这种客户端渲染的页面。

现在想的一个办法是,用服务端渲染出来页面内容,只有内容,没有排版和样式,然后客户端再用 vue 重新渲染为正确的页面。

不知道这样会不会被搜索引擎认为是用户看到的和搜索引擎看到的不一样而惩罚。

高可用架构-限流如何实现

Posted: 11 Jun 2021 12:53 PM PDT

What is 限流?

限流顾名思义,限制流量或者说叫流量管制。

很形象的比喻如老式电闸都安装了保险丝,一旦有人使用超大功率的设备,保险丝就会烧断以保护各个电器不被强电流给烧坏。


Why use 限流?

理论上一个完整的对外提供服务的系统架构在设计初期,就要基于上游流量流速高峰期时间点峰值 qps,还有自身系统的负载能力,评估系统的吞吐量,并且进行入口流量的管制。

当超出限流阈值时,系统可以采取拒绝服务,排队或者引流等机制, 保证自身一直在健康的负载下。

如果系统没有限流策略,对于突发性的超自身负载的流量,系统只能被动的无奈接受,系统内各个子服务逐渐解体,最后服务整体雪崩。

限流

小概念 Review

QPS

Queries Per Second (每秒查询率),每秒查询率 QPS 是对一个特定的查询服务器在规定时间内所处理流量多少的衡量标准,在因特网上,作为域名系统服务器的机器的性能经常用每秒查询率来衡量。

RPS

Requests Per Second (每秒发送请求数 /吞吐率),指客户端每秒发出的请求数。阿里云 PTS 对于这个词的解释为 RPS 有些地方也叫做 QPS,在不单独讨论"事务"的情况下可以近似对应到 Loadrunner/jmeter 的 TPS ( Transaction Per Second, 每秒事务数)。

TPS

Transactions Per Second (每秒传输的事物处理个数),即服务器每秒处理的事务数。TPS 一般包括一条消息入和一条消息出,加上一次用户数据库访问。(业务 TPS = CAPS × 每个呼叫平均 TPS )


限流粒度

  • 集群限流
  • 单机限流

集群限流

集群限流方式可以归纳为两种

  • 网关层
  • 应用层

网关层

网关层常见设计,基于 nginx lua module 实现整体管控。下面是简单 lua demo 。

local locks = require "resty.lock"   local function limiter()     -- ngx dict     local limiter = ngx.shared.limiter     -- limiter lock     local lock = locks:new("limiter_lock")     local key = gx.var.host..ngx.var.uri       -- add lock     local elapsed, err =lock:lock("ngx_limiter:"..key)     if not elapsed then         return fail("failed to acquire the lock: ", err)     end     -- limit max value     local limit = 5     -- current value     local current =limiter:get(key)       -- 限流     if current ~= nil and current + 1> limit then        lock:unlock()        return 0     end           if current == nil then        limiter:set(key, 1, 1) -- 初始化     else         limiter:incr(key, 1)  -- +1     end     lock:unlock()     return 1 end ngx.print(limiter()) 

了解 lua-resty-lock: https://github.com/openresty/lua-resty-lock

Nginx.conf

http {       ……     lua_shared_dict limiter_lock 10m;     lua_shared_dict limiter 10m; } 

应用层

应用层常见通过业务代码实现,基于 Redis 计数, 通过 lua script 保证 redis 执行原子性.

local key = "limiter:" .. KEYS[1] local limit = tonumber(ARGV[1]) local expire_time = tonumber(ARGV[2])  local is_exists = redis.call("EXISTS", key) if is_exists == 1 then     if redis.call("INCR", key) > limit then         return 0     else         return 1     end else     redis.call("SET", key, 1)     redis.call("EXPIRE", key, expire_time)     return 1 end 

单机限流

单兵作战,自生自灭,我不倒集群不倒。不依赖存储中间件,基于 local cache 就可以实现简单的本地计数限流,宏观角度观察,只要网关层负载均衡服务高可用,每个节点流量差别不大,只需要关心单个节点的流量管控就可以。


以上是限流粒度分类,下面说说具体的限流算法模型。


限流模型

以上 Demo 都是基于简单的固定时间窗口模型实现限流,但是当出现临界点瞬间大流量冲击,。

常用的模型分类有两种:

  • 时间模型
  • 桶模型

时间模型

时间模型分两种:

  • 固定窗口模型
  • 滑动窗口模型

固定时间模型

image-20210611162727589

上面聊到的各粒度限流模式的 code demo 都是这种方式。

如图(图片来源网络),拉长 timeline,以 QPS 为例,限流 1000QPS,我们会讲 timeline 按照固定间隔分窗口,每个窗口有一个独立计数器,每个计数器统计窗口内的 qps,如果达到阈值则拒绝服务,这是一种最简单的限流模型,但是缺点比较明显,当在临界点出现大流量冲击,就无法满足流量控制。

image-20210611163226601

如图(图片来源网络),在 900ms 和 1100ms 都出现 1000QPS 并发,虽然单个窗口内是符合限流要求,但是实际上临界点处的 QPS 已经打到 2000,服务过载。

滑动时间模型

image-20210611163509051

如图(图片来源网络),为了规避临界点大流量冲击,滑动时间模型会将每个窗口切分成 N 个子窗口,每个子窗口独立计数。这样用w1+w2计数之和来做限流阈值校验,就可以解决此问题。


桶模型

桶模型也分两种:

  • 令牌桶
  • 漏桶

令牌桶模型

令牌桶算法的原理是系统会以一个恒定的速度往桶里放入令牌,而如果请求需要被处理,则需要先从桶里获取一个令牌,当桶里没有令牌可取时,则拒绝服务。不过令牌桶还是允许一定程度的突发传输,这样解决了在实际上的互联网应用中,流量经常是突发性的问题。

Ref: https://en.wikipedia.org/wiki/Token_bucket

如下图(图片来源网络):

image-20210611164336925

算法实现方式有两种:

  • Ticker 定义一个 Ticker,持续生成令牌并导入桶中。这样问题是会极大的消耗系统资源。如果基于某一维度进行限流,会创建多桶,对应多 Ticker,资源消耗很可怕。
  • Inert Fill 惰性填充,定义一个 inert fill 函数。该函数会在每次获取令牌之前调用,其实现思路为,若当前时间晚于 lastAccessTime,则计算该段时间内可以生成多少令牌,将生成的令牌加入令牌桶中并更新数据。这样一来,只需要在获取令牌时计算一次即可。

桶内令牌数计数方式

桶内令牌数 = 剩余的令牌数 + (本次取令牌的时刻-上一次取令牌的时刻)/放置令牌的时间间隔 * 每次放置的令牌数

常用令牌桶如: github.com/juju/ratelimit 2K Star

多种填充令牌方式:

func NewBucket(fillInterval time.Duration, capacity int64) *Bucket 

默认令牌桶,fillInterval 每过多⻓时间向桶⾥放⼀个令牌,capacity 是桶的容量,超过桶容量的部分会被直接丢弃。

func NewBucketWithQuantum(fillInterval time.Duration, capacity, quantum int64) *Bucket 

和默认方式一样,唯一不同是每次填充的令牌数是 quantum,而不是 1 个。

func NewBucketWithRate(rate float64, capacity int64) *Bucket 

按照使用方定义的⽐例,每秒钟填充令牌数。比如 capacity 是 100,⽽ rate 是 0.1,那么每秒会填充 10 个令牌。

多种领取令牌方式:

func (tb *Bucket) Take(count int64) time.Duration {} func (tb *Bucket) TakeAvailable(count int64) int64 {} func (tb *Bucket) TakeMaxDuration(count int64, maxWait time.Duration) (     time.Duration, bool, ) {} func (tb *Bucket) Wait(count int64) {} func (tb *Bucket) WaitMaxDuration(count int64, maxWait time.Duration) bool {} 

如下,我简单实现了一个极简的令牌桶, 速率默认为 QPS 。

TokenBucket Demo

Struct 结构
// object type TbConfig struct {   QPS    int64 	// 限制 qps e.g 200   MaxCap int64	// 桶最大容量 e.g:1000 }  type TokenBucket struct { 	*TbConfig 	m         sync.Mutex		// 读写锁 	available int64					// 可用令牌 	lastTime  time.Time			// 最后一次获取令牌时间 } 
Inert Fill
func (tb *TokenBucket) fill() error {    n := time.Now()    timeUnit := n.Sub(tb.latestTime).Seconds()     fillCnt := int64(timeUnit) * tb.QPS // 见文下描述    if fillCnt <= 0 {       return nil    }     tb.available += fillCnt     // 防止过大溢出    if tb.MaxCap > 0 && tb.available > tb.MaxCap {       tb.available = tb.MaxCap    }     tb.latestTime = n    return nil } 

桶内令牌数 = 剩余的令牌数**tb.available** + (本次取令牌的时刻**n** - 上一次取令牌的时刻**tb.latestTime) / 放置令牌的时间间隔速率为 qps,所以此处是1** * 每次放置的令牌数**tb.QPS**


漏桶模型

漏桶算法思路很简单,如下图(图片来源网络),水(请求)先进入到漏桶里,漏桶以一定的速度出水,当水流入速度过大会直接溢出,可以看出漏桶算法能强行限制数据的传输速率。

简单的说: 调用方只能严格按照预定的间隔顺序进行消费调用。

Ref: https://en.wikipedia.org/wiki/Leaky_bucket

image-20210611165710958

常用漏桶: https://github.com/uber-go/ratelimit 2.4k Star

对于很多应用场景来说,除了要求能够限制流量的平均传输速率外,还要求允许某种程度的突发传输。

传统的 Leaky Bucket,关键点在于漏桶始终按照固定的速率运行,但是它并不能很好的处理有大量突发请求的场景。

对于这种情况,uber-go 对 Leaky Bucket 做了一些改良,引入了最大松弛量 (maxSlack) 的概念。

当请求间隔时间小于固定的速率时,可以把间隔比较长的请求多余出来的时间 buffer,匀给后面的使用,保证每秒请求数。如果间隔时间远远超出固定速率,那会给后续请求增加超大的 buffer,以至于即使后面大量请求瞬时到达,也无法抵消完这个时间,那这样就失去了限流的意义。所以 maxSlack 会限制这个 buffer 上限。

LeakyBucket Demo

如下,实现了一个极简的非阻塞漏桶。

Struct 结构
// object type LbConfig struct {   Rate     float64 // 速率 e.g 200: 每秒 200 次请求   MaxSlack int64   // 最大松弛量,可以理解 buffer 时间内最大放行的 qps 。默认为 0 表示不开启松弛量 e.g 10: 如果松弛量大于 10,则松弛量强制为 10 }  type LeakyBucket struct { 	*LbConfig 	m          sync.Mutex				// 读写锁    			 	perRequest time.Duration		// 速率 	bufferTime time.Duration		// 多余时间 	slackTime  time.Duration		// 最大松弛时间 	lastTime   time.Time				// 最后一次获取令牌时间 } 
无松弛量实现

即严格按照预定时间间隔获取令牌。

func (lb *LeakyBucket) withoutSlack() error { 	n := time.Now() 	lb.bufferTime = lb.perRequest - n.Sub(lb.lastTime) 	// 多余时间如果为正数: 证明前后时间间隔超过预期速率,需要拒绝服务 	if lb.bufferTime > 0 { 		return ErrNoTEnoughToken 	} else { 		lb.lastTime = n 	} 	return nil } 
有松弛量实现

即多余时间匀给后面获取令牌使用。

func (lb *LeakyBucket) withSlack() error{ 	n := time.Now()   // 此处为+= 表示要累计多余时间 	lb.bufferTime += lb.perRequest - n.Sub(lb.lastTime)  	// 多余时间如果为正数: 证明前后时间间隔超过预期速率,需要拒绝服务 	if lb.bufferTime > 0 { 		return ErrNoTEnoughToken 	} else { 		lb.lastTime = n 	}  	// 允许抵消的最长时间 	if lb.bufferTime < lb.slackTime { 		lb.bufferTime = lb.slackTime 	} 	return nil } 

Demo 源码

源码可见 github.com/xiaoxuz/limiter

相关文章

https://www.cyhone.com/articles/analysis-of-uber-go-ratelimit/

https://en.wikipedia.org/wiki/Token_bucket

https://en.wikipedia.org/wiki/Leaky_bucket

收工

打完收工,感谢支持

扫码_搜索联合传播样式-白色版

似乎是 win10 bug 当 smb 无法连接时,在资源管理器增删文件后,都不会自动刷新

Posted: 11 Jun 2021 12:49 PM PDT

为什么 Centos vs FreeBSD 分别跑 nginx 负载压测,性能差别那么大?

Posted: 11 Jun 2021 12:25 PM PDT

明显 FreeBSD 优于 Centos

端午节准备在家直播写代码~

Posted: 11 Jun 2021 11:56 AM PDT

RT..

有人来看吗,在某站,目前在用 React 全家桶写网页版,可能能帮到前端小白打开思路~

迫于之前开了一个前端训练营带新人做项目,然后有人氪金了说项目太难跟不上,又不忍心打击我,说等以后变强了再跟我做项目...然而我觉得已经很基础了,为了抬杠和还债,我决定整一个更简单的项目直播来写.

项目是一个记事本.应该没有比这更简单的实战项目了。

写完了争取半年更新一次,某记的更新频率比我的使用频率还高,神烦..

正好市面上的笔记应用都用不太爽,就自己写一套!

端午节都出去玩了的话我就换个时间 ̄□ ̄||

这个应用是真的适合入门~

后端准备用 nodejs 、fastify, 移动端可能用 Flutter 或者 Uniapp, 桌面端套个 Electron, 通讯加密要有,钱包密码也能存, 最后可能还会用 slate 扩展编辑器,不过不想趟这个坑,有成熟的 md 编辑器推荐吗~

Oracle Cloud free Tier 可以创建最大 24GB 内存的 ARM VM - Ampere A1 Compute

Posted: 11 Jun 2021 11:45 AM PDT

Infrastructure

  • 2 AMD based Compute VMs with 1/8 OCPU and 1 GB memory each.
  • 4 Arm-based Ampere A1 cores and 24 GB of memory usable as one VM or up to 4 VMs.
  • 2 Block Volumes Storage, 200 GB total.
  • 10 GB Object Storage.
  • 10 GB Archive Storage.
  • Resource Manager: managed Terraform.
  • 5 OCI Bastions.

https://www.oracle.com/cloud/free/ https://www.oracle.com/cloud/compute/arm/

似乎是新产品,不知道跟 AMD 的免费 VM 比,实际性能怎么样。

问一下大佬们, 如何保证在 windows 系统上面这个 Python 进程最多只有一个在运行

Posted: 11 Jun 2021 10:26 AM PDT

例如下面的代码文件 hello.py

 import time  import subproctitle while 1:     pass  

运行该文件 python hello.py , 如果当前系统已经有这个进程在运行了, 则直接这个文件报错不运行或者其它的, 但是如果没有的话则启动这个文件, 一开始用 setproctitle 这个文件, 设置一个专门的进程名字来检测, 但是 setproctitle 在 windows 上好像 失效了, 那么还有什么方法么?

检测浏览器匿名程度的网站,有人知道吗

Posted: 11 Jun 2021 09:57 AM PDT

记得多年以前偶然访问到了一个,能展示出网站获取到的你的 IP 、浏览器默认语言等等很多,好像还会给出你的匿名程度是百分之几的数字,网页还有一个美式漫画是一个人拿着放大镜。

能记得细节就是这些,怎么搜也搜不到了,有没有大神知道这个站,或者类似功能的呀

不是我不想支持 Android 10 的分区存储啊 Orz

Posted: 11 Jun 2021 08:47 AM PDT

我司 App 最近终于打算上架 Google Play 了,因此在做一些准备工作。Google Play 的上架要求是 targetSdkVersion 最低 29,也就是要适配分区存储 /存储隔离。 当然,还有一种临时的方案就是在 application 设置 android:requestLegacyExternalStorage="true"。不过这显然也不是啥长久之计,我决定还是直接支持为好。

说一下 App 情况:我们本身行为是很干净的,只有在 DCIM 下创建了一个我们的文件夹,用于用户导出的视频。然后再有一个内置的图片 /视频 /音频选择器,供用户导入,预览内容。

我看了一通 Android 自己的 Android 10 兼容文档,和一些相关的适配文章,<del>很快就适配好了</del>。

大致思路是,我们没法直接操作非我们私有目录文件的 File 了,我们能得到的是 Uri,然后需要读就调 contentResolver.openAssetFileDescriptor 之类的方法,操作 FileDescriptor 即可。 看着是不是很简单!我也觉得!

然后我就愉快地开始测试了=。=

然后发现,项目用到的一个第三方框架,一款获取视频某个关键帧画面的框架 FFmpegMediaMetadataRetriever,在用 FileDescriptor 解析一部分视频时,会发生 Native Crash 。我想着人家是开源项目嘛,我自己琢磨下咋修呗,然后研究了半天,也试了不同的场景,甚至还找到了当年该作者关于这个问题的提问贴,但看了一圈感觉写得没问题啊...

最后放弃了,给作者提了个 Issue 。

我把用到该框架的功能封装了一下改用 Android 自己的 MediaMetadataRetriever 实现了,姑且算是规避了这个问题。

然后,过了两天,我又发现,我如果反复加载视频(对应的用户操作就是在项目列表页反复进入编辑页退出),以前的操作是直接调系统的一个接口 MediaExtractor.setDataSource(filePath),没有问题。但是兼容 Android 10 传 uri 后,操作就是先 contentResolver.openAssetFileDescriptor(uri, "r"),再 MediaExtractor.setDataSource(fileDescriptor),然后当操作次数多了后,openAssetFileDescriptor 就有概率阻塞住,需要过很久才会响应。

我依旧对其进行了很久的分析,自然是有 close 的,而且它的几个不同的 setDataSource 函数本质上也是互相调用的,折腾了一圈,最终结论就是似乎不是我的锅...

而且这个只在一部分手机上会出现。比如我自己的小米 11 就正常。 暂时无解。

再然后,今天早上,测试小姐姐又跟我说,在一台测试机上导图片又会 Crash 啦。我看了一下,大致原因是我们的 Gif 支持是用的一个第三方框架 android-gif-drawable,它在 Android 11 上(也可能是一部分 Android 11 手机)如果传入一张非 Gif 图,会产生 Native Crash 。

我们可以选择先判断 exif 信息之类的,只对 gif 调用。或者再给作者提个 Issue...

所幸我报着试一试的态度更新了库的依赖,解决了问题。而这个版本也是近几个月才更新修复的。

_(:з)∠)_我已经写得身心俱疲了...不知道哪里会不会又有新的兼容性问题,好烦啊......

现在如何安装 GP?

Posted: 11 Jun 2021 07:51 AM PDT

现在的手机如何安装 Google Play ?

web 因公司需求需要学 flutter 的开发,有什么好的建议

Posted: 11 Jun 2021 07:09 AM PDT

最近在网上查了查 说有原生基础比较好上手 前端的话还需要学习学习 原生的一些代码

怎么优雅的实现 TCP Ping?

Posted: 11 Jun 2021 05:34 AM PDT

如题。

是计算使用 Raw Socket 手动发送 SYN 包 与收到 SYN+ACK 包的时间差,还是直接使用更上层的 TCP Socket,直接计算连接建立完成的时间?

安卓 11 的手机,关了“息屏显示”就不能“双击亮屏”了吗?

Posted: 11 Jun 2021 05:29 AM PDT

moto 系的,预装就是 11 的系统,也是第一次用 11 的系统,不关"息屏显示"的时候也不需要双击,随便一点点振动就会亮屏,不胜其烦,关了息屏显示后除非指纹解锁或者按电源键,否则无论怎么双击三击甚至连击,屏都不可能亮。不方便啊,哪里设置的不对或者有什么办法能找回"双击亮屏"吗?谢谢

大佬们, mysql 五百万以上的 join left 关联查询统计很慢 怎么操作

Posted: 11 Jun 2021 05:18 AM PDT

索引已经加了,a 表 people_id 关联 b 表 id, 然后条件是 b 表的某一个字段==1,然后 count(*)

下面是 php 伪代码

$people_ids = Db::name('people_check')->where('admin_id',$value['id'])->column('people_id'); $people1 = Db::name("people")->where('id','in',$people_ids)->where('id_dailu',1)->count();  # 全部检测人数                  

admin_id 加了索引,id_dailu 加了索引。 没有全表扫描

原先写法是 join left,这个是改过的, 这个更慢。 求大佬分析一波

现阶段使用 Electron 开发的重量级应用有哪些, 是否可以完全切到 centos 上办公.base. Linux

Posted: 11 Jun 2021 05:06 AM PDT

两三年前 electron-forge 很火,不知现在应用生态怎么样了

Mac 下求一个软件,把电脑当做热点,对手机流量进行 MITM

Posted: 11 Jun 2021 04:05 AM PDT

安卓手机直接在 wifi 里面设置代理,很多请求在 Charles 里面抓不到,怀疑这个设置对一些 app 不奏效。

我想直接把电脑作为无线接入点,手机连上,对通过的流量劫持,这样对手机就是透明的了

我知道这里可能有证书的问题,寄希望于该 app 没做证书校验,试一试吧。

请问,在 Mac 上,有没有这样的软件?

有没有什么方法能让 go 写的命令行程序在 windows 上以服务的方式运行

Posted: 11 Jun 2021 04:00 AM PDT

以 windows 服务的方式运行,避免误关闭之类的操作

第一个 Python 程序 | 机选彩票号码+爬取最新开奖号码

Posted: 11 Jun 2021 02:57 AM PDT

(机选彩票号码+爬取最新开奖号码 | 2021-04-21)


因为是自学状态,没有大佬带路, 想知道写的这些代码有木有不规范的,或者说是不应该这么写等等,一开始就想发在 V2 上,但怕丢人....今天想了想还是发出来, 毕竟大佬们的批评才能让我进步么

这个程序作用是<机选三种彩票类型的号码>

程序内包含功能有如下:

  • 自动获取最新的三种彩票的开奖号码
  • 随机生成三种彩票类型的号码
  • 注册
  • 登录
  • 密码加密
  • 数据写入文件
  • 文件中提取数据
  • 时间模块判断早中晚

先上个演示 | 再附上打包后的程序 exe | 再贴上完整源代码

截至 2021-04-20 的最新彩票开奖信息和程序获取的一致,如图:

演示程序下载>>>点击下载 提取密码:cisj

import re as m_re import os as m_os import time as m_time import random as m_random import easygui as m_easygui import requests as m_requests   # 取开奖号码 class HtmlInfo():     def __init__(self):         self.browser_header = {             "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36"                         "(KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"}         #福利彩票         self.ddd_nums = {}# 福彩 3D         self.ssq_nums = {}# 双色球         self.qlc_nums = {}# 七乐彩         self.urls = [             r'http://kaijiang.500.com/sd.shtml',             r'http://kaijiang.500.com/ssq.shtml',             r'http://kaijiang.500.com/qlc.shtml'         ]         self.html_lable = [             r'<span class="span_right">(.*?)</span>',# 开奖日期-0             r'<strong>(.*?)</strong>',# 开奖期号-1             r'<li class="ball_orange">(.*?)</li>',# 福彩 3D-2             r'<li class="ball_red">(.*?)</li>',# 双色球-红-3             r'<li class="ball_blue">(.*?)</li>',# 双色球-蓝-4             r'<li class="ball_red">(.*?)</li>',# 七乐彩-红-5             r'<li class="ball_blue">(.*?)</li>'# 七乐彩-蓝-6         ]      def get_HtmlInfo(self, url):         try:             html = m_requests.get(url, headers=self.browser_header)             html.encoding = 'gbk'# 一下午试图想在正则中解决它...cnm,耽误不少时间         except TypeError:             print('网络中断或其他原因!')             return# 直接中断程序, 函数内用 return | 函数外用 exit()          # 取最新的日期         # lottery_date = m_re.findall('<td align="center">(.*?)</td>', html.text, m_re.S)          # 取最新的开奖号码         # for loop_urls in range(len(self.urls)):         if self.urls[0] == url:             # 福彩 3D: 开奖日期, 开奖期号, 开奖号码, 写入字典             self.lottery_date = m_re.findall(self.html_lable[0], html.text, m_re.S)[0]             lottery_date_nums = m_re.findall(self.html_lable[1], html.text, m_re.S)[1]             lottery_nums = m_re.findall(self.html_lable[2], html.text, m_re.S)             # 数据进字典             self.ddd_nums[lottery_date_nums] = lottery_nums             # print(self.ddd_nums)          if self.urls[1] == url:             # 双色球: 号码列表-合并期号, 开奖日期, 开奖期号, 开奖号码 红六个 / 蓝一个, 红蓝号码合并列表             lottery_nums = []             lottery_date = m_re.findall(self.html_lable[0], html.text, m_re.S)[0]             lottery_date_nums = m_re.findall(self.html_lable[1], html.text, m_re.S)[1]             lottery_nums_red = m_re.findall(self.html_lable[3], html.text, m_re.S)[:6]             lottery_nums_blue = m_re.findall(self.html_lable[4], html.text, m_re.S)[:1]             # 下面用 extend 插了两次是因为我想把红蓝球变成一个列表, 如果弄成只插一次就会造成列表套列表,很是疑惑             lottery_nums.extend(lottery_nums_red)             lottery_nums.extend(lottery_nums_blue)             # 数据进字典             self.ssq_nums[lottery_date_nums] = lottery_nums             # print(self.ssq_nums)          if self.urls[2] == url:             # 七乐彩: 号码列表-合并期号, 开奖日期, 开奖期号, 开奖号码 红七个 / 蓝一个, 红蓝号码合并列表             lottery_nums = []             lottery_date = m_re.findall(self.html_lable[0], html.text, m_re.S)[0]             lottery_date_nums = m_re.findall(self.html_lable[1], html.text, m_re.S)[1]             lottery_nums_red = m_re.findall(self.html_lable[5], html.text, m_re.S)[:7]             lottery_nums_blue = m_re.findall(self.html_lable[6], html.text, m_re.S)[:1]              lottery_nums.extend(lottery_nums_red)             lottery_nums.extend(lottery_nums_blue)             # 数据进字典             self.qlc_nums[lottery_date_nums] = lottery_nums             # print(self.qlc_nums)   # 对密码加密-解密, 上面代码很长 总感觉可以再精简优化下, 目前对于类的使用不是很熟练 class AppCryptos():     def __init__(self):         self.token_list = [             '0000000000_'             'bC0>aB3?aA0!aG1%hI1$'             'eK6)dA8&qB4@lC0$bA0&aI0eP1#cC0$'             '!@#$%^&*()_+aF0!bG2!cE4_eC1^bE0^aE4@bC0{nB'         ]         self.enctry_str = ''# 加密数据         self.dectry_str = ''# 解密数据      # 加密     def enctry_AppCryptos(self, key):# key 为传入的密码         for i,j in zip(key, str(self.token_list)):             temp_ij = str(ord(i) + ord(j)) + str(self.token_list[0][:15])             self.enctry_str += temp_ij             # print(self.enctry_str)         return self.enctry_str      # 解密     def dectry_AppCryptos(self, key):# key 为传入的密文         for i,j in zip(key.split(str(self.token_list[0][:15]))[:-1], str(self.token_list)):             temp_ij = chr(int(i) - ord(j))             self.dectry_str += temp_ij             # print(self.dectry_str)         return self.dectry_str    # EasyGui class EasyGuiUI():     def __init__(self):         self.app_config = [             r'AppConfig.ini',# 文件可自定义目录存放,也可以跟主程序走             r'MainConfig.ini',# 文件跟着主程序走             r'config_path=',# 用户自己选择的配置文件目录路径             r'configfile_path=',# 用户自己选择的配置文件目录路径 + AppConfig.ini 路径             r'username=',# 用户昵称             r'userkey='# 加密的程序密码的密文         ]          # 取三个数为一注         self.loop_ddd = (0, 9)         # 取六个红球,一个蓝球为一注         self.loop_ssq_red = (1, 33)         self.loop_ssq_blue = (1, 16)         # 七个基本号, 一个特别号为一注         self.loop_qlc = (1, 30)          self.box_msg = [             '欢迎进入彩票号码生成器!\n 是否进行程序初始化?\n 自定义配置文件目录或程序默认目录',             '选择一个文件夹!',             '欢迎使用机选彩票号码程序, 祝您早日中大奖!',             '请输入程序密码',             '注册成功!',             '\n\n\n 点击下方[查看最新开奖号码]按钮以获取开奖号码'         ]         self.box_title = [             '程序初始化',             '激活程序',             '登录验证',             '机选号码'         ]         self.indexbox_choices = [             ['0', '确定'],# 用来判断 choices_msg 按钮返回值             ['1', '默认'],             ['2', '机选号码'],             ['3', '查看最新开奖号码'],             ['4', '退出程序']         ]         self.indexbox_errmsg = [             '未知错误!',             '文件不存在',             '',             '',             '主程序文件失效,请重新运行程序!'         ]         self.multpasswordbox_fields = [             '*昵称',             '*程序密码'         ]         # 如果函数中已经有相同变量,应该是优先读函数中的, 有点忘记了...         # 想起来一个, 相同方法下的变量互相调用之前,得先调用被调用的那个方法         self.temp_enctry_str = ''# 临时存放加密的密文,写入到文件 MainConfig.ini. 如果函数中已经有相同变量,应该是优先读函数中的         self.temp_ext_userkey = []# 临时存放提取出来的密文.         self.temp_ext_username = []# 临时存放提取出来的昵称      # 运行程序 初始化界面 | 用户选择目录或者程序直接走默认目录     def init_EasyGuiUI(self):         try:             with open(self.app_config[1], encoding='utf-8') as init_f1:                 init_f1.close()# 走个过程就直接关掉, 不占用                 EasyGuiUI().reg_EasyGuiUI()         except OSError:             # 初始界面, 因为检查不到文件 MainConfig.ini, 所以初始化一下 目的是生成 AppConfig.ini 和 MainConfig.ini 两个文件             # 原本还想弄一个判断有无文件 AppConfig.ini, 因为这个文件是可以让用户自定义目录去生成的,             #    如果作这个判断就把文件 AppConfig.ini 的目录路径也写到文件 MainConfig.ini 中, 想了下还是没写这个, 只验证有无文件 MainConfig.ini             choices_msg = m_easygui.indexbox(                 self.box_msg[0],                 self.box_title[0],                 choices=(self.indexbox_choices[0][1],self.indexbox_choices[1][1])             )              # 判断用户是选择的[确定]按钮, 开始调用 diropenbox() 函数选择目录             if choices_msg == int(self.indexbox_choices[0][0]):                 choices_path = m_easygui.diropenbox(self.box_msg[1])                 # 这里会先生成文件 MainConfig.ini, 避免与下方的 m_os.chdir() 函数冲突                 with open(self.app_config[1], 'w', encoding='utf-8') as user_f1:                     user_f1.write(                         self.app_config[2] + m_os.getcwd() + ';' + '\n' +                          self.app_config[3] + m_os.getcwd() + '\\' + self.app_config[1] + ';'                     )                 # 选择目录窗口如果直接关闭在这里做个 TypeError 处理                 try:                     m_os.chdir(choices_path)                 except TypeError:                     return                 # 合并一下选择的目录跟文件名 AppConfig.ini,得到一个完整路径                 merge_path = m_os.path.join(m_os.getcwd(), self.app_config[0])                 # 根据用户选择的目录直接覆写文件 AppConfig.ini                 with open(merge_path, 'w', encoding='utf-8') as user_f2:                     user_f2.write(                         self.app_config[2] + choices_path + ';' + '\n' +                          self.app_config[3] + merge_path + ';'                     )                 EasyGuiUI().reg_EasyGuiUI()             # 判断用户是选择的[默认]按钮, 直接在程序目录下进行覆写两个文件 MainConfig.ini AppConfig.ini             elif choices_msg == int(self.indexbox_choices[1][0]):                 # 选择[默认] 直接在程序所在目录生成文件                 with open(self.app_config[0], 'w', encoding='utf-8') as app_f1,\                         open(self.app_config[1], 'w', encoding='utf-8') as app_f2:                             app_f1.write(                                 self.app_config[2] + m_os.getcwd() + ';' + '\n' +                                  self.app_config[3] + m_os.getcwd() + '\\' + self.app_config[0] + ';'                             )                             app_f2.write(                                 self.app_config[2] + m_os.getcwd() + ';' + '\n' +                                  self.app_config[3] + m_os.getcwd() + '\\' + self.app_config[1] + ';'                             )                 EasyGuiUI().reg_EasyGuiUI()      # 注册     def reg_EasyGuiUI(self):         # 在启用注册 UI 之前 判断下是否已经进行了注册, 判断文件 MainConfig.ini 中有无 self.app_config[4]/[5]这两个字符串         # 这种判断应该还有更好的写法, 截至学到目前的知识 确实想不出了         with open(self.app_config[1], 'r', encoding='utf-8') as read_f1:             #在这个变量出来前, 原地转圈琢磨了好久. read()这个好像并不能用在 if 语句的多重判断中,期望的结果会 False             read_f1_temp = read_f1.read()             if self.app_config[4] in read_f1_temp and self.app_config[5] in read_f1_temp:                 return EasyGuiUI().login_EasyGuiUI()         # 这下面是原地转圈时琢磨的         # if (self.app_config[4] and self.app_config[5]) in read_f1:         #     return EasyGuiUI().login_EasyGuiUI()                             # aa = m_re.search('username=*|userkey=*', i)                 # if aa:                 #     print(aa.group())                 #     print(i)         # if [read_f1_temp1.strip().find('username=') for read_f1_temp1 in read_f1]:         #     print('11')          # with open(self.app_config[1], 'r+', encoding='utf-8') as read_f2:         #     if [read_f2_temp1.strip().find(self.app_config[5]) for read_f2_temp1 in read_f2.readlines()]:         #         return EasyGuiUI().login_EasyGuiUI()          reg_values = []         reg_values = m_easygui.multpasswordbox(             self.box_msg[2],             self.box_title[1],             fields=(self.multpasswordbox_fields[0],self.multpasswordbox_fields[1])         )          while True:             # 循环后 重置 self.indexbox_errmsg[2]的消息为空字符串             self.indexbox_errmsg[2] = self.indexbox_errmsg[3]             # 返回值为 None,结束             if reg_values == None:                 return             # 这块还想写一个昵称只能输入纯英文, 程序密码只能输入纯数字             for i in range(len(self.multpasswordbox_fields)):                 if reg_values[i] == '' and self.multpasswordbox_fields[i][0] == '*' and self.multpasswordbox_fields[i][0] == '*':                     self.indexbox_errmsg[2] += (' [%s ] 为必填项,请重新填写!\n' % self.multpasswordbox_fields[i])             if self.indexbox_errmsg[2] == '':                 break              reg_values = m_easygui.multpasswordbox(                 self.indexbox_errmsg[2],                 self.box_title[1],                 fields=(self.multpasswordbox_fields[0],self.multpasswordbox_fields[1]),                 values=reg_values# 这里是留存填写过的内容,并显示在程序,避免用户二次输入             )         # 联动 enctry_AppCryptos() 加密函数, 对用户输入的<程序密码>进行加密         link_AppCryptos = AppCryptos()         link_AppCryptos.enctry_AppCryptos(reg_values[1])         self.temp_enctry_str = link_AppCryptos.enctry_str         # 将昵称和加密的程序密码存入文件 MainConfig.ini         # 这块应该还要做个文件中是否存在 username 和 userkey 的字符串做对应的写入判断(如果字符串存在多个,或者没有,或者文件不在,或者权限不够等)         # 不过这次就简单写一下数据存入文件, 其他的心里写了就行         try:             with open(self.app_config[1], 'a', encoding='utf-8') as enctry_f1:                 enctry_f1.write(                     '\n' + self.app_config[4] + reg_values[0] + ';' +                      '\n' + self.app_config[5] + self.temp_enctry_str + ';'                 )             m_easygui.msgbox(self.box_msg[4])             EasyGuiUI().login_EasyGuiUI()         except OSError:             m_easygui.msgbox(self.indexbox_errmsg[4])         # print(self.enctry_str)      # 登录     def login_EasyGuiUI(self):         # 登录这块应该也要写一个取文件中密文的时候来个文件是否存在或文件中需要的字符串是否存在, 心里写了!         # 想了下 验证文件这些步骤其实可以单独弄个函数放在那边来调用, 这样代码应该可以精简一些         # 在 open 的时候用'x'模式 检查文件是否存在?         login_return_cont = m_easygui.passwordbox(self.box_msg[3], self.box_title[2])          # 读取文件中 userkey 存放的密文         with open(self.app_config[1], encoding='utf-8') as dectry_f1:             # for read_line in dectry_f1:             ext_userkey = m_re.findall(r'userkey=(.*?);', dectry_f1.read(), m_re.S)             # print(ext_userkey)          # 联动 enctry_AppCryptos(),进行一次密码加密,然后验证加密好的密文是否存在文件内         link_AppCryptos = AppCryptos()         link_AppCryptos.dectry_AppCryptos(ext_userkey[0])         if login_return_cont == link_AppCryptos.dectry_str:             EasyGuiUI().panel_EasyGuiUI()         elif login_return_cont == None:             return         else:             return EasyGuiUI().login_EasyGuiUI()      # 登录成功后调用的, 获取最新开奖号码给面板显示     # 此方法被 panel_EasyGuiUI(self) 方法来调用     def get_nums_ForPanel(self):         # 获取最新中奖号码, 为了给面板显示         link_HtmlInfo = HtmlInfo()         for loop_urls in range(len(link_HtmlInfo.urls)):             link_HtmlInfo.get_HtmlInfo(link_HtmlInfo.urls[loop_urls])         dict_ddd = link_HtmlInfo.ddd_nums         dict_ssq = link_HtmlInfo.ssq_nums         dict_qlc = link_HtmlInfo.qlc_nums         dict_ddd_value = ','.join(list(dict_ddd.values())[0])         dict_ssq_value = ','.join(list(dict_ssq.values())[0])         dict_qlc_value = ','.join(list(dict_qlc.values())[0])          self.marge_msgs_get_nums_ForPanel = (             # ext_username[0] + self.box_msg[2] + '\n' +             '第[' + list(dict_ddd)[0] + ']期福彩 3D 开奖号码: ' + dict_ddd_value + '\n' +             '第[ ' + list(dict_ssq)[0] + ' ]期双色球开奖号码: ' + dict_ssq_value + '\n' +             '第[ ' + list(dict_qlc)[0] + ' ]期七乐彩开奖号码: ' + dict_qlc_value         )      # 机选号码, 机选的规则都为:彩票投注中的单式投注!     # 此方法被 panel_EasyGuiUI(self) 方法来调用     def get_loopnums_ForPanel(self, keyloopnums):         if keyloopnums == 'start':             # 机选福彩 3D             # 使用列表推导式 把需要的每一个元素转换成字符串,这样做的方式是方便呈现的时候 数字后面自带逗号             # loopnums_1_ddd = ''             loopnums_1_ddd = [str(m_random.randint(self.loop_ddd[0],self.loop_ddd[1])) for loop in range(3)]             loopnums_1_ddd = ','.join(loopnums_1_ddd)# # 三个数字转换成字符串且用逗号来分割进行展示             # print(loopnums_1_ddd)# 输出一下 机选出来的三个数字              # 机选双色球             # loopnums_2_ssq = []             loopnums_2_red = [str(m_random.randint(self.loop_ssq_red[0],self.loop_ssq_red[1])) for loop in range(6)]             loopnums_2_blue = [str(m_random.randint(self.loop_ssq_blue[0],self.loop_ssq_blue[1])) for loop in range(1)]             loopnums_2_red.append(loopnums_2_blue[0])# 蓝球合并到红球的列表             loopnums_2_ssq = ','.join(loopnums_2_red)# 定一个新的变量名称 | 七个数字转换成字符串且用逗号来分割进行展示             # print(loopnums_2_ssq)# 输出一下 机选出来且合并后的 红+蓝七个数字              # 机选七乐彩             loopnums_3_red = [str(m_random.randint(self.loop_qlc[0],self.loop_qlc[1])) for loop in range(7)]             loopnums_3_blue = [str(m_random.randint(self.loop_qlc[0],self.loop_qlc[1])) for loop in range(1)]             loopnums_3_red.append(loopnums_3_blue[0])             loopnums_3_qlc = ','.join(loopnums_3_red)             # print(loopnums_3_qlc)              # 三个彩种机选的号码合并掉,给 panel_EasyGuiUI() 函数中的 indexbox() 调用             self.marge_msgs_get_loopnums_ForPanel = (                 '机选的福彩 3D 号码: ' + loopnums_1_ddd + '\n' +                 '机选的双色球号码: ' + loopnums_2_ssq + '\n' +                 '机选的七乐彩号码: ' + loopnums_3_qlc + '\n' +                 '截屏或拍照后去彩票站购买, 祝你鸿运当头!'             )         else:             pass      # 登录成功后 显示获取的最新彩票号码 | 按钮形式机选号码并以 msgbox() 函数显示给用户 | over!     def panel_EasyGuiUI(self):         self.get_nums_ForPanel()         # self.get_loopnums_ForPanel()          # 读取文件中 username 存放的昵称         with open(self.app_config[1], encoding='utf-8') as read_f1:             ext_username = m_re.findall(r'username=(.*?);', read_f1.read(), m_re.S)          # 加一个时间判断         # 06:00~10:00>早上 10:00~12:00>中午 12:00~18:00>下午  18:00~06:00>晚上         get_time = m_time.localtime()         # print(get_time.tm_hour)         if 0 <= get_time.tm_hour <= 4:             indexbox_msg_time = '凌晨时段,注意休息: '         elif 5 <= get_time.tm_hour <= 10:             indexbox_msg_time = '早上好: '         elif 11 <= get_time.tm_hour <= 12:             indexbox_msg_time = '中午好: '         elif 13 <= get_time.tm_hour <= 18:             indexbox_msg_time = '下午好: '         elif 19 <= get_time.tm_hour <= 23:             indexbox_msg_time = '晚上好: '         else:             indexbox_msg_time = '奈何桥见: '          choices_msg = m_easygui.indexbox(             msg=(indexbox_msg_time + ext_username[0] + self.box_msg[5]),             title=self.box_title[3],             choices=(self.indexbox_choices[2][1],self.indexbox_choices[3][1],self.indexbox_choices[4][1])         )          while True:             if choices_msg == 0:                 self.get_loopnums_ForPanel('start')# 写这里是因为要每次点击都获取新的随机数                 # 按钮返回 0 则去机选随机号码展示给用户                 choices_msg = m_easygui.indexbox(                     msg=self.marge_msgs_get_loopnums_ForPanel,                     title=self.box_title[3],                     choices=(self.indexbox_choices[2][1],self.indexbox_choices[3][1],self.indexbox_choices[4][1])                 )             elif choices_msg == 1:                 # 按钮返回 1 则去获取最新号码展示给用户                 choices_msg = m_easygui.indexbox(                     msg=self.marge_msgs_get_nums_ForPanel,                     title=self.box_title[3],                     choices=(self.indexbox_choices[2][1],self.indexbox_choices[3][1],self.indexbox_choices[4][1])                 )             elif choices_msg == 2:                 # 直接结束                 break             else:                 # 这里比如直接关闭 返回了 None                 break   app_run = EasyGuiUI() app_run.init_EasyGuiUI() # app_run.get_loopnums_ForPanel() 

[Angular] ngx-center 单运行时多项目共享依赖解决方案

Posted: 11 Jun 2021 02:45 AM PDT

https://github.com/wszgrcy/ngx-center

  • 本来用 ng 的人就少...估计了解我这个的就更少了.
  • 主要是用来解决当项目足够大时,打包时间膨胀,申请内存膨胀的问题
  • 原理就是先打包依赖(dll),再打包主项目,同时主项目实现了内置的 dll,然后打包子项目,子项目可以使用到内置的 dll 来保持住各种依赖注入...
  • 觉得有啥缺点,不足尽管来提吧

关于 黑苹果 固定启动项问题

Posted: 11 Jun 2021 02:12 AM PDT

电脑两块硬盘,一块安装黑苹果 10.15 ,另一块安装 win10 。黑苹果使用最新 OC_0.7.0 引导 。 问题: 进入引导界面后,按 ctrl+enter ( OC 手册写着是选择默认引导)选择 MACOS,正常进入 MACOS 之后无论冷热启动都会默认进 MACOS,这是正常的 。。。但是,当我选择 win10 启动后(只按 entet 确认,不按 ctrl+enter ) 只要重启,无论冷热都会变成 WIN10 引导,不会默认选择 MACOS 。 这是不是 OC 的 BUG ?还是有解决办法? 配置文件的 AllowSetDefault 已设为 ture 。

求 sql 优化才几万数据查询都破 1s 了

Posted: 11 Jun 2021 01:11 AM PDT

从用户表中按 jifen_all 获取我的排名。

SELECT b.rank FROM         (         SELECT t.id, @rownum := @rownum + 1 AS rank                    FROM (SELECT @rownum := 0) r,                    (SELECT id FROM fa_bankgy_dsxx_user ORDER BY jifen_all DESC) AS t                    ) AS b WHERE b.id = 29605; 				 

CREATE TABLE `fa_bankgy_dsxx_user` (   `id` int(11) NOT NULL AUTO_INCREMENT,   `nickname` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,   `openid` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,   `avatar` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,   `realname` varchar(24) COLLATE utf8mb4_unicode_ci NOT NULL,   `mobile` varchar(24) COLLATE utf8mb4_unicode_ci NOT NULL,   `province` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,   `city` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,   `area` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,   `workunit` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,   `exchange_count` int(11) DEFAULT '0',   `dati_count` int(11) DEFAULT '0' COMMENT '答题次数',   `rank_fen` int(11) DEFAULT '0',   `jifen_all` int(255) DEFAULT '0', 累计积分数量   `jifen` int(11) NOT NULL DEFAULT '0',   `createtime` int(11) NOT NULL,   `updatetime` int(11) NOT NULL,   `deletetime` int(11) DEFAULT NULL,   PRIMARY KEY (`id`),   KEY `jifen_all` (`jifen_all`),   KEY `openid` (`openid`),   KEY `workunit` (`workunit`) ) ENGINE=MyISAM AUTO_INCREMENT=33259 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci 

jifen_all 加了索引,怎么避全表扫描又能取出排名?

关于 nacos 的几个疑问

Posted: 10 Jun 2021 11:59 PM PDT

由于工作原因最近有在接触 nacos,遇到几个疑问的点:

1 、一般在接入 nacos 配置中心时里面都放什么配置?

据官网文章 典型的应用场景 描述,数据库连接信息、限流阈值和降级开关是很好的实践。

  • 数据库连接信息 是在项目启动时读取的,假设当前是独立的 SpringBoot 的应用(没有使用 SpringCloud ),又无法直接在项目启动时从 nacos 中获取配置。这点在官网 issue 中找到类似的疑问。如果我现在就想把数据库信息托管在 nacos,必须使用 SpringCloud ?
  • 限流阈值和降级开关,关于这点,与将这些信息放在 Redis 、ZK 等中间件,有什么区别?

2 、动态 key 该如何访问?

下面是网提供的例子,访问的静态 key 。简单的 k-v 配置。

@NacosValue(value = "${useLocalCache:false}", autoRefreshed = true) private boolean useLocalCache; 

假设现在有个 业务项配置 需要根据 某个用户参数 进行获取(key 里包含动态数据),这种场景在 nacos 下面是否可行?假如可行,如何实现?

请教运维大佬, strace -p [pid] 没有任何输出,但是该 pid 占用 CPU 百分百

Posted: 10 Jun 2021 11:44 PM PDT

我们有一套 GatewayWorker 程序,分配 4 条进程服务 昨天更新代码,一段时间之后出现某几条进程 cpu 占用 100%,用 strace 跟踪该 pid,没有任何信息输出,请教大佬们有没有排除问题的思路 初步怀疑是由于客户端某个操作,触发了程序内部的死循环,导致,但是程序大大说没发现有什么死循环的代码

有几个关于 etcd 部署的问题想问问大家

Posted: 10 Jun 2021 09:35 PM PDT

最近发现 master 节点上的组件运行都不正常,最后查到了是磁盘 I/O 性能不行导致 etcd 落盘变慢从而影响了其他组件的运行。我们的 etcd 是运行在虚机机上的,可能有其他的机器 I/O 高影响了 etcd 的机器。

有三个问题问问大家:

1 、你们的 etcd 是运行在和其他 master 节点组件一起部署的吗?

2 、etcd 是运行在虚机上还是物理机?如果是虚机的话会避免和其他虚机部署在同一个物理机吗?

3 、etcd 的数据目录是单独挂盘吗?是机械硬盘还是 SSD 呢?因为我看了 etcd 官网是推荐 etcd 部署在 SSD 上的?

AWS EC2 想用负载均衡器监控一个 HTTP 主机是否工作正常,但一直搞不定

Posted: 10 Jun 2021 08:32 PM PDT

在 AWS 上弄了一个免费的 EC2 实例玩,部署的是 windows server 2019 和 Tomcat8.5

Tomcat 上做了一个非常简单的 webapp,只有一个静态的网页 index.html,http 协议,8080 端口。

安全组和 windows 的防火墙里都把 8080 打开了,并且测试过浏览器也能正常访问这个静态网页。

现在想用负载均衡器监控这个 http 服务是否工作正常,侦听器也设置好了 HTTP 8080,但实例一直无法被监听器 ping 通。明明用浏览器可以打开,实在想不通问题出在哪里。请各位大佬指教。

负载均衡器的监听器设置如下: https://imgtu.com/i/2WEaSe https://imgtu.com/i/2WEdQH

index.html 放在 webapp/test/index.html,浏览器的访问方式是 http://IP 地址:8080/test

麻烦大家帮忙看看问题所在,非常感谢!

Recent Questions - Stack Overflow

Posted: 12 Jun 2021 10:12 AM PDT

Recent Questions - Stack Overflow


How to comment on .tsx file?

Posted: 12 Jun 2021 10:11 AM PDT

I want to comment TSX code that I showed below. How can I do that?

<Form.Group controlId="type"> <Form.Label>Type</Form.Label>

How to prevent overflow when when using animations

Posted: 12 Jun 2021 10:11 AM PDT

I have a container div with overflow: auto (this can't be removed) and within it there's another div that toggles between showing and hiding using an animation when a button is clicked. The problem is that when this div moves down it causes an overflow. Keep in mind that this div must be within the container.

Example of the problem https://jsfiddle.net/wg3jzkd6/1/

The expected result:

  • Div moves down without causing overflow

Conditional counts in pandas group by

Posted: 12 Jun 2021 10:11 AM PDT

I have the following dataframe enter image description here

I want to reformat it in the following way:

  1. Group by name/account/monthly periods
  2. Average (mean) balance to two decimal places
  3. Average (mean) for transactions to no decimal places
  4. Count of days where balance < 0
  5. Count of days where Balance > Max credit

So the I apply the following function to make a Series of all the aggregations, and use the Series index as labels for the new columns:

 def f(x):      d = {}      d['Avg_Transactions'] = x['Transaction'].mean().round()      d['Avg_Balance'] = x['Balance'].mean().round(2)      d['Zero_Balance_days'] = (x['Balance'] < 0).count()       d['Over_Credit_days'] = (x['Balance'] > x['Max Credit']).count()      return pd.Series(d, index=['Avg_Transactions', 'Avg_Balance', 'Zero_Balance_days', 'Over_Credit_days'])    month = df.groupby(['Account','Name', 'Month']).apply(f)  

Which gives the following output: enter image description here

But I am getting the conditional counts wrong and instead counting all days. What would be the proper way to write these?

Swift iOS 14 Firebase Warning - This Old-Style Function Definition Is Not Preceded By a Prototype

Posted: 12 Jun 2021 10:11 AM PDT

I have an app with Firebase integration to connect analytics using cocoapods. It was working well without any yellow warnings for iOS 13, but when I installed the new cocoa pods for target iOS 14 and build the app I get 6 yellow warning messages

"XXXPods/GoogleUtilities/GoogleUtilities/Logger/GULLogger.m:130:20: This old-style function definition is not preceded by a prototype"

GULLogger.m Warnings

When I was looking for answers online, there are only few and pointing to Flutter. I don't have Flutter for this app and I don't think I will be needing one. Does anyone else have the same issue? How can this be silenced for iOS 14 please?

I can downgrade the pods to iOS 13 but the whole point was to update the version. Thank you for any help/direction

Python adding outlook color categories to specific emails with a loop

Posted: 12 Jun 2021 10:11 AM PDT

I am trying to add color categories to existing emails in a given outlook folder based on criterias such as email object and/or sender email address.

I found a way to do it with VBA but I would like to use python not sure if the code can easily be "translated" from VBA to python?

import win32com.client as client  import win32com  import pandas as pd    outlook = client.Dispatch("Outlook.Application").GetNamespace('MAPI')    main_account = outlook.Folders.Item(1)  second_account = outlook.Folders.Items(3)    df = pd.read_excel (r'C:\Python\test.xls')    df_outlook_folder = df['Outlook_folder'].tolist()  df_mail_object = df['Mail_object'].tolist()    out_iter_folder = main_account.Folders['Inbox'].Folders['TEST']    fixed_item_count = out_iter_folder.Items.Count  item_count = out_iter_folder.Items.Count    if yout_iter_folder.Items.Count > 0:      for i in reversed(range(0,item_count)):          message = out_iter_folder.Items[i]          for y,z in zip(df_mail_object,df_outlook_folder):              try:                  if y in message.Subject:                       message.Move(second_account.Folders['Inbox'].Folders['TESTED'].Folders[z]              except:                  pass  item_count = out_iter_folder.Items.Count  print('Nb mails sorted:',fixed_item_count - item_count)  

the code above enables me to move emails based on the mail object but I am not able so far to add a feature to also change the outlook color categories

I spent time on the following doc without success so far https://docs.microsoft.com/en-us/office/vba/api/outlook.categories

Many thanks !

find cumulative number of shops of past 12 month in mongodb

Posted: 12 Jun 2021 10:11 AM PDT

I want to find the cumulative number of shops of past 12 month. Query must return result something like

[{    date: 'Aug-2020',    numShops: 100,   // Total number of shops until aug-2020  }, {    date: 'Sep-2020'    numShops: 230, // Total number of shops until sep-2020  }, ....  ]  

Change Products by Form in Django

Posted: 12 Jun 2021 10:10 AM PDT

I have two models about my products

class Product(models.Model):      product_model = models.CharField(max_length=255, default='', verbose_name="نام محصول")      product_url = models.SlugField(max_length=200, default='', verbose_name="اسلاگ محصول" )      description = tinymce_models.HTMLField(verbose_name="توضیحات")      size = models.ManyToManyField(Size , verbose_name="سایز", related_name="rel_size")  ...    class Size(models.Model):      size = models.CharField(max_length=20)      size_url = models.SlugField(max_length=200, default='', verbose_name="اسلاگ سایز")    class Stock(models.Model):      amount = models.PositiveIntegerField(verbose_name="موجودی انبار")      product = models.ForeignKey(Product, on_delete=models.CASCADE, verbose_name="محصول")      size = models.ForeignKey(Size, on_delete=models.CASCADE, verbose_name="سایز")      product_price = models.FloatField(null=True, verbose_name="قیمت محصول")  

we have L M Xl XXL sizes and in views.py i have:

def product_detail(request, product_url):      if request.user.is_authenticated and request.user.is_staff or request.user.is_superuser:          product = get_object_or_404(Product, product_url=product_url)          stock = get_list_or_404(Stock, product=product)          if request.method == "POST":              amount = request.POST['amount']              price = request.POST['price']              stock.amount = amount              stock.product_price = price              stock.save()          ctx = {'product':product, 'stock':stock}          return render(request, 'staff/product_detail.html',ctx)             else:          return redirect('/staff')   

and my html :

<div class="container-fluid">      {{product.product_model}}      <br>      <br>      {% for sto in stock %}      <form method="POST" class="register-form" id="register-form">          {% csrf_token %}          <p>{{sto.size}}</p>          <input type="text" value="{{ sto.amount | default_if_none:""   }}" name="amount" id="lo" placeholder="موجودی"/>          <input type="text" value="{{ sto.product_price | default_if_none:""   }}" name="price" id="lo" placeholder="قیمت (تومان)"/>          <br>          <input type="submit" name="signup" id="signup" class="form-submit" value="ذخیره"/>      </form>          {% endfor %}      <br>  </div>  

My problem is that each size has own amount and price from a product, like each product has 1 or more size it can be one or more, how can I edit models by "for" in my html ? or any best other way?

How can I design the code in VBA in order to refer to a previously already newly created workbook in Excel?

Posted: 12 Jun 2021 10:10 AM PDT

How can I refer in VBA to a previously newly created workbook within the same macro? For example, I copy something from A2 in the active workbook, then I create a new workbook, paste there in cell B3, return to the first workbook, copy cell A3, return again to the newly created workbook and paste in in cell B4.

So, what I need is the code for this part of the sentence: "return again to the newly created workbook"

My code till now is this:

        `Selection.Copy`          `Workbooks.Add`          `Range("B3").Paste`          `Windows("First_WorkBook.xlsm").Activate`          `Range("A3").Select`          `Selection.Copy`  

The last two lines are missing: returning to the new workbook and pasting there.

Can you please help me with this issue?

How to make an outlier detection function from scratch?

Posted: 12 Jun 2021 10:10 AM PDT

I ve got some data on Premier League players and I want to check for outliers. Boxplots show several outliers in some variables. However, I have created a function to detect them into a list, but returns an empty outlier list:

numeric_cols = [x for x in df if df[x].dtype != "object"]  def outlierdetector(x):  for i in x:      mn = df[i].min()      mx = df[i].max()      iqr = stats.iqr(df[i])      outlier = [o for o in df[i] if o < mn or o > mx]      print("COLUMN:", i,"\nMIN:", mn, " MAX:",mx," IQR:",iqr, "\nOutliers:", outlier, "\n\n")  outlierdetector(numeric_cols)  

What is wrong with the function so that it does not return outlier values? Thank you

Restore deleted script blocks

Posted: 12 Jun 2021 10:10 AM PDT

please help, I accidentally removed a huge portion of my codes in Google Script and accidentally saved it. Is there any way I can "Undo" and I get my previous version back?

React and Springboot : axios requests not shown in browser devtools

Posted: 12 Jun 2021 10:10 AM PDT

I'm trying to follow a tutorial on React(frontend) and Springboot(backend) and I face a little problem when making an http POST request with Axios on Mozilla and Chrome. I try to post some data to a REST api that I set up and save it in an H2 in-memory database. If I use an HTTP client like Postman, it works fine but when I use a web browser as a client, here are some issues :

  • On Chrome, when I submit the form, I don't see any trace of the triggered request in the Network tab of the console while the data is saved in the database. I also have this browser error message when I run my React client :

console error shown in Chrome when running my app

  • On Firefox, the request doesn't hit my rest controller endpoint and no data is persisted. But I get this error message

error message in Firefox when submitting the form

I configured my CORS, checked proxy config in package.json but I don't get what the issue is.

my http post method called from my form component when submitted

import axios from 'axios';    const API_URL = 'http://localhost:8080/api/v1';    export const signup = (user) => {      const headers = {"Accept": "application/json", 'Content-Type': 'application/json'};      return axios.post(API_URL + '/auth/signup', user, {headers})      .then(res => console.log(res));  };

my package.json

{    "name": "project-frontend",    "version": "0.1.0",    "private": true,    "proxy": "http://localhost:8080",    "dependencies": {      "@testing-library/jest-dom": "^5.11.9",      "@testing-library/react": "^11.2.4",      "@testing-library/user-event": "^12.6.3",      "axios": "^0.21.1",      "http-proxy-middleware": "^2.0.0",      "react": "^17.0.1",      "react-dom": "^17.0.1",      "react-scripts": "4.0.1",      "web-vitals": "^0.2.4"    },    "scripts": {      "start": "react-scripts start",      "build": "react-scripts build",      "test": "react-scripts test",      "eject": "react-scripts eject"    },    "eslintConfig": {      "extends": [        "react-app",        "react-app/jest"      ]    },    "browserslist": {      "production": [        ">0.2%",        "not dead",        "not op_mini all"      ],      "development": [        "last 1 chrome version",        "last 1 firefox version",        "last 1 safari version"      ]    }  }

My rest controller

package com.project.project.auth;    import com.project.project.shared.HttpResponse;  import com.project.project.user.User;  import org.springframework.beans.factory.annotation.Autowired;  import org.springframework.web.bind.annotation.*;    import java.util.logging.Logger;    @CrossOrigin(origins = "http://localhost:3000")  @RestController  @RequestMapping("/api/v1/auth")  public class AuthController {        @Autowired      private AuthService authService;        public Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);        @PostMapping("/signup")      public HttpResponse signup(@RequestBody User user) {          logger.info("AUTH_CONTROLLER : I'am in signup method");          authService.save(user);          HttpResponse response = new HttpResponse("User saved succesfully !");          return response;      }  }

Is there any solution for the following error ? Its actually while running the web app in shiny. Although i installed all the necessary packages

Posted: 12 Jun 2021 10:10 AM PDT

runApp() Warning: package 'shinyWidgets' was built under R version 3.6.3 Error: package or namespace load failed for 'shinyWidgets' in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called 'bslib'

How to run non-web docker container on AWS ECS

Posted: 12 Jun 2021 10:10 AM PDT

What I have are Python Scripts that listen to SQS and Process messages received from those.These are dockerized and uploaded to ECR. What the requirement is to run this docker on ECS using EC2 and Scale up/in based on the number of messages from sqs.

The issue is I am not able to run the tasks defined, I think the reason for it is the health check is not set, so I set it to CMD_SHELL, ps aux | grep "Python" || exit 1 , but of no use can anyone help me with it. Also is it possible to run Non-Web application on ECS.

If anyone has any documents please point me put to it.

I am posting my container definition here

i-00bd43d507b521acc        {    "ipcMode": null,    "executionRoleArn": "arn",    "containerDefinitions": [      {        "dnsSearchDomains": null,        "environmentFiles": null,        "logConfiguration": {          "logDriver": "awslogs",          "secretOptions": null,          "options": {            "awslogs-group": "python-extract",            "awslogs-region": "us-east-1",            "awslogs-stream-prefix": "ecs"          }        },        "entryPoint": [          "/bin/sh",          "-c",          "/tmp/bin/main"        ],        "portMappings": [          {            "hostPort": 0,            "protocol": "tcp",            "containerPort": 80          }        ],        "command": null,        "linuxParameters": null,        "cpu": 256,        "environment": [        ],        "resourceRequirements": null,        "ulimits": null,        "dnsServers": null,        "mountPoints": [],        "workingDirectory": null,        "secrets": null,        "dockerSecurityOptions": null,        "memory": null,        "memoryReservation": 512,        "volumesFrom": [],        "stopTimeout": null,        "image": "<docker-registery:latest>",        "startTimeout": null,        "firelensConfiguration": null,        "dependsOn": null,        "disableNetworking": null,        "interactive": null,        "healthCheck": {          "retries": 3,          "command": [            "ps aux | grep "python" || exit 1"          ],          "timeout": 5,          "interval": 30,          "startPeriod": 5        },        "essential": true,        "links": null,        "hostname": null,        "extraHosts": null,        "pseudoTerminal": null,        "user": null,        "readonlyRootFilesystem": null,        "dockerLabels": null,        "systemControls": null,        "privileged": null,        "name": "python-extract"      }    ],    "placementConstraints": [],    "memory": "1024",    "taskRoleArn": "arn:aws:iam::<is>:role/ecsTaskRole",    "compatibilities": [      "EC2",      "FARGATE"    ],    "taskDefinitionArn": "<ecsTaskRole>",    "family": "map-extractor",    "requiresAttributes": [      {        "targetId": null,        "targetType": null,        "value": null,        "name": "com.amazonaws.ecs.capability.logging-driver.awslogs"      },      {        "targetId": null,        "targetType": null,        "value": null,        "name": "ecs.capability.execution-role-awslogs"      },      {        "targetId": null,        "targetType": null,        "value": null,        "name": "com.amazonaws.ecs.capability.ecr-auth"      },      {        "targetId": null,        "targetType": null,        "value": null,        "name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"      },      {        "targetId": null,        "targetType": null,        "value": null,        "name": "com.amazonaws.ecs.capability.docker-remote-api.1.21"      },      {        "targetId": null,        "targetType": null,        "value": null,        "name": "com.amazonaws.ecs.capability.task-iam-role"      },      {        "targetId": null,        "targetType": null,        "value": null,        "name": "ecs.capability.container-health-check"      },      {        "targetId": null,        "targetType": null,        "value": null,        "name": "ecs.capability.execution-role-ecr-pull"      },      {        "targetId": null,        "targetType": null,        "value": null,        "name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"      },      {        "targetId": null,        "targetType": null,        "value": null,        "name": "ecs.capability.task-eni"      },      {        "targetId": null,        "targetType": null,        "value": null,        "name": "com.amazonaws.ecs.capability.docker-remote-api.1.29"      }    ],    "pidMode": null,    "requiresCompatibilities": [      "EC2"    ],    "networkMode": "awsvpc",    "cpu": "256",    "revision": 6,    "status": "ACTIVE",    "inferenceAccelerators": null,    "proxyConfiguration": null,    "volumes": []  }  

Any suggestion on whether it's possible to run non-server containers on ECS would be of great help or any one has done it please let me know what should be the healtchecks

Moshi parses List custom object to List that holds LinkedHashTreeMap

Posted: 12 Jun 2021 10:09 AM PDT

I have a list of custom objects that I want to parse and save in shared prefs.

internal fun putObjects(key: String, item: List<Any>) {      val listJson = toJson(item)      edit { it.putString(key, listJson) }  }    internal fun <T> getObjects(key: String): List<Any> {      val json = prefs.getString(key, "") ?: ""      val objectList: List<Any>? = fromJson(json)        return objectList ?: listOf()  }  

Moshi builder is created like this:

return Moshi.Builder()          ...          .addLast(KotlinJsonAdapterFactory())          .build()  

Expected result is ArrayList<XObject>, but instead Moshi returns ArrayList<LinkedHashTreeMap<String, String>>.

Discord.py Sqlite

Posted: 12 Jun 2021 10:11 AM PDT

How can I save the count of guilds in sqlite?

    @commands.Cog.listener()      async def on_guild_join(self,ctx, guild):          self.client.warnings[guild.id] = {}            db = sqlite3.connect("C:\\RDS\\Software\\Mythern\\Database\\database.sqlite")          cursor = db.cursor()          cursor.execute('''              CREATE TABLE IF NOT EXISTS guilds(              guild_count TEXT              )              ''')  

Using a Lambda function with a CloudFront distribution located in a different AWS account

Posted: 12 Jun 2021 10:09 AM PDT

I am wondering if a lambda function located in AWS account A can be used with a CloudFront distribution located in AWS account B. When I try, i get the following error. This leads me to think that it is probably not possible. But maybe it is a permission problem.

com.amazonaws.services.cloudfront.model.InvalidLambdaFunctionAssociationException: The CloudFront distribution under account 999999888888 cannot be associated with a Lambda function under a different account: 999999666666. Function: arn:aws:lambda:us-east-1:999999666666:function:cf_test_lambda:2 (Service: AmazonCloudFront; Status Code: 400; Error Code: InvalidLambdaFunctionAssociation;  

Loop three lines and print horizontally from csv file in bash

Posted: 12 Jun 2021 10:09 AM PDT

I have been trying to print two lines from the csv file to print horizontally and loop the next two lines and try to do the same.

The code which I have tried is

while IFS=, read -r name code;  do  echo "$name" "$code" | head -2 | tr ' '  done <  csvfile.csv  

The csv file contains

Albany, N.Y  Albuquerque, N.M.  Anchorage, Alaska  Asheville, N.C.  Atlanta, Ga.  Atlantic City, N.J.  

All I want is the output like

Albany, N.Y.    Albuquerque, N.M.  Anchorage. Alaska.  Asheville, N.C. Atlanta, Ga.  

and so on

Can anyone help me with this. I have tried different ways as suggested online but still no luck and am a newbie in bash scripting. Any help would really be appreciated. Thank you

how to check if a email is already in my database in python kivy app

Posted: 12 Jun 2021 10:10 AM PDT

main.py

def email_validate(self, email):      return_value2 = Database.validate()      print(email)      df1 = pd.DataFrame(return_value2)      print(df1)      if email != "":          for items in df1 == email:              content_box = BoxLayout(orientation="vertical", padding=40)              content_box.add_widget(Label(text="this email is taken"))              return_button = Button(text="Return", size_hint=(0.8, 0.4), pos_hint={'center_x': .5, 'center_y': .5})              content_box.add_widget(return_button)              popup_window = Popup(content=content_box, title="Error!",                                        size_hint=(None, None), size=(200, 200))              return_button.on_release = popup_window.dismiss              popup_window.open()  

Open SQLite connection in UWP right after moving StorageFile

Posted: 12 Jun 2021 10:10 AM PDT

Prologue:

I am writing SQLite GUI client for UWP. I use Microsoft.Data.Sqlite library for SQLite API with C#. Also I use a redirection table to be able to open database within my sandbox app which is published in Microsoft Store. Redirection table replaces CreateFileW to CreateFileFromAppW calls and similar.

Problem:

User has File -> Save as feature. When user creates a new database file is created inside app local directory. Next when user saves his/her database as I need to move this file. I use StorageFile API cause I cannot use any other file API within a sandbox app. So I call:

var savePicker = new Windows.Storage.Pickers.FileSavePicker();  savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;  savePicker.FileTypeChoices.Add("SQLite3 Database", new List<string>() { ".sqlite", ".db" });  savePicker.SuggestedFileName = "Database";  var file = await savePicker.PickSaveFileAsync();  if(null != file)  {                          Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(file);      sqliteConnection.Close();  // it is important cause if I skip this moving a file will fail      var localFolder = ApplicationData.Current.LocalFolder;      var currentStorageFile = await localFolder.GetFileAsync(App.UnsavedDatabaseFileName);  // here I obtain StorageFile for opened database      await currentStorageFile.MoveAndReplaceAsync(file);  // here I move a file      sqliteConnection = new SqliteConnection("Data Source=" + file.Path);      sqliteConnection.Open();  // this line fails with error 14: cannot open database file  }              

I also tried to skip closing and reopening a connection -> then moving a file fails. If I call FileOpenPicker between await currentStorageFile.MoveAndReplaceAsync(file); and sqliteConnection = new SqliteConnection("Data Source=" + file.Path); then everything will work fine but showing file open picker right after file save picker is a very bad user experience. I know that sandboxed app gives file access permission only after user selected a file manually. But it looks like that FileSavePicker does not give me a permission just like FileOpenPicker does. I could not find any info about it.

Epilogue:

This is the app https://sqliteman.dev. Please feel free to criticize cause it is what makes my app better.

How to efficiently create multidimensional arrays?

Posted: 12 Jun 2021 10:09 AM PDT

assuming I have any function such as

f(x, y, z) = xyz

what's the fastest way of calculating every value for f given three linear input arrays x, y, and z?

Of course I can do something along the lines of,

import numpy as np    x = np.linspace(-1., 1., 11)  y = np.linspace(-1., 1., 11)  z = np.linspace(-1., 1., 11)    for xi, xx in enumerate(x):      for yi, yy in enumerate(y):          for zi, zz in enumerate(z):              f(xi, yi, zz) = xx*yy*zz  

but this is probably not the best way to do it, especially if the input arrays become larger. Is there a better way of doing it, such as with a list comprehension (but multidimensional) or any other way? Help is appreciated.

How to change background video on scroll in React?

Posted: 12 Jun 2021 10:10 AM PDT

I am trying to change background video on scroll, using react-intersection-observer. When inView changes to true, useEffect must change state to sample2, and send new video to startscreen, where it's using as background video with position fixed. State is changing, but video is still the same.

//Startscreen

const Startscreen = ({ sample }) => {    return (        <VideoBg className="videoTag" autoPlay loop muted>          <source src={sample} type="video/mp4" />        </VideoBg>      </Container>    );  };  

//App.js

import sample1 from "./videos/0.mov";  import sample2 from "./videos/2.mov";    function App() {    const [state, setState] = useState(sample1);    const { ref, inView, entry } = useInView({      threshold: 0.5,    });      useEffect(() => {      if (inView === true) {        setState(sample2);      } else {        setState(sample1);      }      console.log(state);    }, [inView]);      return (      <div className="App">        <Startscreen sample={state} />        <div ref={ref}>          <AboutMe>       </div>      </div>  )};  

Select columns of multiple items in SQL on Laravel

Posted: 12 Jun 2021 10:09 AM PDT

I have something like that :

  • product 1 with rating rating2 rating3 etc... in my database
  • product 3 with rating rationg2 ratioN3 etc... in my database

My wish is to select all notations (given by members) to make the average rating.

I looked in the collections helpers but I don't found what I am looking for.

My goal is to make something generic, like an helper per example, but Im open to all method you can suggest to help me to do this.

One more difficulty is that Im showing all the products on the same page....

Bests

Difference between localhost 3000 and 5000?

Posted: 12 Jun 2021 10:10 AM PDT

While using NodeJS, the URL was localhost:3000 and while using flask, it was localhost:5000. Why are they different if both running on same browsers. What is the key difference? Are there any others in different web technologies? Can we run NodeJS on 5000 and flask on 3000?

Button in UICollectionView's Cell not working

Posted: 12 Jun 2021 10:11 AM PDT

I added a button to my collection view, but I cannot press it. I coded it so it would print something to the console as a test, but it still didn't work. The UIButton is connected to the respective class as well. they're connected

This is the code:

@IBAction func plusTapped(_ sender: UIButton) {          print("presses!")      }  

EDIT

This is what it looks like in the View Hierarchy Debugger. It seems that the UIButtonLabel is on top of the UIButton. wireframe

However, on the storyboard, I cannot find that UIButtonLabel. How do I remove the label?

what the storyboard looks like


Edit 2

So I dragged the button down so it could be at the top like suggested, but I still can't press on it.

enter image description here


Edit 3

The content inspector: enter image description here

The size inspector: enter image description here


Edit 4

This is what the View Hierarchy Debugger's inspector shows. enter image description here

The code:

extension ViewController: UICollectionViewDelegateFlowLayout {      func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {                    return CGSize(width: 180, height: 260)      }  }  

Edit 5

enter image description here


Edit 6

enter image description here

How to create a for loop to obtain correlations from a data frame in R?

Posted: 12 Jun 2021 10:10 AM PDT

I have the following data frame:

Gene <- c("1","2","3","4","5","6")  A1.1 <- c(1,1,2,4,3,5)  B1.1 <- c(1,2,3,4,5,6)  C1.1 <- c(2,2,3,5,5,5)  A1.2 <- c(1,2,3,5,5,5)  B1.2 <- c(3,2,5,6,6,6)  C1.2 <- c(1,1,2,2,4,6)  df <- data.frame(Gene, A1.1, B1.1, C1.1, A1.2, B1.2, C1.2)       Gene A1.1 B1.1 C1.1 A1.2 B1.2 C1.2  1    1    1    1    2    1    3    1  2    2    1    2    2    2    2    1  3    3    2    3    3    3    5    2  4    4    4    4    5    5    6    2  5    5    3    5    5    5    6    4  6    6    5    6    5    5    6    6  

So I need to obtain correlation values between columns of the same letter. So obtain the correlation values for A1.1 and A1.2, B1.1 and B1.2, and C1.1 and C1.2 for a total of 3 correlation values.

I can do this by using the cor() function for each (eg. cor(df$A1.1, df$A1.2)), but is there a for loop I could create that could obtain the correlations for all these at once?

How to delete "X" lines, when found "Y" line

Posted: 12 Jun 2021 10:10 AM PDT

I have a .txt with contacts like this:

(line 1) Andrew
(line 2) andrew@email.com
(line 3) 314657463
(line 4) Ariana
(line 5) ariana@email.com
(line 6) 1026479657
(line 7) .
(line n) ...

(each value is in a diferent line)

I am trying to make a code (Python) to delete 1 full contact (name, email and phone number) given the NAME.

The thing is, I haven't been able to delete the email and the phone number.

Try is what I tried:

def delete_someone():      Y=input("Enter the full name:")      archivo=open("agenda.txt", "r")      count_lineas= archivo.readlines()      archivo.close()      archivo1= open("agenda.txt", "w")      for line in count_lineas:          if line.strip("\n")!= Y:              archivo1.write(line)      archivo1.close()  

aws quicksight create-analysis cli command

Posted: 12 Jun 2021 10:11 AM PDT

We have two different accounts:

  • one for developing
  • another clien prod account

We have cloudformation templates to deploy resources, during developing new features firstly we test on dev and then deploy to prod. But with quicksight it not so easy, there are no cloudformation templates for quicksight. We need to reacreate all reports in prod account, manually it is very hard. I found QuickSight API and create-analysis command but I don't understand how I can create analysis via this command.

Maybe someone have examples or know how to create analysis with cli?

(2027, 'Malformed packet') packet issue with SQLAlchemy

Posted: 12 Jun 2021 10:11 AM PDT

Environment

  • Amazon RDS Aurora - 2.03.1
  • MySQL Innodb - 5.7.12
  • SQLAlchemy - 1.2.18
  • Python - 3.6.7

I have this table

class Users(Base):      __tablename__ = "users"        id = Column(Integer, primary_key=True)      user_id = Column(String(64))      email = Column(String(64))      first_name = Column(String(100))      last_name = Column(String(100))      mobile = Column(String(100))      last_org_session = Column(ForeignKey("organizations.id"))   

I am using the session.query version of querying.

updated_by_user_query = select([Users.id, Users.first_name, Users.last_name]).where(           Users.id == obj["updated_by"]       )       updated_by_user = session.execute(updated_by_user_query).first()  

This issue is that when tested locally it works. But when tested on a staging environment, it raises a malformed packet error issue.

I have confirmed that localhost and staging are using the same environment and database.

Any ideas what I should do?

Appium/Protractor - Cordova app - When I try to run simple test I get following error - Failed to get sockets matching: @webview_devtools_remote_

Posted: 12 Jun 2021 10:11 AM PDT

I'm trying to run a simple test on my hybrid app with Appium + Protractor and I am unable to since I am getting following error: Failed to get sockets matching: @webview_devtools_remote_.*15239

I am using Ubuntu, and on it I have set up Appium and Protractor, tried literally every solution I have found on the internet, could not resolve the issue.

Only thing that would "remove" the error is adding following code into capabilities:

chromeOptions: {      androidPackage: "com.android.chrome"  },  

But then I only get in the app, and Appium server just gets stuck at:

[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8001/wd/hub/session] with body: {"desiredCapabilities":{"chromeOption {"androidPackage":"com.android.chrome","androidUseRunningApp":true,"androidDeviceSerial":"1cdc4ed10c027ece"}}}  

It won't start the spec file at all.

var SpecReporter = require('jasmine-spec-reporter').SpecReporter;

exports.config = { seleniumAddress: 'http://localhost:4723/wd/hub', allScriptsTimeout: 50976,

specs: [      'test.js'  ],    capabilities: {      platformName: 'Android',      platformVersion: '8.0.0',      deviceName: 'Galaxy S9',      app: 'path_to_app',      autoWebview: true,      browserName: '',      appPackage: 'app_package_name',      newCommandTimeout: '140',        chromeOptions: {          androidPackage: "com.android.chrome"      }     },    onPrepare: function () {  jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));  },    framework: 'jasmine',    jasmineNodeOpts: {  print: function () {}, //remove protractor dot reporter  defaultTimeoutInterval: 100000  }  

}

Restoring mongodb database with different name

Posted: 12 Jun 2021 10:10 AM PDT

I've been doing periodic (every 24 hour) backups of my mongodb instance. This works great, and I can restore them on my staging server with no problem:

time mongorestore  --ssl --gzip --authenticationDatabase=admin \      --host=fra-mongo-staging-1.example.com --port=27017        \      --username=restore --password=secret --archive="$snapshot_name"  

But the dbname in production is example_prod, whereas on the staging server I'd like to restore to example_staging. So I type this:

time mongorestore  --ssl --gzip --db "$dbname" --authenticationDatabase=admin \      --host=fra-mongo-staging-1.example.com --port=27017                       \      --username=restore --password=secret --archive="$snapshot_name"  

The only difference is the --db "$dbname" (where $dbname is example_staging). This doesn't work: I see the lines about preparing, then it says done, but nothing is restored.

2019-02-07T11:16:36.743+0000    the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead  2019-02-07T11:16:36.772+0000    archive prelude example_prod.surveys  2019-02-07T11:16:36.773+0000    archive prelude example_prod.settings  2019-02-07T11:16:36.773+0000    archive prelude example_prod.spines  2019-02-07T11:16:36.773+0000    archive prelude example_prod.reduced_authors  2019-02-07T11:16:36.773+0000    archive prelude example_prod.delayed_backend_mongoid_jobs  2019-02-07T11:16:36.773+0000    archive prelude example_prod.email_events  2019-02-07T11:16:36.773+0000    archive prelude example_prod.authors  2019-02-07T11:16:36.774+0000    archive prelude example_prod.crowberry  2019-02-07T11:16:36.774+0000    archive prelude example_prod.bitly  2019-02-07T11:16:36.774+0000    archive prelude example_prod.mytestcollection  2019-02-07T11:16:36.774+0000    archive prelude example_prod.reviews  2019-02-07T11:16:36.774+0000    archive prelude example_prod.books  2019-02-07T11:16:36.774+0000    archive prelude example_prod.candy_events  2019-02-07T11:16:36.774+0000    archive prelude example_prod.features  2019-02-07T11:16:36.774+0000    archive prelude example_prod.elderberry  2019-02-07T11:16:36.776+0000    preparing collections to restore from  2019-02-07T11:17:02.403+0000    done  

I've also tried using --tsFrom=example_prod --tsTo=example_staging, no joy.

Any suggestions on the right way to do this?

1 comment:

  1. Magnificent News: E-Techbytes >>>>> Download Now

    >>>>> Download Full

    Magnificent News: E-Techbytes >>>>> Download LINK

    >>>>> Download Now

    Magnificent News: E-Techbytes >>>>> Download Full

    >>>>> Download LINK 40

    ReplyDelete

End of Summer Sale ☀️😎

20% OFF Inside!🤯 ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏...