Response stringlengths 15 2k | Instruction stringlengths 37 2k | Prompt stringlengths 14 160 |
|---|---|---|
The storage location for the retain count depends on both the runtime in use and the class implementation.For Apple's Objective-C runtime, you can figure out a lot by digging intothe source code of the Objective-C runtime.For example, if you're using ARC (and I think even if you're not), the reference counts for most objects are stored in hash tables. Have a look at the_objc_rootRetainfunction inruntime/objc-arr.mm. I don't know exactly why they did this. Perhaps it's a way of keeping retain counts together for better cache behavior (which is important under ARC because ARC adjusts retain counts more often than non-ARC code usually does).However, some classes overrideretainand related methods and store the retain count elsewhere. For example, when debugging a memory leak I discovered thatCALayerdoes this. Instead of using the runtime's normal retain count mechanism, aCALayerstores its retain count in a private C++ implementation object. This is rather frustrating because it means the Instruments Allocations instrument doesn't log retains and releases ofCALayerobjects. | I am curious about how retain/release work internally. On the face, it seems like there's an integer related to each instance of anNSObject, which gets increased and decreased when you call-retainand-release, respectively.But taking a look atNSObject, the only instance variable it has is theisavariable, for determining its class type.So where are retain counts for individual objects stored? Not that I'm going to muck around with it, but just for my own edification.Is it stored with theNSObject, but hidden away in some Objective C implementation detail? If so, that seems like a bad design to me. Oneshouldbe able to create their own root class and handle their own retain/release counting in a similar fashion (not that it's a good idea--one would have to have averygood reason not to useNSObject). | Where is the retain count stored for NSObjects in Objective C |
The solution is to use Git-Hooks and feature branches. (The Github-flow is recommended).
You have to install this Git-Hook (copy a file to your local repository):
https://github.com/ktamas77/git_hooks
Before you start working on a particular Pivotal Ticket, you create a branch prefixed with the Pivotal Tracker ID, for an example:
git checkout 1234567_build_new_form
then add all your changes as you'd do normally:
git commit -am 'form added'
git commit -am 'styles added'
git push origin
you'll see, the git hook script will automatically extract the Pivotal Tracker ID from the feature branch name and add it to the front of each comment. You can still manually override it (with another ID) if you want.
In this way you don't have to worry about adding the Pivotal ID manually for every single commit. It also works with GUIS (such as GIT Tower) since these GUIs are using the standard GIT libraries / executables.
|
Pivotal Tracker and Github have great integration: Once it's set up, each commit which is prefixed by the Pivotal Tracker ID will appear under the corresponding Pivotal Ticket automatically, for an example:
git commit -am '[#1234567] my new changes'
git push origin
will add the comment 'my new changes' automatically to the 1234567 Pivotal Ticket among with the github commit link.
However, it's easy to forget to add the ticket ID each time. How could it be simplified / automated?
| How can I automate Pivotal Tracker & Github Integration? |
You canfiltercontainers which publish or expose a given port:docker ps --filter=expose=3306or use theformatswitch to get a list of container IDs with the used ports:docker ps --format "{{.ID}}: {{.Ports}}"ShareFollowansweredAug 2, 2018 at 19:21Stefan PruggStefan Prugg27422 silver badges55 bronze badges11Thank you for your reply. The above commands are indeed very useful, but they show the ports that a given container islistening to, not the port being used by docker for traffic originating in the container.–James EarlyAug 3, 2018 at 15:32Add a comment| | I have a collection of IPv4 traffic recorded by tcpdump, and I am interested in mapping a given outgoing connection to its origin Docker container on the same machine. I can view the TCP source port, but it is unclear to me how to ask Docker which container is using this port. How can this be done?
Thanks | Map outgoing TCP connection to Docker container |
0
It is clear that, in stable condition with the read cache full, it needs more than 70% of disk cache.
Not all queues in read cache contain loaded data. The a1out queue which consumes 50% of disk cache size contains only information about pages which were loaded in a1in queue. So this queue contains so called "ghost entries" which in reality do not affect disk cache memory consumption. This queue is needed to provide additional statistical data overcome disadvantages of simple LRU cache.
Some space is took from the write cache or simply more space from the start is given to the read cache
Write cache and read cache share the same memory space, but part of the space exclusively belongs to write cache.
the "disk cache" involved is the RAM included with a common disk (HDD or SDD) and not the RAM of the machine;
We use RAM of server and do not use HDD buffer.
The default space of disk cache used by orientdb is 100%
It is used on 100% in case of high load of data, otherwise 15% now (not 30% as it is stated in documentation) is used only for write cache so is not used without presence of high data load.
Share
Improve this answer
Follow
answered Apr 18, 2016 at 15:20
Andrey LomakinAndrey Lomakin
65533 silver badges1212 bronze badges
Add a comment
|
|
I found out from the Docs that, given 100% usage of disk cache by orientdb, it uses a maximum size of 70% for read cache and 30% for write cache (http://orientdb.com/docs/last/plocal-storage-disk-cache.html#interaction-between-read-and-write-caches).
Reading more about the read cache, it's divided by 3 queque: a1in, a1out and am which their respectively maximum sizes are 25%, 50% and 75% of the read cache size (http://orientdb.com/docs/last/plocal-storage-disk-cache.html#queue-sizes).
It is clear that, in stable condition with the read cache full, it needs more than 70% of disk cache for the read cache. How is this handled? Some space is took from the write cache or simply more space from the start is given to the read cache?
Also, I would like to be sure that:
the "disk cache" involved is the RAM included with a common disk (HDD or SDD) and not the RAM of the machine;
the default space of disk cache used by orientdb is 100%, as written in the first link (possible to change with storage.diskCache.bufferSize parameter)
Thanks everyone!
| How disk cache in OrientDB is separated by read and write cache (percentages) |
As for thesafepart: Always keep a backup of your repository around and make sure you create a backup (by copying the directory to some other location) before you do anything that messes with git history.As long as it is only the order of the commits and the messages you want to change, I find git's interactive rebase (git rebase -i <sha-of-the-first-commit-you-want-tochange>) the most intuitive solution. It will open the commit history in an editor and you can change the order of commits by moving around lines and squash commits by prepending lines withsquash. The most important options and usage is documented when you open it.Note that this will change all the commit IDs, so you will need to force-push it to remotes that have theoldhistory. If your repo has any forks or is developed by others, make sure you inform them and consider whether a cleaner history is worth the trouble for everyone. | I have been working on a complicated github project which involved making many changes to the repository over and over again. Sometimes I ended up making many nasty and some times unnecessary commit messages that are making it it very difficult for new developers to understand how the project works.What would be the safest way for me to edit the commits and commit messages ?Currently I have 78 commits and I would like to make changes to previous commits (for example squash commit 34-38 or maybe edit to message of commit 51 and so on). | How to safely edit commits on a github repository? |
At https://api.github.com/repos/ruby/ruby/tags I dont'see the word ruby in any tags name.
The tags are sorted by name in reverse order (the same as a sort -nr)
You can download and extract the latest tag ruby tarball by:
LAST_URL=`cat ruby.json | grep -Po '(?<="tarball_url": ")[^"]* | egrep -v [a-z]$ | head -1'
wget $LAST_URL && tar -xvzf `basename $LAST_URL`
Some notes:
egrep -v [a-z]$ filters out non ruby packages, not finishing in a number (es. yarv_migration_base)
head -1 takes the first tag (in the form vX_X_X) in a reverse order, the most recent
|
So, I'd like to create a shell script that automates the process of downloading a package, unzipping it, cd'ing into it, configuring it, and compiling it from source.
I have started with a simple script below:
#!/bin/bash
PROJ=ruby
curl https://api.github.com/repos/$PROJ/$PROJ/tags -o $PROJ.json
cat $PROJ.json | grep -Po '(?<="name": ")[^"]*'
This fetches the JSON file for the Ruby project, and returns the latest(?) tag name (e.g. ruby_2_3_1).
However, I am dumb, and I'd like to expand more on this script. I would like to:
ignore any tags that don't include the word "ruby"
only fetch the latest tag (in this example, 2_3_1)
fetch the URL for tag 2_3_1 and download a tarball of the source code from that tag
unzip the tarball (unless it detects that this tarball has been unzipped before)
The rest I can do on my own, as I'm fairly familiar with ./configure, make, make install, etc.
Hopefully this isn't too difficult. I'd prefer not to use jq (just standard regex), but if it happens to be easier with jq, I'll be fine either way.
| Automating package compile process using GitHub API |
SonarSource has created a FLOSS migrater for just this case:https://community.sonarsource.com/t/end-of-life-of-mysql-support/8667You will use it to migrate your data from MySQL to Oracle and thus retain all your projects and their history. | How can I migrate the history from one sonarqube server to another in which the first is using MySQL as the database and the second one is using Oracle?I would like to have the history of scans of the old sonarqube in the new sonarqube server along with date and in a sequential manner. | How to migrate history from one sonarqube server to another? |
1
Is it possible to make apigateway a target group for an alb?
NO
As per the existing documentation currently you cannot have apigateway as the target group of ALB.
You can get more details here - load-balancer-target-groups.html
Is this a reasonable approach? Or would it make more sense to just move all the routing logic into apigateway? Or some other alternative?
Since Apigateway is not supported as a target group. I would recommend following approach based on the usecase
If you have a dynamic website with static and dynamic content
Backend
The backend can be served via the internal load balancer as shown in the below diagram. You can also skip the internal load balancer and directly hit the lamda function as you are currently doing. It can also be a kubernetes cluster or an EC2 instance behind the internal load balancer.
Frontend
The frontend can be served via an External Load Balancer. In you case you can send the requests directly to S3 via Cloudfront.
Share
Improve this answer
Follow
answered Aug 3, 2022 at 8:47
codeaprendizcodeaprendiz
2,91711 gold badge3232 silver badges5353 bronze badges
Add a comment
|
|
I am in the process of replacing nginx. Currently, my nginx instance routes traffic to an s3 bucket OR to apigateway (apigateway then routes traffic to different lambda functions).
Originally, I was considering replacing the nginx routing with an application load balancer, but I can't find any information on how to set up api gateway as a target group for the alb. Also for context, we want to keep our current apigateway as is.
My main questions are:
Is it possible to make apigateway a target group for an alb?
Is this a reasonable approach? Or would it make more sense to just move all the routing logic into apigateway? Or some other alternative?
Thanks in advance!
| Application Load Balancer in front of ApiGateway? |
Looks like you are confusing the fact that users, browsing online, will trigger standard requests to both "download" your static content,anduse your 2 APIs (book and api). It's not the NGINX service serving the static content that is accessing your APIs, but the users browsers/applications, and they do that exactly the same for both static content and APIs (former has more/specific headers and data, like auth...).On your diagram you'll want to put your newstatic-serviceat the exact same level as yourbook-serviceandapi-service, iebehindthe ingress. But yourstatic-servicewon't have a link with thedb-servicelike the other 2. Then just complete your ingress rules, with the static-service at the end as in this example:apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: your-global-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: foo.bar.com
http:
paths:
- path: /book-service
backend:
serviceName: book-service
servicePort: 80
- path: /api-service
backend:
serviceName: api-service
servicePort: 80
- path: /
backend:
serviceName: static-service
servicePort: 80You'll have to adjust your services names and ports, and pick the paths you want your users to access your APIs, in the example above you'd have:foo.bar.com/book-servicefor your book-servicefoo.bar.com/api-servicefor the api-servicefoo.bar.com/ie everything else going to the static-service | I have a smalljavawebapp comprising of three microservices -api-service,book-serviceanddb-serviceall of which are deployed on a kubernetes cluster locally using minikube.I am planning to keep separate UIs forapi-serviceandbook-service, with the common static files served from a separate pod, probably annginx:alpineimage.I was able to create a front end that serves the static files fromnginx:alpinereferring to thistutorial.I would like to useingress-nginxcontroller for routing requests to the two services.The below diagram crudely shows where I am now.I am confused as to where I should place the pod that serves the static content, and how to connect it to the ingress resource.I guess that keeping a front end pod before ingress defeats the purpose of ingress-nginx controller. What is the best practice to serve static files. Appreciate any help. Thanks. | How to serve static contents in a kubernetes application |
You can build an LRU cache using the standard JDK library using LinkedHashMap:
public class MyLRUCache<K, V> extends LinkedHashMap<K, V> {
private final int maxEntries;
public MyLRUCache(int maxEntries) {
// you can be a bit fancy with capacity and load factor
super(16, 0.75, true);
this.maxEntries = maxEntries;
}
@Override
protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
return size() > maxEntries;
}
}
You may want to play with WeakReferences as well.
|
Are there any implementations of a static size hashtable that limits the entries to either the most recently or most frequently used metadata? I would prefer not to keep track of this information myself.
I know most caching components keep track of this, but I would rather not introduce quite a lot of new dependencies.
| Frequently Used metadata Hashmap |
+50I am sorry because I don't fully understand your requirements, but maybe you could use tools likeskopeoin some way.Among other things, it will allow you to copy your container tar to different registries including AWS ECR without the need to install docker, something like this:skopeo login -u AWS -p $(aws ecr get-login-password) 111111111.dkr.ecr.us-east-1.amazonaws.com
skopeo copy docker-archive:build/your-jib-image.tar docker://111111111.dkr.ecr.us-east-1.amazonaws.com/myimage:latestThis approach is documented as well as apossible solutioninthis Github issuein theGoogleContainerToolsrepository.In the issue they recommend another tool namedcranewhich looks similar in its purpose toskopeoalthough I have never tested it. | Is there an AWS CLI command to simply load my image tar to AWS? (I do not have docker on my computer at all nor do I want to increase the image size of our CD pipeline as I prefer to keep it very very small since it adds to the time to start in circleCI/githubCI).Is there a way to do this?If not, what is the way to do this with docker so I do not have to upload into local docker registry and instead can just directly load to AWS ECR.Context:
Our CI job builds on the PR 'and' writes a version/build number on the image and into a file in CI on the PR as well BUT NONE OF THIS should be deployed yet until on master branch. PR cannot merge into master until up to date with master and a merge of master into PR triggers CI again so PR is guaranteed to be latest when landing on master. This CI job has the artifact that can be deployed by CD (ie. there is no need to rebuild it all over again which takes a while sometimes)
Our CD job triggers on merge to master and reads the artifacts and needs to deploy them to AWS ECR and the image for our CD is very very small having just AWS tooling right now (no need for java, no need for gradle, etc. etc.). | After jibBuildTar, what command to use to load to AWS ECR? |
You need to increase the maximum number of CPUs available to containers in the DockerServer. In OS X you can find them in Preferences -> Advanced. | I am currently using a Macbook Pro with i7, which has 8 cores. However, I am not able set the CPU cores to more than 1. When I rundocker run --cpus=2 "my-image"I get the following error:docker: Error response from daemon: Range of CPUs is from 0.01 to 1.00, as there are only 1 CPUs available.What am I missing? | Docker not able to use all of Macbook's CPU cores |
6
You need windows 10 Pro or Enterprise to have access to Windows containers.
Source
The other answer will indeed switch your daemon mode to Windows, but you will not be able to pull any Windows container.
Update 2022:
The link above now mentions that it should work for
Windows 11 64-bit: Home or Pro version 21H2 or higher, or Enterprise or Education version 21H2 or higher.
Windows 10 64-bit: Home or Pro 21H1 (build 19043) or higher, or Enterprise or Education 20H2 (build 19042) or higher.
Share
Follow
edited Jun 7, 2022 at 16:06
answered May 26, 2021 at 21:05
mababinmababin
19344 silver badges1616 bronze badges
3
2
This is correct, but needs to be clarified as the requirements say Win Home edition is compatible.
– code4days
May 11, 2022 at 20:53
This tripped me up, too. Win Home doesn't work for me even when I switch to "Windows containers". In fact, even when I switch, the option to switch back to "Linux containers" doesn't show. Still says switch to Windows containers, so I'm doubtful that is even happening.
– Matthew Allen
May 25, 2022 at 16:54
@MatthewAllen according to your actual Windows version you might need to upgrade to either a Pro or Enterprise edition. I had your exact issue when I found this solution.
– mababin
Jun 7, 2022 at 16:08
Add a comment
|
|
I have installed latest Docker Desktop. Currently unable to switch to Windows container. The option is blocked from task bar :
I am running Windows 10 Home 64-bit Build 19042.
| Docker Desktop cannot switch to Windows Container |
This is most likely because you're running an https redirect (or another redirect) inside another .htaccess file. So it is asking for the authentication once in http, and once in https. If you do this:<If "%{HTTPS} == 'on'">
AuthType Basic
AuthName "Password Area"
AuthUserFile "/yourdirectory/.htpasswd"
<IfVersion >= 2.4>
AuthMerging And
</IfVersion>
Require valid-user
</If>then it will only ask for the password once the redirect has happened. Otherwise, get rid of the second redirect. | I use .htaccess to ask for credentials to access members only data. The .htaccess file is stored in one of the directories and protects everything in directories below it. The .htaccess file itself is very simple:AuthName "Members Area"
AuthType Basic
AuthUserFile /home/xxxxx/public_html/xxx/data/.htpasswd
require valid-userProblem is, when we moved to a new server (and built the new website within that directory using WordPress), the Authentication Box now comes up twice and requires users to enter the same correct login information both times.I've read in other strings here about trailing/, but since I don't have a redirect or anything else in my .htaccess, I'm not quite sure what to do.Anybody have any suggestions on a workaround or rewrite? | .htaccess requests correct login twice with .htpasswd and wordpress |
Your project is under source control.. As you can see the files marked with letters "R" (for Renamed) and "M" (for Modified) and "A" (for Added)
By default Xcode creates a local git repository for new project unless you uncheck that option
Check this out
Xcode will automatically add it under source control.
You just need to define a remote. Right click on the repository (from the git pane) and tap on "Add existing remote.."
|
I have created a project that I would like to push to my GitHub account. Unfortunately, I did not create a GitHub repository when creating the project. When I attempt to create a repository using Xcode by following the path of Source Control -> Create Git Repository, Xcode displays a popup stating that "all projects are already under source control." This is not the case and the project is not in my GitHub account. Here is a screen cap of the error. What am I missing?
| Cannot create git repository using Xcode 9 |
There is no problem with the given redirect rule. It seems problem is that OP is executing shown rule from<VirtualHost *:80>section. Those rules will obviously won't fire if request ishttps://. OP can do one of the two thing to fix the problem:Keep same redirect rule in<VirtualHost *:443>section as well -ORKeep rule in a common place like.htaccess | I'd like to permanently redirect my pages to https + www.I'm using the code below but it doesn't work when I enterhttps://example.com. It does nothing and displays the page without adding the www.RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L,NE] | Double conditions redirection |
There are several, for example lighttpd. Here is a description of how C plugins can be built for it.
NOTE
I want the source code of web server to be as less as possible.
The length of the source code is not a good metric for performance and memory use of a program.
|
I'm very new to Web server matters, and relatively a naive student of C++. I'm now working on a project where I have to create a Plugin to an existing web server. It is a commercial project for a company, but it's also my bachelor thesis project. I'm not quite sure which web server would be suitable for my project. The web server that I am looking for should handle the Network socket and present the http or https request as object,from which the plugin(That I want to develop) should read the header,url,data and translate(translating specially the SOAP and REST) it accordingly for the company's Data storage's Filesystem API and vice versa.The plugin has to be developed using C++.The server environment is Linux Cent OS 6. The normal staffs of the company has never worked with linux server environment before. Its a small company. They only worked with windows and IIS web server before. Our project manager is reluctant to use Apache because it has heavy footprint and it's slow, while IIS is not suitable for linux. So, we are looking for a free light-weight web server for linux.
I see that people talk a lot about Nginx, G-WAN, Cherokee, Lightspeed, Varnish, Tntnet etc. But I didn't really find any standarad source of judgement about the comparison of these web servers. So, please let me know, which web server would be preferable for me. Waiting for response.
| C++ compatibility for lightweight web servers |
It depends what you want to do; but basically, Redis is much more performant than CouchDB, and it is much more suitable for a cache system. Redis is an in-memory database (with options to sync to disk), with features for expiring data after a certain time.Redis is used often for caching, so it may be better in terms of scalability. If you already have Redis running now, then you will have no additional maintenance overhead compared to CouchDB. | I am using MongoDB for persisting data, and Redis for session storage. I need to cache a complex aggregation query done on MongoDB, so I was wondering what your opinions are on Caching on NodeJS, specifically caching with Redis or CouchDB.Which one is more performant? Correct me if I'm wrong, but is having a different database specifically for cache better in terms of scalability? | Cache on NodeJS - Redis vs CouchDB vs ..? |
Right after this I went to investigate testcontainers-go source code and found that that all I had to do was to define in myContainerRequestSkipReaper: true, | I'm using bitbucket pipelines to run my Go project tests that use Testcontainers.
Pipelines fail with message:Error response from daemon: authorization denied by plugin pipelines: --mounts is not allowed: creating reaper failed: failed to create containerSo I setexport TESTCONTAINERS_RYUK_DISABLED=truethat I found from Testcontainers Java docs. It doesn't seem to do anything.Usinggo 1.19.2andgithub.com/testcontainers/testcontainers-go v0.15.0 | Disable RYUK (Testcontainers for Go) |
If you use a Dockerfile, first you better to build your image.FROM node:12.17.0-alpine as builder
WORKDIR /app
COPY . .
RUN npm install
RUN npx prisma generate
RUN npm run build
## this is stage two , where the app actually runs
FROM node:12.17.0-alpine
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/dist ./dist
EXPOSE 8080
CMD ["npm","start"]From the location where yourDockerfilelocated:docker build -t your-image-name .docker run -p 3000:8080 --env-file .env your-image-name | I would like to put my Nodejs app into a docker. When deploying it via npm run build and start I can send requests to it.But when creating a docker image I getting problems:First I have an EXPOSE 8080 in my Dockerfile. Then I am runningdocker run -p=3000:8080 --env-file .env my-docker-file. After that I am getting the info that the server is running on http://localhost:3000.I know localhost:3000 ist just in the docker file. But at least the docker is running.When I use the commandhttp localhost:3000(or the browser) I am gettinghttp: error: ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) while doing a GET request to URL: http://localhost:3000/.Does someone have an idea what's going wrong??? I have no clue.tanks to all hints that directs me into the right direction.My Dockerfile:## this is the stage one , also know as the build step
FROM node:12.17.0-alpine as builder
WORKDIR /app
COPY package*.json ./
COPY prisma ./prisma/
COPY tsconfig.json .
COPY src ./src/
COPY tests ./tests/
RUN npm install
RUN npx prisma generate
COPY . .
RUN npm run build
## this is stage two , where the app actually runs
FROM node:12.17.0-alpine
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/dist ./dist
EXPOSE 8080
CMD npm start | ConnectionError in Docker with Nodejs (Hapi.js) and Prisma |
I found the solution:
FROM osgeo/gdal
RUN apt-get update
RUN apt install -y python3-pip
WORKDIR /work
COPY requirements.txt ./
RUN pip install -r requirements.txt
After that, you can install TF via requirements.txt file and you are done!
|
I'm using Docker to build and run my projects.
I need to use gdal library, but using pip install gdal I have lots of error, so I tried to download from https://github.com/OSGeo/gdal/tree/master/gdal/docker the GDAL docker images.
Now I would like to run my .py file but I have to import also TensorFlow and Numpy and other libraries. GDAL docker image, as I expected, doesn't come with other libraries.
Is there a way to build a new image from GDAL docker image and include other libraries?
I tried to make something similar with Nvidia TF docker image and it works (Dockerfile down below) without gdal library installed, but if I change FROM osgeo/gdal (name of GDAL image) I have an error pip can't be find.
#Dockerfile
FROM nvcr.io/nvidia/tensorflow:19.12-tf2-py3
WORKDIR /work
COPY requirements.txt ./
RUN pip install -r requirements.txt
Any advise?
| Add TensorFlow and Numpy libraries to osgeo/gdal docker image |
The basic abstraction in Spark is theRDD. If you look incore/src/main/scala/org/apache/spark/rdd/RDD.scalayou can findmap(),flatMap(), andfilter(), amongst others.But they are not terribly exciting. | I'm studying about mapreduce and spark, and I curious about how spark process the mapreduce work. Accordingly, I'm searching that in 'https://github.com/apache/spark', but Watching that site, I couldn't get any clue about which directory should I search to see mapreduce source code.I mean in following code, there are .flatMap(), .map() and .reduceByKey() function. Definitely, I want to see source code about these function.val textFile = sc.textFile("hdfs://...")
val counts = textFile.flatMap(line => line.split(" "))
.map(word => (word, 1))
.reduceByKey(_ + _)
counts.saveAsTextFile("hdfs://...")thank you | What kind of directory shoud I search to look for mapreduce source code in spark? |
I faced the same problem after upgrading to PHP 7.Upgrading PhpMyAdmin to the last version fixed the issue. | I am unable to export dbase from PhpMyadmin, on PHP7 and Nginx server.The/var/log/nginx/error.logsays18 FastCGI sent in stderr: "PHP message: PHP Fatal error: Cannot
'break' 2 levels in /usr/share/phpmyadmin/export.php on line 864I have already triedsudo apt install php7.0-mbstringandsudo service nginx restartbut still not working. | Phpmyadmin Export Dbase getting error on PHP7 Nginx |
git log --oneline
Copy the commit hash before merge one.
git reset --hard <copied-commit-hash>
git push --force (be carefully, it rewrites the remote history)
|
I have done some mess in my repo, which I don't understand at all.
A strange commit has appeared:
commit 70cc4bd585019286ef64ef591f1b6ab310484eb3 (HEAD, origin/master,
origin/HEAD, master) Merge: 960b06a 709f964 Author: DuchSuvaa
[email protected] Date: Tue Sep 12 15:46:05 2023 +0200
Merge branch 'master' of https://github.com/DuchSuvaa/monitor-kolejek
I don't really understand how that happened. Someone told me that git reset --hard HEAD~1 will do the job but when I do it, I am checkouted to the third (!) commit from the end and nothing is removed from GitHub.
How do I remove that problematic merge commit from my repo on Github?
| How do I delete a merge commit? |
So to fetch all the unused docker images without actually pruning them, you could do the followingFetch all the images belonging to the running containers(which are not stopped or exited)Fetch all the images on the machineThen filter the images in step 1 from step 2Below are the shell commandsrunningImages=$(docker ps --format {{.Image}})
docker images --format "{{.ID}} {{.Repository}}:{{.Tag}}" | grep -v "$runningImages"ShareFolloweditedApr 25, 2022 at 8:43answeredApr 25, 2022 at 8:16Tolis GerodimosTolis Gerodimos4,14222 gold badges99 silver badges1818 bronze badgesAdd a comment| | This question already has answers here:How to check for unuse images for your docker containers?(5 answers)Closed1 year ago.I've found thatdocker system dfshows the large RECLAIMABLE space for me.In order to save the space, I know thatdocker image prune -awill remove all unused images.However, I'd like to know the list before pruning for the safety.Is there any way to list all images those are currently not being used by any container? (The images that will be deleted bydocker image prune -a)I have searched for it but there are only pruning methods, no listing methods. | docker how to list all unused images without pruning [duplicate] |
You are stepping into the shoes of Raymond Chen. He did the exact same thing, writing a Chinese dictionary in unmanaged C++. Rico Mariani did too, writing it in C#. Mr. Mariani made one version. Mr. Chen wrote 6 versions, trying to match the perf of Mariani's version. He pretty much rewrote significant chunks of the C/C++ runtime library to get there.Managed code got a lot more respect after that. The GC allocator is impossible to beat. Checkthis blogpost for the links. Thisblog postmight interest you too, instructive to see how the STL value semantics are part of the problem. | Last week I wrote a few lines of code in C# to fire up a large text file (300,000 lines) into a Dictionary. It took ten minutes to write and it executed in less than a second.Now I'm converting that piece of code into C++ (because I need it in an old C++ COM object). I've spent two days on it this far. :-( Although the productivity difference is shocking on its own, it's the performance that I would need some advice on.It takes seven seconds to load, and even worse: it takes just exactly that much time to free all the CStringWs afterwards. This is not acceptable, and I must find a way to increase the performance.Are there any chance that I can allocate this many strings without seeing this horrible performace degradation?My guess right now is that I'll have to stuff all the text into a large array and then let my hash table point to the beginning of each string within this array and drop the CStringW stuff.But before that, any advice from you C++ experts out there?EDIT: My answer to myself is given below. I realized that that is the fastest route for me, and also step in whatIconsiderthe right direction- towards more managed code. | C++ string memory management |
0
You will still get that head.js speed benefit during the initial cache manifest download event and during cache manifest updates
Share
Improve this answer
Follow
answered Aug 15, 2012 at 3:36
mattnullmattnull
34222 silver badges99 bronze badges
Add a comment
|
|
There are large speed benefits to using head.js in my own sites. Now I am considering HTML5 cache manifest to improve offline access to sites and improving speed (more things are loaded from cache)
Are the benefits of head.js still there (parallel script loading in particular) if I use HTML5 Cache Manifest?
| html5 cache manifest compatibility with head.js? |
This is an old question, but in case anybody else lands here with this problem, the solution (for me) is to include the github username in each block in ~/.ssh/config. As in:# USERNAME-1 at github:
Host github.com-1
HostName github.com
User USERNAME-1
IdentityFile ~/.ssh/id_rsa_1
IdentitiesOnly yes# USERNAME-2 at github:
Host github.com-2
HostName github.com
User USERNAME-2
IdentityFile ~/.ssh/id_rsa_2
IdentitiesOnly yesIn the github URL, change "github.com" to "github.com-1" or "github.com-2" as needed, so for example, you'd clone with:git clone[email protected]:USERNAME-1/foo.gitinstead of:git clone[email protected]:USERNAME-1/foo.git | I can manage multiple SSH keys for different GitHub accounts so that I can access multiple accounts and projects, each with different credentials. However, is it possible for me to work on two different projects on two different github accounts (push and pull) in the same RStudio? I searched online but could not find an answer. I have related SSH keys in my folder. However, I cannot change SSH RSA key in Global Options of RStudio since it always puts the file~/.ssh/id_rsa. But I also have another key for my another Github account~/.ssh/id_rsa_SECOND. I would appreciate any help! Thank you!EDIT:
My config file has,Host me.github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile Clone ~/.ssh/id_rsa
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_SECONDwhich tells me to use me.github.com instead of github.com as host for repositories in the first Github account (with identity ~/.ssh/id_rsa) AND to use github.com for repositories in the second Github account (with identity ~/.ssh/id_rsa_SECOND). However, when I clone a repository in my personal account , usinggit@ **me**.github.com:username/hugo-academic.gitdoes not work. | Two different Github accounts in the same RStudio |
crontab commands are executed only with minimal environment variables, i.e.PATH=/usr/bin:/bin(on debian anyway),so if you are relying on programs that are in your$PATH, it will fail.
Consider specifying an absolute path to the osmosis program wherever it's called from.Alternatively you can change$PATHitself in your scriptexport PATH="/my/bin:$PATH"p.s.: you can check the environment by adding a simple cron job* * * * * env > /tmp/env.txt | I'm new in Ubuntu and programming.
I'm testing a program that I found on github, to download and import OSM data into postgis.
It works when I run it from terminal (url and name are fake):make all NAME=dbname URL='http://myurl'using postgres user.Now I need to run this command every day.
So I wrote that script:#!/bin/bash
# go to the directory with Makefile
cd /PCuserhome/directory/to/Makefile/
# run Makefile
make all NAME=dbname URL='http://myurl'and it works when i run it from terminal.So I have added it to crontab (of postgres user) in this way:0,15,30,45 * * * * /PCuserhome/myscript.shIt create the db but probably fail in running osmosis selection (Osmosis is in the path for all users).
Any idea to solve this? Thank you! | Run Makefile with crontab |
I don't think there is any official specification about how long favicons should be cached (and why). You should rather ask browsers developers why they decided to cache them longer.My guess is that since websites change favicons relatively rarely, there's no need to check very frequently if a favicon has been updated. | I would like to know why favicons, unlike images and other resources are stored far longer in cache and seem to be very persistent as well. I'm using Google Chrome, so the question aims this browser, but also browsers in general as I observed this behavior in other browsers, too.This question(related, not a duplicate)targets the"how to delete them"question. However, I want to understandwhyfavicons seem to be treated so distinctively, whereas my interest in deleting them is rather secondary to irrelevant.As a web developer, I can simply applyfavicon.ico?2and get a "fresh" one. And the responsibility lies in the provider of an application rather than in the user managing his own cache(or "petting" my application as I like to call it). So this is not my main question.Whydo favicons seem to be more persistent than other resources? | Why are favicons cached longer? |
You don't need (you can't acctually) to add the unit to the expression, just the number. If your alert is never triggered maybe is something wrong with the expression or maybe the result is always less than 5. Have you tested the expression in the Prometheus console? | - name: app
rules:
- alert: ServerHighLatency
expr: sum by(applicationName) (rate(http_server_requests_seconds_sum{status!~"4..|5.."}[1m]))/sum by(applicationName) (rate(http_server_requests_seconds_count{status!~"4..|5.."}[1m])) >= 5s
for: 5s
labels:
severity: critical
annotations:
summary: "{{ $labels.applicationName }} is responding with high latency(5s+)"
description: "*Host*: {{ $labels.node }}\n*Datacenter*: {{ $labels.datacenter }}\n*Value*: {{ humanize $value }}\n"But I got parsing error around the finalsin the expression, so I guess it is not allowed. When I removesit works, but is never triggered. I cannot find any examples of alerts to examine the average response time within a range, but only comparison by value, like "some percentile > 0.8", but not with time units. Does it make sense?Side note: I cannot get{{ $labels.datacenter }}and{{ $labels.node }}working, but{{ $labels.applicationName }}is working, why? Where can I find some good examples and documentations of alerts syntax in Prometheus? | How to create an alert in Prometheus with time units? Like "average response time surpasses 5 seconds in the last 2 minutes" |
deflateEnd() returning Z_DATA_ERROR means that the deflate operations were left in some intermediate state, i.e. not completed, at the time of that call. So deflate() had never returned a Z_STREAM_END.
Regardless, all of the allocated memory for deflate is released by deflateEnd(). So if you're calling deflateEnd(), there will be no memory leak for memory allocated by zlib.
To properly complete the deflate stream, you need to give deflate() the Z_FINISH flush parameter, and then call deflate() to consume its output until it returns Z_STREAM_END.
|
i am trying to compress block of strings in partial_flush mode, moreover there is one case when there is only one string to process.
Now i am calling deflateInit2(params...), deflate() and deflateEnd(). I get some correct output in output, witch is uncompressable(tried), but there is an error when trying to deallocate all memory using deflateEnd(&strm); or inflateEnd(&strm);
For now, i am thinking here will be no possibility to create this case on application run, but i need to pinpoint and eliminate error with memory leak.
whole schematis is like this:
class Czlib{
compress( std::string );
decompress( std::string );
Czlib() // allocate inflate and deflate state here
~Czlib()// deallocate both here
}
int main(){
for (char c=0x00 ; ; c++){
std::string str(255, c);
Czlib zlib;
zlib.compress(str);
}
I know that class should die after each loop and probably it is, but deflateEnd and inflateEnd keeps reporting deflateInit2(params...)0, so in the end dynamically allocated data stays in memory :(
| Zlib usage - deflateEnd() error |
You can do this using the following CLI commands:
Register a user
aws cognito-idp sign-up --region {your-aws-region} --client-id {your-client-id} --username [email protected] --password password123
Confirm user registration
aws cognito-idp admin-confirm-sign-up --region {your-aws-region} --user-pool-id {your-user-pool-id} --username [email protected]
Authenticate (get tokens)
aws cognito-idp admin-initiate-auth --region {your-aws-region} --cli-input-json file://auth.json
Where auth.json is:
{
"UserPoolId": "{your-user-pool-id}",
"ClientId": "{your-client-id}",
"AuthFlow": "ADMIN_NO_SRP_AUTH",
"AuthParameters": {
"USERNAME": "[email protected]",
"PASSWORD": "password123"
}
}
You should get a response like this if everything is set up correctly:
{
"AuthenticationResult": {
"ExpiresIn": 3600,
"IdToken": "{your-idtoken}",
"RefreshToken": "{your-refresh-token}",
"TokenType": "Bearer",
"AccessToken": "{your-access-token}"
},
"ChallengeParameters": {}
}
|
I' using Cognito user pool for securing my API gateway . Now I would like to make requests to my API using postman but I need to pass in Authorization token as the API is secured. Is there any AWS CLI command or REST API to generate auth tokens(by passing username/password)? I have searched documentation but couldn't find any examples. Thanks for your help.
| How to generate access token for an AWS Cognito user? |
Both the errors are due to date and time mismatch, ie.. try syncing system time settings to your exact location and login,that worked for me. | awsapps login page shows -It's not you, it's us We couldn't complete your request right now. Please try again later
oraccess key and secret could not connect aws account with an error message as
"An error occurred (InvalidSignatureException) when calling the DescribeCluster operation: Signature expired: 20220801T134645Z is now earlier than 20220801T143813Z (20220801T144313Z - 5 min.)" | It's not you, it's us We couldn't complete your request right now. Please try again later- awsapps login |
I have had a similar issue on Azure App Services, the way I solved it was using the links keyword. As I see from your docker-compose you are linking it in the wrong way. The reason why it works locally is because the containers are in the same local network.
Have you tried to link reporting.service to messaging.bus instead?
Also check this answer here, docker official documentation here and docker compose supported commands on Azure here.
I have also found an interesting article here that says how to make two containers depending on each-other.
I hope this helps!
|
I have following docker-compose content:
version: '3.4'
services:
reporting.service:
image: xxx.azurecr.io/beta/reporting.service
environment:
- ASPNETCORE_ENVIRONMENT=Docker
ports:
- "5003:80"
messaging.bus:
image: rabbitmq:3-management
environment:
- RABBITMQ_DEFAULT_USER=user
- RABBITMQ_DEFAULT_PASS=user
- RABBITMQ_DEFAULT_VHOST=test
links:
- reporting.service
ports:
- "15672"
- "5672"
web.frontend:
image: xxx.azurecr.io/beta/web.frontend
ports:
- "3000:80"
When running above locally on my machine using docker everything works fine and my reporting.service is able to connect to the messaging.bus (RabbitMQ) without any problem.
Connection string looks something like this:
"EventBus": {
"ConnectionString": "amqp://user:[email protected]:5672/test"
},
When I push my images to Azure container registry and try to use it in Azure web app for containers then following exception is thrown in reporting.service container:
RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the
specified endpoints were reachable ---> System.AggregateException: One
or more errors occurred. (Connection failed) --->
RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed
---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException:
No such device or address
FYI, I implemented Polly retry policy in the reporting.service when connecting to the RabbitMQ so that code is executed multiple times in case of broker not available. To make sure that RabbitMQ container is up and running (which I confirmed also looking at the logs).
What I'm doing wrong? Why I'm not able to see rabbitMq instance from other containers?
Thanks for the help!
| RabbitMQ container not reachable in Azure Web App for Containers |
Usually, Git will only allow you to changenewcommits to a remote repository, i.e. commits that only add to what the remote already has. This is mainly to make sure that everybody working with the repository stays in a consistent state and their repositories won’t break.If you knowingly want to remove the commit from your remote, you can usegit push --forcetooverwritewhat the remote has and force it to accept whatever you give it. This is what you want to do to actually remove a commit from a remote. Note again that this actually breaks the local repositories of everyone else involved (just like rebasing), so don’t do it unless you are either the only one working with it, or you actually agreed with everyone on this.The saner way to undo the changes is by doing arevert. That is an additional commit that undoes the work that has been previously done. So instead of removing a commit from the history, you add another commit that undoes the commit. You can do that usinggit revert commit-you-want-to-revert. | So I am on a branch with a bunch of commits. At a certain point in time I decide that the most recent commit is bad and I want to go back to the second-to-last commit. I did this usinggit reset --hard xxxxxxxxxx, where xxxxxxxxxx is the first ten digits of the commit code. This seems to work fine for reverting my local app to the conditions of the second-to-last commit.However, when I try andadd,commit, andpushchanges, I get an error that the tip of my local branch is behind its remote counterpart. What to do? | Revert local app to old commit, push it and replace commits further down branch |
4
Seems like the From docker docs answers your question pretty exhaustively:
By default, all external source IPs are allowed to connect to the Docker daemon. To allow only a specific IP or network to access the containers, insert a negated rule at the top of the DOCKER filter chain. For example, the following rule restricts external access to all IP addresses except 192.168.1.1:
$ iptables -I DOCKER-USER -i ext_if ! -s 192.168.1.1 -j DROP
To allow specific subnet:
iptables -I DOCKER-USER -i ext_if ! -s 192.168.1.0/24 -j DROP
Bonus: you can also limit connections entirely to localhost: docker run -p 127.0.0.1:80:8003 should automatically restrict the access to localhost.
Alternatively with docker compose:
webapp:
image: image_name
ports:
- "127.0.0.1:80:8003"
Share
Improve this answer
Follow
edited Mar 19, 2019 at 12:51
answered Mar 19, 2019 at 12:32
Christian W.Christian W.
2,59011 gold badge2020 silver badges3333 bronze badges
0
Add a comment
|
|
I have several web services in different containers and I redirected 80 ports of each server to another port on the host server. (container 1 80 -> 8003, container 2 80 -> 8004, container 3 80 -> 8005) I want to prevent access to these ports except the preconfigured ip list
I've added iptables rules to the "docker-user" chain as follows;
-A INPUT -s 212.154.74.194/32 -p tcp -j ACCEPT //accept all from this ip
-A INPUT -s 185.22.208.0/25 -p tcp -j ACCEPT //accept all from this ip
-A INPUT -p tcp -m tcp --dport 8003 -j DROP //block anyone except allowed ips
-A INPUT -p tcp -m tcp --dport 8004 -j DROP //block anyone except allowed ips
-A INPUT -p tcp -m tcp --dport 8005 -j DROP //block anyone except allowed ips
But it doesn't work. Routed ports can still be accessed from the outside. I don't know what I did wrong. How can I block access to routed ports?
| How do I prevent redirected docker ports from being open to the outside world? |
1
You could write your command more explicitly - this would also ensure you know exactly where commits are coming from or going to.
git push (and pull) by default expand to git push origin current_branch_name, which is a shorthand for git push origin current_branch_name:current_branch_name, where left side of the colon is originating branch and right side is destination branch.
So, for your example, to pull from remote branch A to local branch C, you could do
git pull origin A:C
to push from local branch C to remote branch B -
git push origin C:B
Share
Follow
answered Nov 6, 2015 at 1:27
apprenticeDevapprenticeDev
8,05933 gold badges2323 silver badges2525 bronze badges
Add a comment
|
|
Is it possible to git push to branch B, while using git pull to pull from branch A, while the local branch is branch C?
I realize that git pull pulls all the branches down by default, and would be fine with setting it up to only pull the currently checked out branch.
To clarify; the local clone of the repository only has branch C.
git fetch
git pull
For this branch get their commits from remote branch A and
git push
Should send commits upstream to remote branch B.
| Different remote branches for pushing and pulling |
Just had the same issue. Open the file with Notepad++. On the bottom right it tells you the encoding the file is in. It has to beUTF-8 without BOM. You can fix that via selecting a new encoding at the top and saving the file.ShareFolloweditedOct 12, 2022 at 8:30answeredMar 5, 2020 at 13:01jaaqjaaq1,2261212 silver badges3232 bronze badges23can do the same with VSCode: the key is to make sure it's UTF-8. When I re-opened the file that I had created as UTF-8, a bunch of weird chars were present and it was just a matter to delete them to get rid of the error–fabiog1901Aug 10, 2021 at 16:34Yep, VSCode does it all :)–jaaqAug 16, 2021 at 6:41Add a comment| | I am setting my systems for codecommit. but getting following errorI followed the below link :https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-ssh-windows.html/c/Users/Prasanna/.ssh/config: line 1: Bad configuration option: \377\376h
/c/Users/Prasanna/.ssh/config: terminating, 1 bad configuration optionshere is the config file
Host git-codecommit.*.amazonaws.com
User ********
IdentityFile ~/.ssh/codecommit_rsaAm I missing anything to configure ? | Getting Bad configuration option: \377\376h |
Internet Explorer 7: 1,789
Firefox 3: 3,000
Chrome 1: 21,837
Opera 9.62: 10,000
Safari 3.2: 500
This are all the some of limits
refer this
http://javascriptrules.com/2009/06/30/limitation-on-call-stacks/
and also this
http://www.nczonline.net/blog/2009/05/19/javascript-stack-overflow-error/
|
Here is a recursive function for endless loop.
<html>
<body>
<script type="text/javascript">
function repeat(x){
document.write(x+" ");
repeat(x+1);
}
repeat(1);
</script>
</body>
</html>
Using the function, I can see how many recursive calls took place there before out of memory.
First time, I run it on firefox.
Result -> 1 2 3 .... upto 40536
Now, I refresh the page
Result -> 1 2 3 ... upto 46046
!! Again refreshing or running on different browsers, I got different results.
How can this be possible? What is the call stack logic/limit for recursion in javascript?
| Same function, different behaviour in times |
Install pipenv first and then you can run pytest using pipenv.
name: Python application
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install pipenv
run: pip install pipenv
- name: Run tests
run: |
pipenv install --dev
pipenv run pytest
|
I have a Python project that uses pipenv to run pytest. I want to create a GitHub Action that will run pytest each time I submit a pull request.
I've tried using the python-app.yml starter workflow.
name: Python application
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pip install pytest
pytest
But I get the following build failure.
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
##[error]Process completed with exit code 1.
I would like to avoid creating a requirements.txt file and simply use pipenv to run pytest.
How do I create a GitHub Action that uses pipenv to run pytest?
| How do I setup a GitHub action that runs pytest with pipenv? |
You can do that usingTHE_REQUESTvariable that represents complete http request (including REQUEST_URI and QUERY_STRING) as received by Apache:RewriteEngine On
RewriteCond %{THE_REQUEST} bar [NC]
RewriteRule ^ - [F] | Let's say there are a few URL schemes, like:http://www.example.com/foo/bar/bashttp://www.example.com/foo/fooo/bas/bar/bashttp://www.example.com/foobarbashttp://www.example.com/?foobar=bashttp://www.example.com/?barfoo=bashttp://www.example.com/?bas=foo&bar=basI want to DROP (e.g. returns404) all the URLs whenever it contains a string:barinside.Please kindly help. Thank you all. | HTACCESS : How to FILTER A STRING anywhere in the full URL string? |
Amazon maps-out typical latency between IP addresses and AWS regions. ChooseLatency-based Routingto have the fastest response.Geolocationmaps the IP addresses to geographic locations. This permits rules like "send all users from Côte d'Ivoire to the website in France", so they see a language-specific version. It can redirect bycountry, region (eg Oceania) and US state. Geolocation cares more about the location of users rather than the speed of their connection.Geolocation pre-dates GDPR. It could be used forgeo-blocking, but this is typically done in Amazon CloudFront:Restricting the Geographic Distribution of Your Content - Amazon CloudFrontShareFollowansweredMay 29, 2020 at 4:24John RotensteinJohn Rotenstein254k2626 gold badges408408 silver badges497497 bronze badges2Hi, can you elaborate on Latency based routing policy?–Aishwarya JoshiMay 28, 2023 at 15:461@AishwaryaJoshi AWS measure the latency (response time) to many different IP addresses in the world. This can result in faster connections than geo-based routing. For example, there might be a high-speed undersea cable that connects to a distant country faster than a closer country. See:Latency-based routing - Amazon Route 53–John RotensteinMay 28, 2023 at 23:59Add a comment| | AWS implements latency routing policy based on the ip address of resolver or masked ip address of client. It will help to find the region of low latency.If both geolocation policy and latency policy are based on the IP address of client, it comes to several questions:what's the difference between them?What's the purpose of Geolocation routing policy?Is geolocation policy used for complying the law of different country? e.g. GDPR, cookie usage.Europe: GDPRChina: data must be stored in China.In which case should I use Geolocation routing policy rather than latency policy?Referencehow does AWS Route 53 achieve latency based routing:https://youtu.be/PVBC1gb78r8?t=1963https://youtu.be/PcoQY82SDHw?t=622How does AWS Route 53 achieve latency based routing? | AWS Route 53 Routing Policy: Geolocation Vs Latency |
SSH into your Homestead VM.
Edit /etc/nginx/sites-available/your-site.app and add /webroot to the line that looks like: root "/home/vagrant/your-site"; so that it looks like root "/home/vagrant/your-site/webroot";
Restart nginx with: sudo service nginx restart
Your should find your CakePHP pages can find their static content.
|
I'm trying to do some cakePHP development using my existing homestead
installation I use for Laravel.
I can get the application running but it says that
'URL rewriting is not properly configured on your server.'
I tried to use the instructions to configure nginx but did not have much luck.
Has anyone gotten url rewriting to work, or can point me at any sources?
I know their is a vagrant setup for cakephp, but I'd rather continue to use homestead if possible.
| CakePHP with Homestead |
I achieved by running the querysum by (groupname) (namedprocess_namegroup_context_switches_total{ctxswitchtype="voluntary"})We can use any of tags inside the sum by (use any tag) such as job, groupname, ctxswitchtype to filterShareFolloweditedNov 28, 2019 at 7:47Sebastian Kaczmarek8,41544 gold badges2323 silver badges4141 bronze badgesansweredNov 28, 2019 at 7:32shivcenashivcena2,04399 gold badges2424 silver badges5151 bronze badgesAdd a comment| | In my grafana I am tracking the running instance of node exporter and process exporter. In that i have used the querynamedprocess_namegroup_context_switches_total{ctxswitchtype="voluntary"}For this query I am getting multiple process running instance for node exporter and process exporter. For example for the above query i am getting the result like,namedprocess_namegroup_context_switches_total{ctxswitchtype="voluntary",groupname="processexporter",job="processexporter"} 45678
namedprocess_namegroup_context_switches_total{ctxswitchtype="voluntary",groupname="processexporter",job="processexporter"} 98767
namedprocess_namegroup_context_switches_total{ctxswitchtype="voluntary",groupname="nodeexporter",job="nodeexporter"} 64835
namedprocess_namegroup_context_switches_total{ctxswitchtype="voluntary",groupname="nodeexporter",job="nodeexporter"} 36217I want to alter the query to display the sum of total running instace like,namedprocess_namegroup_context_switches_total{ctxswitchtype="voluntary",groupname="processexporter",job="processexporter"} 144445
namedprocess_namegroup_context_switches_total{ctxswitchtype="voluntary",groupname="nodeexporter",job="nodeexporter"} 101052Kindly assist me on how to achieve the sum value of running instance | How to get sum of instance for grafana query |
) Your Lambda RoleCreate your Lambda function, rather than use a template, choose to
create a new role and give it a name (lets say MyLambdaRole).Go into IAM, go to the Roles menu option and find the MyLambdaRole role. Attach the following policy: AmazonDynamoDBFullAccessNote that the Lambda will already have CloudWatch access by default. The AmazonDynamoDBFullAccess has more permissions than you strictly need but its not unreasonable. If you did want finer grained permission I would at least get it working with AmazonDynamoDBFullAccess and go from there. Also note you shouldn't need any Cognito permissions at all, as all you will be doing is parsing the data sent to you by Cognito.Make sure you import the relevant DynamoDB library in your script.For example:exports.handler = (event, context, callback) => {
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'us-east-1'});
// Create the DynamoDB service object
ddb = new AWS.DynamoDB({apiVersion: '2012-10-08'});
};2) Accessing the individual Cognito user dataAssuming you are using NodeJs, like this:event.request.userAttributes.emailMore detailshereOne final thing, you don't need to assign a trigger to the Lambda function. All you need to do is go into Cognito, and assign the Lambda function in the triggers section. That way Cognito calls the Lambda directly - Lambda doesn't need to listen out for any special events. | I'm having trouble implementing a post-confirmation lambda function in which I take the user submitted credentials from the sign-up process and write those to a 'Users' DynamoDB table. The specific entries that I'm trying to write to the table are
- user name
- email
- actual nameIn order to distinguish users from one another I need the primary key to be the 'sub' value since users can change their usernames and that could cause problems in the future.The main points of confusion I'm having are the following1) What roles should I begin my Lambda function with?When creating a lambda function I need to give it a starting role and I'm not really sure what starter template I should use. I know I'm going to need DynamoDB write access but I don't see a template for that.2) How do I access the individual fields of the Cognito user?As far as I'm aware these values should be stored in the 'event' parameter of the handler function, but I can't find any documentation or sample events that show how to access the individual fields for things like 'sub', 'email', etc. | Writing Cognito user info to DynamoDB through a post-confirmation lambda function? |
Use something like:
RUN apk add --no-cache python2
This will install the latest version of Python 2 as python2 or python2.7. Python 3.7.3 will still be available using python3, or simply python.
|
I am trying to figure out a way that I can install both python2.7 and 3.7 in a lightweight alpine docker image.
Currently I am using the
FROM python:3.7-alpine3.9
Base image but would like to know how to get python2 installed as well.
| How do I get python2.7 and 3.7 both installed in an alpine docker image |
You are misunderstanding the concept ofexposed ports.When you expose a port in kubernetes with theportsoption (the same apply with Docker and theEXPOSEtag), nothing is open on this port from the outside world.It's basically just a hint for users of that image to tell them"Hey, you want to use this image ? Ok, you may want to have a look at this port on this container."So if your port does not appear when you dokubectl describe, then it does not mean that you can't reach that port. You can still map it with a service targetting this port.Furthermore, if you really want to make it appear withkubectl describe, then you just have to add it to your kubernetes descriptor file :...
containers:
- ports:
- name: prom-http
containerPort: 9249 | I'm runningflink run-applicationtargetting Kubernetes, using these options:-Dmetrics.reporter.prom.class=org.apache.flink.metrics.prometheus.PrometheusReporter
-Dmetrics.reporter.prom.port=9249I specify a container image which has the Prometheus plugin copied into/opt/flink/plugins. From within the job manager container I can download Prometheus metrics on port 9249. However,kubectl describeon the flink pod does not show that the Prometheus port is exposed. The ports line in the kubectl output is:Ports: 8081/TCP, 6123/TCP, 6124/TCPTherefore, I expect that nothing outside the container will be able to read the Prometheus metrics. | How do I get the pod to expose the prometheus monitoring port in Flink application mode on Kubernetes? |
<div class="s-prose js-post-body" itemprop="text">
<p>It's caused by some bug in GZIP compression vs. WebKit-based browers (Safari, Chrome/Chromium, new Opera). Solution, that worked for me, was disabling content compression in HHVM side and keeping it enabled only in nginx. It's controlled with GzipCompressionLevel HDF runtime option.</p>
<pre><code>Server {
GzipCompressionLevel = 0
}
</code></pre>
<p><code>hhvm.server.gzip_compression_level = 0</code> in php.ini also should work, but I haven't tested that yet.</p>
</div> | <div class="s-prose js-post-body" itemprop="text">
<p>If you take a look at this page using Safari:</p>
<p><a href="http://m2.monetarylane.com/product-category/women/" rel="nofollow noreferrer">http://m2.monetarylane.com/product-category/women/</a></p>
<p>You'll see this:</p>
<p><img alt="Safari bug" src="https://i.stack.imgur.com/ScoQO.png"/>
Every other browser displays the content properly.</p>
<p>This server is using Mercury - which is Varnish + Nginx + HHVM + PHP5-FPM fallback + W3 Total Cache + cloudflare.</p>
<p>I've switched off CSS and JS minification, so it's not that.</p>
<p>Any ideas why Safari is doing this?</p>
</div> | Why is Safari displaying weird symbols instead of HTML content? |
There is no way that I would be aware of to cover this use case. | I want to know how many critical and blocker have been resolved each day/month, but I didn't find how doing it!
Does anyone have an idea? | Count resolved critical and blocker issues sonarqube |
Gearmanwould be an ideal candidate, and I would use it for exactly the purpose you describe. It has everything you need out of the box to meet your requirements ("background" a long running, CPU-bound process to another machine, e.g. video encoding).There is aGearman PHP library, but you can write your worker code in a different language if it's better suited to doing the work.For reporting progress information, I recommend having the worker write toRedisorMemcached- some kind of temporary storage that your web server can also access.Check out the simplePHP exampleon the Gearman site. For learning, I recommend setting up a lab environment that contains 3 separate VM's, one for your web server (the client), one for the Gearman job queue (the server) and another for processing jobs (the workers). | I have a website, created using PHP and running on Apache. I want a subscriber to be able to log in and start a process on the server. They can then log out or close the browser without interrupting the process. Later they can log in and see the progress or see the results of the original process. What is the best way to accomplish this (having the process run until completion, after the browser is closed)?Just looking for someone to point me in the right direction. A few people mentioned Gearman. | (having the process run until completion, after browser is closed) |
If you want to totally ignore the files, you should add them to your .gitignore.
If you wish to "hide" only the credentials, that depends on your deployment and your build process. One way is using a vault (again, depending on your system).
Another option would be reading credentials from some environment variable, that'll be set in a secured manner somewhere else.
|
I'm new to git and github and would like to know how to git push login-credentials.php without Username and Password in it.
Suppose, there are just two files on local repository and index.php will include ("login-redentials.php");:
index.php
login-credentials.php
When using git push origin master, both files will be pushed to github. In this case, USERNAME and PASSWORD will be made published.
What is the best way to remove login credentials from login-credentials.php BEFORE using git push? - I could not find a best practice for this use case in git documentation.
| How to git push without credentials? |
This is because your email address is not properly registered inside your computer's git config.
You can set it like so (globally):
git config --global user.email "[email protected]"
Or locally per repository, execute this inside the directory:
git config user.email "[email protected]"
Then your icon will show up again!
|
When committing to Github directly from VSCode (Visual Studio code),
my github profile user icon is not visible in the commit history on Github.
Eg.
There is no avatar shown for my user, while I do have one set on the Github website.
| Github commit from VSCode has no profile icon |
You can provide the--outputflag to display only the contexts' names, for example:$ kubectl config get-contexts --output=name
minikubeIt's then easy to grep for GKE contexts:$ kubectl config get-contexts --output=name | grep "gke_*" | I am trying to get a list of kube-contexts (and filtering for gke clusters) andwith some toolsended up with that:kubectl config get-contexts | tr -s ' ' | cut -d ' ' -f 2 | grep gkeoutput:gke_dev-redacted
gke_prod-redactedIs there an easier way to do that (which does not depend on the fact that the command output does not use tabs, but multiple whitespaces). yaml or json output is not supported by that command:--output yaml is not available in kubectl config get-contexts; resetting to default output format | How to get a list of kube-contexts using cli |
13
I'm trying to do the same (DS920+, DSM 7.1 latest). According to this Reddit:
https://www.reddit.com/r/portainer/comments/u1vf1s/how_to_add_ghcr_as_a_registry/
it used to work with 'docker.pkg.github.com' as the repo url, but according to the current Github docs, it was the old namespace and the actual repo is now 'https://ghcr.io'
https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
According to the docs, authentication is implied many times, maybe it is not possible to use the repo w/o authentication (tried with access tokens, not working).
I opened a Synology support ticket, let's see what they can say.
2022-10-27 - Synology Support replied and the official statement is that the token authentication currently used by Github Container Registry is not supported on the DSM's Docker package GUI. Its possible to ssh to the DSM and use docker from the command line.
Share
Follow
edited Oct 27, 2022 at 13:35
answered Oct 26, 2022 at 9:28
PeterPeter
13111 silver badge55 bronze badges
Add a comment
|
|
When trying to add the Github Registry to Synology Docker, I always get a prompt saying "Registry returned bad result".
The URL I try to connect to is: https://ghcr.io
| Adding ghcr (Github Docker Regustry) to Synology docker results in "Registry returned bad result" |
I'm not 100% sure what the problem was but I read somewhere that downgrading the multi_json gem to version 1.7.8 would fix this and it did for me. Please note that this is just what fixed my app, it might not be the same for you but hopefully it is! I did the following:Add the following to your Gemfile:gem 'multi_json', '1.7.8'And then update the gem:bundle update multi_jsonCommit the new changes:git add .
git commit -m "Downgrade multi_json gem"And push to AWS:git aws.pushThat should resolve the issues.If you get a complaint from bundler about mis-matched dependencies you can re-install your gems and hopefully fix the dependency issues by removing the Gemfile.lock.To delete the Gemfile.lock run:rm Gemfile.lockAnd then run bundle install:bundle installCommit again and push to aws. | I am trying to setup rails on aws (Dev env work fine). Can not get production to start up correctly. Can shell in and db looks good. I looked into my log file and I am getting the following error.rake aborted!
MultiJson::AdapterError: Did not recognize your adapter specification (cannot load such file -- json/ext/parser).HaveMultiJsonandJsongems installed and in the gemlock file.This happens during asset compilation. | MultiJson AdapterError Rails 4 Ruby 2 Passenger |
<div class="s-prose js-post-body" itemprop="text">
<p>After being helped in the right direction via the comments and finding the real error, I was able to find the solution <a href="https://stackoverflow.com/a/24121256/2124351">here</a>. Needed to supply the mysql socket path in the node-mysql configuration.</p>
<pre><code>host: 'localhost',
user: 'root',
password: 'xxx',
database: 'xxx',
socketPath: '/var/run/mysqld/mysqld.sock'
</code></pre>
</div> | <div class="s-prose js-post-body" itemprop="text">
<p>I'm running a node app on ubuntu server 14.04 with nginx. I have a mysql database, which was initially running on a different server. Everything worked fine, but in an effort to tune performance I moved it onto the same server and I'm getting an error trying to connect through localhost. I'm using <a href="https://github.com/felixge/node-mysql" rel="nofollow">node-mysql</a> with the following configuration:</p>
<pre><code>host: 'localhost',
user: 'root',
password: 'xxx',
database: 'xxx'
</code></pre>
<p>I haven't really changed anything with mysql after the initial installation, simply created a dump file and ran it to create the database.</p>
<p>I get the following error whenever my app hits the database:</p>
<blockquote>
<p>502 (Bad Gateway)</p>
</blockquote>
<p>I've searched around but everything I find on this is PHP related.</p>
<p><strong>Update:</strong>
Checked the pm2 logs (using pm2 to run node) and it's giving the following error:</p>
<blockquote>
<p>ECONNREFUSED 127.0.0.1:3306</p>
</blockquote>
<p>Is there something I need to do to open this up?</p>
</div> | node/mysql/nginx - 502 bad gateway |
The following code solved my issue# Rewrite rules for Zend Framework
RewriteEngine on
Redirect permanent /robots.txt /public/robots.txt
Redirect permanent /favicon.ico /public/favicon.ico
RewriteRule ^(.*)$ /public/$1 [QSA,L] | I have the following .htaccess to rewrite my domain.com/ to domain.com/public/# Rewrite rules for Zend Framework
RewriteEngine on
RewriteRule ^(.*)$ /public/$1 [QSA,L]It works fine but my logs report me that some bots try to access the file robots.txt and it doesn't exists.If I access the url:http://domain.com/robots.txtdoesn't workbut if I access the full url, it workshttp://domain.com/public/robots.txtWhat I am doing wrong in the .htaccess? | ZendFramework .htaccess |
Node's process.env is an object containing the user environment. Docker's CLI allows you to set the environment variable for the container using the -e or --env options.
You can run
docker run --env mysql_host=127.0.0.1 -p 80:80 -d myApp
To pass the mysql_host into the container.
|
How to set node ENV process.env.mysql-host with docker run?
Can i somehow do like this? docker run --mysql-host:127.0.0.1 -p 80:80 -d myApp
I am using FROM node:onbuild as image.
| Docker Node JS set env |
If your application is read heavy, you can add more reader endpoints in other AZs.If your RDS is single instance and in the different AZ to your EC2 instance, you will need to take a snapshot and create the instance again in order to change the availability zone. | I currently have a EC2 instance working with an MySQL RDS database. They are both in the same region, but in different availability zones. Currently my application is experiencing a bit of lag, and it is my intuition that it is due to this.How can I change the AZ of my RDS database to speed up my application?Locally I am running the same application and it is significantly faster. | How to change a RDS availability zone to a different one within the same region on AWS? |
We have solved both the issues with the setup below.FiledirA/main.tfcontains something similar toresource "local_file" "kubeconfig" {
content = module.gke_auth.kubeconfig_raw
filename = "${path.module}/kubeconfig"
}
output "kubeconfig_file" {
value = "${path.cwd}/kubeconfig"
}FiledirB/main.tfcontains something similar todata "terraform_remote_state" "kubeconfig_file" {
backend = "local"
config = {
path = "${path.module}/../dirA/terraform.tfstate"
}
}
provider "kubernetes" {
config_path = "${data.terraform_remote_state.kubeconfig_file.outputs.kubeconfig_file}"
}Finally:cd dirA
terraform apply
cd ../dirB
terraform applyNote: In a similar way we can access variables from the stack in the different directory | We have the below directory structure on the Linux system./root
├─dirA
│ ├─main.tf
│ ├─terraform.tfvars
│ └─variables.tf
└─dirB
└─main.tf==FIRST==We used the below snippet inmain.tffile ofdirAto create a local kubeconfig file.resource "local_file" "kubeconfig" {
content = module.gke_auth.kubeconfig_raw
filename = "./kubeconfig"
}Now we would like to access thiskubeconfigfile in themain.tffile ofdirBinside the following snippet. Please suggest how to do that?provider "kubernetes" {
config_path = "<PATH_TO_KUBECONFIG_FILE>"
}==SECOND==We have defined some variables inside theterraform.tfvarsfile ofdirAand we would like to access those variables inside themain.tffile ofdirB. Please suggest how to do this. | How to access files and variables from different directory in Terraform? |
If you want the easiest way, then you just execute thecat /some/file/herecommand instead of bash and sending the output to a file on your local machine. Then remove the initial aws cli message from the beginning of the local file, such as:The Session Manager plugin was installed successfully. Use the AWS CLI to start a session.
Starting session with SessionId: ecs-execute-command-<some session id>
This session is encrypted using AWS KMS.If it's a binary file, then save it as a txt file, remove the initial cli output mentioned above, and rename it with the binary extension. Example:aws ecs execute-command --region <your region> --cluster <your cluster> --task <your task ID> --container <your container> --command "cat /tmp/reportBatch.zip" --interactive >> ~/reportBatch.txtFor this method, you only need access to your ECS instance and be allowed to run commands on it. | I need to do some heap dumps and it would be great to have an easy (and fast) way to get the files as seamless as possible.Current way doing it is:Create fileOptional: Upload SSH key to EC2 instance if not yet known(depending on security model used)Open SSH session (not using ASM as it has some OsX flaws)copy docker container file to EC2 instanceSCP the file to local machineCleanupThis seems overwhelming complex for getting a single file. Is there a more straight-forward way in doing it? As this is an on demand use case I'd be ok with manual AWS Console way or using tools to do it more convenient. THX | What is the easiest way to download a file out of an ECS container to local machine? |
Unlike C/C++ (and others), JavaScript takes care of memory management and garbage collecting. Of course, removing unnecessary data will release some resources used by your browser/server and may slightly improve the overall performance, but this is not an obligation and there will be no memory leaking if you forget about it.
To clean up the array, you can set images.length = 0. images will be an empty array [].
|
Here is my code:
// array of image data
var images = [
{
url: 'image.jpg'
}
];
// function that loads image
var loadImage = function(imageObject) {
imageObject.img = $('<img src="'+imageObject.url+'"/>').error(function() {
// error event handler, that might not always fire
imageObject.img.remove();
imageObject.notLoaded = true;
});
};
loadImage(images[0]);
My question is how to clean up images array? If I assign
images = null;, will this clean up memory for all images? Should I unbind 'error' handler?
Thank you!
| Should I unbind event listener to prevent memory leaks? |
1
yes,
if you have local or otherwise access to this GlusterFS storage and eg. assuming it would be mounted under /mnt/backup/ you can list and restore from it using the file target.
i'd suggest listing/grepping first and when you found the backup repo containing your folder restoring from there
repeat this for every backup folder (note the three slashes in the target url for an absolute file path)
duplicity list-current-files [options] [--time time] file:///mnt/backup/server[num]/duply/www/
then restore when you found the folder (use the folder name as shown in the listing, a relative path to the backup base folder)
duplicity [restore] [options] --file-to-restore www.example.com [--time time] /mnt/backup/server[num]/duply/www/ /var/www/www.example.com
parameters in [square brackets] are optional.
hope that helps.. ede/duply.net
Share
Follow
answered Nov 4, 2016 at 12:35
ede-duply.netede-duply.net
51822 silver badges55 bronze badges
1
Sounds good. Unfortunately, the listing command is now copying all signature files from the GlusterFS storage to the local cache to get the listing. This takes a lot of time. I'm already waiting for more than 15 minutes for only one server... Can't I say, that it has to read it from the remote side?
– Sebbo
Nov 4, 2016 at 14:10
Add a comment
|
|
I've multiple virtual machines and every machine is backuping to the same backup storage (GlusterFS; it's mounted using fuse), but into different backup directories. /var/www/ for example will be backuped to this directory:
/mnt/backup/server001/duply/www/
/mnt/backup/server002/duply/www/
/mnt/backup/server003/duply/www/
...
/mnt/backup/serverXXX/duply/www/
...
As backup software, I'm using duply / duplicity. If I know, on which server the folder or file was, I can connect to this server and run this command to restore it:
duply www-backup fetch www.example.com/ /var/www/www.example.com/ 1D
Unfortunatley, this does only work for files and directories, which were backuped from/on this server.
Today, I've the problem, that I've deleted a while a go a website and can't remember myself, on which server it was hosted. Well... This means, I would need to connect to each single host and need to run the restore command to check, if it's available from there or not.
I don't have the time to do this on each single server. Well... Is there a way to fetch it from the backup anyhow using file://, even when I don't know, where it is?
I've already tried to fetch it using the following command, but it didn't worked, because the directories does not contain any backup chain:
duplicity --force file:///mnt/backup/ /var/www/www.example.com/
Any ideas?
# duplicity --version
duplicity 0.6.23
| How-to restore duplicity/duply backup from unknown archive |
Creating tables for single files is not supported by Athena. You can only create a table on a directory level.What is possible on the other hand is, creating a table on the directory level and filter the input file while querying.You can filter the input file with the$pathpseudo column.select * from tablename
where "$path" = 's3://bucketname/directory/a.file.txt' | I am trying to use Amazon Athena over S3 bucket which has two kinds of files.a.file.txt
b.file.txtI just want athena to target a.file.txt. Is it possible to specify it in console while creation of table?Thanks | Is there any way to specify Prefixes in AWS Athena S3 paths? |
It looks like yourmongobackup.shdoesn't have proper rights to be executed.chmod 755 /etc/cron.daily/mongobackup.shshould do the trick, but it wouldn't hurt to see what's inside of the script and results ofls -l /etc/cron.daily.Also, you could manually add a task to root crontab (or any other user thathas rightsto run the script and to work with everything mentioned there):to start editing crontab enter commandcrontab -u username -ein the end of the file insert this:0 0 * * * /bin/sh /full-path-to-mongobackup.sh >/dev/null 2>&1, pressEsc,:wq,Enter- that will create a task, which will runmongobackup.shevery midnight.And in order to answer your question about how you could run scripts in specific time of a day i would recommend you to readthis articleaboutcronandcrontab.ShareFolloweditedMay 16, 2016 at 3:24answeredMay 16, 2016 at 2:06Sergey BrodinSergey Brodin36111 silver badge77 bronze badgesAdd a comment| | I want to backup database regularly in my linux server (Ubuntu 12.02),I red some documents and that saying I should use linux cron, and Fortunately, I found this :https://github.com/micahwedemeyer/automongobackup/blob/master/src/automongobackup.shI put my configuration and save itmongobackup.shand put it to/etc/cron.dailyIt was 3 days ago, Today, I check the backup folder(/var/backups/mongodb) but the backup file does not exist.Should I detele extension ofmongobackup.sh? or something I missed? | How can I backup mongodb database regularly, the specific time of a day |
Yes, first you should add rules.You can directly add routers in KubeSphere. See thedocumentationfor more info. | I installed Kong (Kong proxy+kong ingress controller) over Kubernetes/Kubesphere cluster with Istio mesh inside, and I added annotations and ingress types needed, so am able to access only the Kong Proxy at node exposed IP and port, but am unable neither add rules nor access Admin GUI or do any kind of configuration, every request I do to my Kong end-point likecurl -i -X GET http://10.233.124.79:8000/rulesor any kind of request to the proxy, I get the same response of:Content-Type: application/json; charset=utf-8 Connection: keep-alive
Content-Length: 48 X-Kong-Response-Latency: 0 Server: kong/2.2.0
{"message":"no Route matched with those values"}Am not able to invoke Admin API, its pod-container is only listening to 127.0.0.1, my environment var's for kong-proxy podKONG_PROXY_LISTEN
0.0.0.0:8000, 0.0.0.0:8443 ssl http2
KONG_PORT_MAPS
80:8000, 443:8443
KONG_ADMIN_LISTEN
127.0.0.1:8444 ssl
KONG_STATUS_LISTEN
0.0.0.0:8100
KONG_DATABASE
off
KONG_NGINX_WORKER_PROCESSES
2
KONG_ADMIN_ACCESS_LOG
/dev/stdout
KONG_ADMIN_ERROR_LOG
/dev/stderr
KONG_PROXY_ERROR_LOG
/dev/stderrAnd env. var's for ingress-controller:
CONTROLLER_KONG_ADMIN_URLhttps://127.0.0.1:8444CONTROLLER_KONG_ADMIN_TLS_SKIP_VERIFY
true
CONTROLLER_PUBLISH_SERVICE
kong/kong-proxySo how to be able to expose Admin GUI over the mesh over the nodeport and how to able to invoke Admin API, to add rules, etc? | Kong LoadBalancer over Kubesphere |
You are facing the following bug:VSTS-135TL;DR: version 4 of the extension uses a mechanism that is available only starting with TFS 2017 Update 2. | On TFS 2015, I upgraded from 3.0.0 to 4.0.1, however the new 4.0 tasks are not showing up in the tasks list.When I try to reinstall 4.0, I get confirmation that it is already installed:Shows version is already installedHowever the new 4.0 related tasks are now showing up in the tasks listI do still see the version 3.0 tasksIs 4.0.1 compatible with TFS 2015? How do I get the 4.0 tasks to show up in the tasks list?In TFS 2018, a new installation of 4.0 works just fine:4.0 Tasks Showing Up in TFS2018 after initial installationThanks in advance for the feedback. | Upgrading to Sonarqube TFS Extension From 3.0.0 to 4.0.1 |
1
The publisher plugin will work inside of the container, but not if you are trying to access an area inside the container. This means if you need to access something like the /etc of the container, you will not be able to because the plugin will actually be accessing the /etc of the Jenkins host. You can the workspace though inside of the container though.
Share
Improve this answer
Follow
answered May 13, 2021 at 19:22
VenVen
1111 bronze badge
Add a comment
|
|
I recently switched to using docker containers in my Jenkins pipelines and it seems that the jenkins HTML publisher plugin doesn't seem to work from within the container.
What I mean by that, is that after the build an HTML file is generated, which I wish to be published. I am using the HTML publisher plugin for that which worked perfectly fine until switching to building with containers.
Should the HTML publisher plugin work from within the container? If not are there any alternatives to publishing the HTML from within the container?
Thank you.
| Jenkins publish HTML from docker container |
I am not sure I have fully understood your question but hopefully this may shed some light.The docker command is just a REST client. By default the client connects to the unix-socket/var/run/docker.sockto send requests to the docker daemon.
You can practically achieve the same thing by runningcurl:curl --unix-socket /var/run/docker.sock http:/localhost/versionNow if your docker daemon was configured for remote access, you probably have the URI information in thedocker.serviceservice file. See this postHow do I find the Docker REST API URL?.Hope that helps | Is there a command that I can evaluate (eval $COMMAND) or an environment variable that I can inspect to get the URI of the locally running docker host? I need to be this an expression to evaluate at runtime, since I need to use it in a script intended to run on hosts where docker engine may not be running on the standard ports.Thanks. | How to get the docker host URI on my localhost |
Have you had a chance to check outSpeed Traceryet? That should give you more of what you need I think.With memory usage, you probably want to do a heap profile in the Chrome developer tools under the "Profiles" tab. You can compare multiple heap profiles to get a look at memory usage. | I am currently developing an application using Google O3D WebGL framework, and this is the first time I am using JavaScript so intensively. The features are only around 20% complete, but already the application on its own starts off by taking up around 160 meg of memory, whilst leaving the application running it consumes around 200kb per second in Chrome, 2meg in FF; as the screen is refreshed. As I am writing this I have left Chrome 9 running and it has just hit 400 meg of memory usage. I am now crapping myself especially with FF's usage, and I am looking for any really good documentation on optimizing JavaScript, preventing memory leaks, anything that will help me tackle this basically. I would also really appreciate any links to awesome tools that will help me. Thanks in advance.Edit: I have come acrossMozilla performance toolsbut I need something simple to use, preferably with a GUI, or at least a noob friendly guide. Also a lot of those tools are for linux (I am using Win7) or require purchase / are command line only. + I would really like to see something for Chrome :) but I will accept the answer that provides the most usefull information.Edit: Google Chrome's developer tools only report on 10meg of memory usage, unsure where the rest is coming from. | Javascript Memory Usage & Debugging in Chrome / Firefox (Minefield) |
There are two relevant effects at play.
The first and major effect is that all data transfers from the 3 locations mentioned happen in blocks bigger than a single integer value. From HDD or SSD to main memory, block sizes are typically 4kB or bigger (file system cluster size). From main memory to cache, data transfers are typically 64-256 bytes (cache line size).
The second effect is that because most access is sequential, storage is optimized for this. Hard disk file systems store files consecutively, so the hard disk read head doesn't need to move to get the next cluster. The disk just rotates. Only after one rotation does the head move, by a single step. A random seek takes milliseconds, in comparison. But even SSD's have to wait for a new address, whereas for a sequential read the next address can be predicted.
|
I was shown this table in the context of data processing and big data.
What are the bars actually measuring? The mechanism of a device for reading always has the same speed: e.g. it's not as if a hard drive thinks "ok, this data is sequential so I'll increase the amount which the head reads".
I was told it happens because of the cache, though it's sort of misleading to say that the actual read speed is faster if it's the cache that's responsible. Does this happen because an entire page is loaded from secondary storage to primary and if it's sequential than a larger portion of the page would be used then if it was random? This seems like a very academic perspective.
I'm not sure if I should've posted this question above the previous paragraph, but are we talking about 1) how long a device takes to read something, 2) how long it takes for a device to read something and pass it to the next level in the memory hierarchy, 3) or how long a device takes to read something and pass it to the processor? Come to think of it I'm not sure there's a difference between the first two: say you have an SSD that has read speed of x and RAM that has read speed of y. Then for something to be loaded into ram, would it take (x+y)*size_of_page time or just x*size_of_page? Obviously there's many different caches a long the way: hard drives have a buffer, I don't know if SSD do, any CPUs can have L1, L2 or any number of caches. It really seems like this table needs more of an explanation.
| What is this table trying to convey? Why do sequential reads happen faster than random reads? |
Just dodevice = torch.device("cuda:0") | I am learning ML and trying to run the model(Pytorch) on my Nvidia GTX 1650.torch.cuda.is_available() => True
model.to(device)Implemented the above lines to run the model on GPU, but the task manager shows two GPU1. Intel Graphics
2. Nvidia GTX 1650The fluctuation in CPU usage is shown on Intel and not on Nvidia.How I can run it on Nvidia GPU?NOTE: The code is working fine and is getting executed on the Intel one with around 90-100s time of epoch. | Pytorch Model set GPU to run on Nvidia gpu |
There's no such thing as a "static object". But all static variables in all types loaded in any app domain are treated as GC roots until the app domain is unloaded.
If you want to do things when the app domain is unloaded, you could subscribe to AppDomain.DomainUnload and AppDomain.ProcessExit.
|
I try to avoid using static classes in my production code as they cant be injected, there is no control over default initialization and lastly you can't really clean up your resources implicitly as there is no destructor for static objects. Additionaly, you cannot implement the IDisposable for a static class as well, so sounds like static classes are never good for being a wrapper around unmanaged resources...
It totally seems like singletons are a better solution to replace the use of static classes directly in that case. But my question is - why doesn't the compiler support static destruction, after all what difference does it make for the GC to keep track of references to a static object vs an instance?
| Why there is no static destructor? |
RFC 7234 defines the cache key:
The primary cache key consists of the request method and target URI....
If a request target is subject to content negotiation, its cache
entry might consist of multiple stored responses, each differentiated
by a secondary key for the values of the original request's selecting
header fields.
The secondary key uses the headers listed in the Vary response header. See section 4.1 for more detail.
When a cache receives a request that can be satisfied by a stored
response that has a Vary header field,
it MUST NOT use that response unless all of the selecting header
fields nominated by the Vary header field match in both the original
request (i.e., that associated with the stored response), and the
presented request.
To answer your specific questions:
But the question here is, what is the same request? Does it mean the same resource URI in the case of a GET request?
Yes.
What about the values of headers included in the request or the content of the body?
The content of the body doesn't matter, and the headers only matter if they're listed in the Vary header.
I've seen that the Cache-Control header is also used for POST requests. If so, is the standard for the same Post request determined by comparing the contents of the body?
Since the primary cache key consists of the URI and the method, two POST requests will have the same key if they have the same URI. However, as the standard notes, "since HTTP caches in common use today are typically limited
to caching responses to GET, many caches simply decline other methods
and use only the URI as the primary cache key."
|
I understand that the browser save the response, to return quickly at next same request.
But the question here is, what is same request? Does it mean that same resource uri in the case of Get request?
What about the values of headers included in the request or the content of the body?
I've seen that the Cache-Control header is also used for Post requests.
If so, is the standard for the same Post request determined by comparing the contents of the body?
| How browser cache determine that request is same or not? |
FYI, I ended up doing the query manually, creating an SdkHttpFullRequest and using an AWS4Signer to sign it. Works OK but I wonder why it couldn't be included in the SDK directly... The only gotcha was to make sure to specify the "aps" for the signing name in the Aws4SignerParams creation. | I am using AWS Managed Prometheus service and setup a Prometheus server on my EKS cluster to collect and write metrics on my AMP workspace, using the helm chart, as per tutorial from AWS. All works fine, I am also connecting to a cluster run Grafana and I can see the metrics no problem.However, my use case is to query metrics from my web application which runs on the cluster and to display the said metrics using my own diagram widgets. In other words, I don't want to use Grafana.So I was thinking to use the AWS SDK (Java in my case,https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/amp/model/package-summary.html), which works fine (I can list my workspaces etc...), except it doesn't have any method for querying metrics!?The documentation indeed mentions that this is not out of the box (!) and basically redirects to Grafana...This seems fairly odd to me as the basic use case would be to run some queries no? Am I missing something here? do I need to create my own HTTP requests for this? | Send metrics query on AWS AMP |
You can use Jekyll variable inside code blocks. Thus try the following:{% raw %}
v
$
|
{%}-:-%&
{% endraw %} | Onmy GitHub repoI have this Markdown:blah blah blah text
v
$
|
{%}-:-%&Every time I have pushed with it, GitHub's page build fails because "the{%tag was not properly closed with%}". However, the{%is in a code block, so shouldn't it be ignored in ... whatever the page build is checking (I'm assuming it's Markdown)? | GitHub page build failure due to '{%' in code block |
You should be able to stop tracking changes on the file with:
git update-index --skip-worktree <file>
And you can resume tracking changes with:
git update-index --no-skip-worktree <file>
|
I'm trying to ignore all changes to a very small file in my repo (Github). It is a hidden file (.first_run), which contains a single character (0). I use it (obviously) to detect a first run of my package.
I'm encountering these issues:
The file is already tracked, so adding it to my .gitignore won't work.
I can't use git rm --cached <file> because it will remove that file from the repo, which is not what I want.
Using git update-index --assume-unchanged <file> also does not work. If, after applying assume-unchanged to the file, I change the 0 for a longer string (e.g.: sdfgdgd), it does not show as changed (correct behaviour) But if I change the 0 for say a 4, it will show up as modified.
I assume the issue described in point 3. is due to what is explained in this answer:
Assume-unchanged (..) is not a promise by Git that Git will always consider these paths are unmodified---if Git can determine a path that is marked as assume-unchanged has changed without incurring extra lstat(2) cost, it reserves the right to report that the path has been modified (as a result, "git commit -a" is free to commit that change).
Is there anything I can do to make 00 ignore future changes to this file?
| git ignore tracked file but keep in repo (assume-unchanged does not work) |
3
Install aws Agent
#change to root user
sudo su -
#update the yum package
sudo yum update -y
#install aws logs
sudo yum install -y awslogs
Edit the configuration file
vim /etc/awslogs/awslogs.conf
In this file add configuration like
[/var/log/messages]
datetime_format = %b %d %H:%M:%S
file = /var/log/messages
buffer_duration = 5000
log_stream_name = @10.20.19.93
initial_position = start_of_file
log_group_name = /aws/syslogs/unix/messages
in your case you can chage the file to
application.log.*
check for the origin to write the cloud watch logs
vim /etc/awslogs/awscli.conf
check for any exception
less /var/log/awslogs.log
For More reference
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AgentReference.html
Share
Improve this answer
Follow
edited Jun 20, 2020 at 9:12
CommunityBot
111 silver badge
answered May 18, 2018 at 6:48
ankursingh1000ankursingh1000
1,36911 gold badge1616 silver badges2121 bronze badges
2
Can we have like multiple files for config? Leaving default config as is and have separate file to auto-append?
– Justinas
Mar 3, 2020 at 12:09
The amount of noise surrounding CloudWatch is deafening! This was the best description of allowing multiple log files I've found. Thanks @UserszrKs
– Adrian Lynch
Mar 12, 2020 at 0:19
Add a comment
|
|
I have a Java application deployed on AWS EC2 instance which creates multiple log files named application.log, application.log.1, application.log.2 and so on with increasing logs. The number of log files are not fixed and keeps on increasing with increase in logs. In Cloudwatch Logs conf file, we can specify multiple files with their absolute names, but in this case there are many files getting created at runtime with .log.1, .log.2, .log.3 .. suffix. How can I setup CloudWatch Logs to take logs for all files as they get created.
| AWS Cloudwatch logs for multiple files |
You can use git reset to point a branch to a different commit. So, on second_branch,
git reset --hard master
Then git push -f to update GitHub.
|
I have a project with a master branch and a second_branch. The data in the two branches is different and I want to copy the data from the master branch into second_branch and then update second_branch on GitHub. How can I do that?
The status of second_branch is:
This branch is 3 commits ahead, 1 commit behind master
| Copy master branch data into other branch |
Answer from @Walfis close but requires some changes e.g. regex anchors andDPIflag.You can use these rules ontop of your site root .htaccess:RewriteEngine On
# remove /sub_directory/ when there is no _ left
RewriteRule ^sub_directory/([^_]+)$ /$1 [R=301,NC,NE,L]
# use recursion based rule to replace _ by -
RewriteRule ^(sub_directory/[^_]*)_+(.*)$ $1-$2 [NC,N,DPI]
# rest of your rules go here | I need help creating a rewrite rule/301 redirect for the following link structures in the .httaccess folder.Source URL: www.example.com/sub_directory/product_name_1.htmlDestination URL: www.example.com/prodcut-name-1.htmlThe requirements for the redirect then are as follows:Remove /sub_directory/Change all underscores '_' to hyphens '-'Unfortunately my regex isn't very good. I've tried searching around and but the solutions from other post with similar issues where not working for me (such ashere)Any help on a solution for this would be much appreciated. Also if you could please explain the why/how of it. I'd like to be able to better understand this. | 301 Redirects Rewrite Rule to replace underscore with hyphen and remove subdirectory |
I found a solution:location ~ \.xml$ {
rewrite ^ /<bucket>/sitemap$request_uri break;
proxy_pass https://s3-eu-west-1.amazonaws.com;
}ShareFollowansweredApr 11, 2018 at 11:00BntMrxBntMrx2,27744 gold badges2020 silver badges3131 bronze badges3No but it works well on production env with us, do you have any idea why?–BntMrxMay 18, 2018 at 8:57No! For me this did some strange redirect, ended up having to handle that so as not to be redirected to s3. But now I think about it, that could've been since initially CloudFront was not forwarding the Host header.–Andy HaydenMay 19, 2018 at 4:22@me987654323 Can you provide the source? I'm getting same error.–Vipul SolankiFeb 28, 2019 at 12:53Add a comment| | All my xml files are stored in a AWS S3, I want to show them via my website :Nginx conf:location ~ \.xml$ {
proxy_pass https://s3-eu-west-1.amazonaws.com/bucket-name/sitemap$request_uri;
}But I get a 502 and log says[error] 13295#13295: *26 no resolver defined to resolve s3-eu-west-1.amazonaws.comIf I define a resolver likeresolver s3-eu-west-1.amazonaws.com;I get[error] 14430#14430: *7 s3-eu-west-1.amazonaws.com could not be resolved (110: Operation timed out),Thank you for helping | no resolver defined to resolve s3-eu-west-1.amazonaws.com |
The short answer is:root@debian: yes
y
y
...
^C
root@debian:;-) | This is a pointless task, I know. But I'm just messing around and trying to familiarize myself.I thought this might work, but no:root@debian: Jibberish 2> file.txt && file.txt < /dev/tty0I thought this might generate an error message which would then be sent to file.txt which would in turn be the input back into the shell (/dev/tty0).Anyway, if anyone knows how to make an infinite loop using just redirects and pipelines I'd be interested to know.Thanks | Is an infinite loop possible in Unix shell using just redirection and pipelines? |
I was advised to use: Docker Registry HTTP API V2 directly instead of SDK as it is not supported right now:https://docs.docker.com/registry/spec/api/
|
I am looking to use this library but it does not offer this option. https://cloud.google.com/go/docs/reference/cloud.google.com/go/artifactregistry/latest/apiv1. It seems the struct artifactregistrypb.DockerImage simply does not have the option.
| How do you get the manifest of an image in GCP artifact registry using the Go SDK? |
I found the answer. Python client does have support for draining a node but it is not a single command. "kubectl drain" operation utilizesEviction APIto safely delete all the workloads running on a node. The python-client has a functioncreate_namespaced_pod_evictionthat safely deletes all the pods in a namespace. However, "safely" depends on thePod Disruption Budgets (PDB)that you have defined for the apps running on that node.I am posting this answer hoping that someone might find it useful :)ShareFollowansweredOct 5, 2017 at 19:06Swarup DonepudiSwarup Donepudi98411 gold badge1111 silver badges2323 bronze badges1Note that there's currently (July 2019) a method todelete a nodein the python-client.–Jaime M.Jul 1, 2019 at 13:11Add a comment| | I am trying to automate kubernetes worker nodes using the officialkubernetes python-client. I am currently looking for a way tosafely move al the running applications to other nodes. We can do so using "kubectl drain". I did not find a way to simulate that functionality using python client. I am currently looking into Does this library support drain functionality yet? | How to drain a node using kubernetes python client? |
The correct syntax is the following:time_intervals:
- name: monday-to-friday
time_intervals:
- weekdays: ['monday:friday']You can use this time interval like shown in the following example:route:
group_by: ...
...
routes:
- receiver: SOME-RECEIVER
matchers:
- SOME-MATCHER
active_time_intervals:
- monday-to-friday
... | I tried to add this to my alertmanager.yml in root level, but I got this error:yaml: unmarshall errors: field time_intervals not found in type config.plaintime_intervals:
- times:
weekdays: ['monday:friday'](I used 0.23 version of Alertmanager) | Alertmanager: how to send alerts only in weekdays? |
There is no non-moving memory allocator that can avoid fragmentation of at least a log(M/m) factor, where M = the size of the largest object request, and m = the size of the smallest (this is a classic result due to Robson, 1971).I work with folks who do real-time systems programming (including at Airbus), and they studiously avoid the use of dynamic memory allocation, instead using pools, as you mention.There is, however, a big difference between an OS and memory allocation. Dynamic memory allocation, as exposed to the programmer, is part of the library and has little to do with the OS (except as a source of memory). Linux itself uses a slab-based memory allocator for its own internal purposes; I assume Embedded Linux does the same, but am not sure. | In many embedded systems, memory fragmentation is a concern. Particularly, for software that runs for long periods of time (months, years, etc...). For many projects, the solution is to simply not use dynamic memory allocation such as malloc/free and new/delete. Global memory is used whenever possible and memory pools for types that are frequently allocated and deallocated are good strategies to avoid dynamic memory management use.In Embedded Linux how is this addressed? I see many libraries use dynamic memory. Is there mechanism that the OS uses to prevent memory fragmentation? Does it clean up the heap periodically? Or should one avoid using these libraries in an embedded environment? | Embedded Linux: Memory Fragmentation |
No.You can turn off directory listings because nothing needs to see them.You can't turn off display of CSS or JS because the browser has to be able to see them in order to use them for what they are designed for. Anything the browser can see, the user can see too. | Before this question I asked about disabling file and folder listing and I found an answer that this can be done with a file called .htaccess. For disabling folder listing I write Options -Indexes in the .htaccess file and place it in the parent folder, on the other hand for disabling display of files content in the browser I write Deny from all.The above part functions good, but when a putted the .htaccess file for disabling display of files content in the css or js folder, it disables display of files and also blocks the functionality of them (.css and .js).Is there an answer that disables the display of files in the browser but allows the functionality of them?Thank you | Disable display of .css and .js files content in the browser |
You can useLinqToCachefor this.It allows you to use the following code inside your repository:var queryTags = from t in ctx.Tags select t;
var tags = queryTags.AsCached("Tags");
foreach (Tag t in tags)
{
...
}The idea is that you useSqlDependencyto be notified when the result of a query changes. As long as the result doesn't change you can cache it.LinqToCachekeeps track of your queries and returns the cached data when queried. When a notification is received from SqlServer the cache is reset. | What I want is pretty simple conceptually but I can't figure out how it would be best to implement such a thing.In my web application I have services which access repositories which access EF which interacts with the SQL Server database. All of these are instanced once per web request.I want to have an extra layer between the repositories and EF (or the services and the repositories?) which statically keeps track of objects being pulled from and pushed to the database.The goal, assuming DB-access is only accomplished through the application, would be that weknowfor a fact that unless some repository access EF and commits a change, the object set didn't really change.An example would be:Repository invokes methodGetAllCarrots();GetAllCarrots()performs a query on SQL Server retrieving aList<Carrot>, if nothing else happens in between, I would like to prevent this query from being actually made on the SQL Server each time (regardless of it being on a different web request, I want to be able to handle that scenario)Now, if a call toBuyCarrot()adds aCarrotto the table, then I want that to invalidate the static cache forCarrots, which would makeGetAllCarrots();require a query to the database once again.What are some good resources on database caching? | Cache Entity Framework data and track its changes? |
So sorry, it was my misunderstanding.
My OS is Redhat Linux.
I get to install docker by
yum-config-manager --enable rhui-REGION-rhel-server-extras
yum -y install docker
systemctl start docker
systemctl enable docker
docker version
|
I wanna create docker image for Amazon ECR.
but yum can't find it in my Amazon Linux2.
[root@*** ~]# yum install -y docker
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
No package docker available.
Error: Nothing to do
Next, I tried to use amazon-linux-extras.
but amazon-linux-extras is not found, too.
[root@*** ~]# amazon-linux-extras install docker -y
-bash: amazon-linux-extras: command not found
[root@*** ~]# find / -name 'amazon-linux-extras'
[root@*** ~]$ cat /proc/version
Linux version 4.14.77-81.59.amzn2.x86_64 (mockbuild@ip-10-0-1-59) (gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC)) #1 SMP Mon Nov 12 21:32:48 UTC 2018
How can I install amazon-linux-extras or create docker image?
| How to install docker on Amazon Linux2 |
My gut feeling on this is Core Data structured such that each tile element has relationships to the tiles around it. There's some non-trivial overhead here, but the advantage is that you can release tiles that aren't onscreen from memory and fault them back when you need them. As you move in a direction, you can query for the tiles in that direction, and you can fairly cheaply dump memory when you're in the background. This would get rid of the "several" 2D arrays and move all the data into a single object. In principle, the grid could be infinite in size this way, since everything is by relationship rather than coordinate.
You could similarly approach the problem using SQLite, querying for rows and columns in a given range. You might mark the objects as NSDiscardableContent and put them in an NSCache, which could dramatically improve memory performance. You could still generate an effectively-infinite grid as long as you allow coordinates to be both positive and negative.
|
I am coding a 2 dimensional, tile based (orthogonal tiles) iPhone game. All levels are procedurally generated when the app is first played, and then persist until the user wants a new map. Maps are rather large, being 1000 tiles in both width and height, and the terrain is destructible. At the moment it is rather similar to Terraria, but that will change.
To hold map/tile information I am currently using several 2 dimensional c style arrays. This works well, but I am concerned as to the amount of memory this takes up, as the arrays are all defined as short array[1000][1000], which takes up (1000 * 1000 * sizeof(short)) bytes of space.
This is not particularly desirable when the iPhone doesn't have an incredibly large amount of memory to work with, especially when the user is multitasking. The main problem is that there is no way that I can use a specific tile map format such as .tmx, because all the levels are procedurally generated. Performance could also be an issue, because if a tile is destroyed at index(x, y), then I need to change the data in that index. I have also thought about writing tile map data to a text file, but I think there would be difficulties or performance issues when accessing or changing data.
Keeping all this in mind, what would be an efficient and fast way to handle my tile data?
| Efficient way to handle large runtime-generated tile maps? |
finally my config looks like this:
docker run -v /etc/openvpn:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig \
-u udp://192.168.10.152:1194 \
-n 10.3.0.10 \
-n 192.168.10.1 \
-n 8.8.8.8 \
-n 75.75.75.75 \
-n 75.75.75.76 \
-s 10.8.0.0/24 \
-N \
-p "route 10.2.0.0 255.255.0.0" \
-p "route 10.3.0.0 255.255.0.0" \
-p "dhcp-option DOMAIN-SEARCH cluster.local" \
-p "dhcp-option DOMAIN-SEARCH svc.cluster.local" \
-p "dhcp-option DOMAIN-SEARCH default.svc.cluster.local"
-u for the VPN server address and port
-n for all the DNS servers to use
-s to define the VPN subnet (as it defaults to 10.2.0.0 which is used by Kubernetes already)
-d to disable NAT
-p to push options to the client
-N to enable NAT: it seems critical for this setup on Kubernetes
the last part, pushing the search domains to the client, was the key to getting nslookup etc.. to work.
note that curl didn't work at first, but seems to start working after a few seconds. So it does work but it takes a bit of time for curl to be able to resolve.
|
I spinned a docker-openvpn container in my (local) Kubernetes cluster to access my Services securely and debug dependent services locally.
I can connect to the cluster via the openVPN server. However I can't resolve my Services via DNS.
I managed to get to the point where after setting routes on the VPN server:
I can ping a Pod by IP (subnet 10.2.0.0/16)
I can ping a Service by IP (subnet 10.3.0.0/16 like the DNS which is at 10.3.0.10)
I can curl to a Services by IP and get the data I need.
but when i nslookup kubernetes or any Service, I get:
nslookup kubernetes
;; Got recursion not available from 10.3.0.10, trying next server
;; Got SERVFAIL reply from 10.3.0.10, trying next server
I am still missing something for the data to return from the DNS server, but can't figure what I need to do.
How do I debug this SERVFAIL issue in Kubernetes DNS?
EDIT:
Things I have noticed and am looking to understand:
nslookup works to resolve Service name in any pod except the openvpn Pod
while nslookup works in those other Pods, subnet 10.2.0.0/160 does not.
similarly subnet 10.2.0.0/161 in those other Pods leads to the flannel layer subnet 10.2.0.0/162 and then stops there.
from this I guess ICMP must be blocked at the flannel layer, and that doesn't help me figure where DNS is blocked.
EDIT2:
I finally figured how to get nslookup to work: I had to push the DNS search domain to the client with
subnet 10.2.0.0/163
add with the subnet 10.2.0.0/164 option in the subnet 10.2.0.0/165 image
so i end up with
subnet 10.2.0.0/166
Now, subnet 10.2.0.0/167 works but subnet 10.2.0.0/168 still does not
| Kubernetes: VPN server and DNS issues |
As shown indocker loadpage, it "restores both images and tags."So an image from the same name doesn't get overwritten.Adocker imageswould simply lists the newly loaded image alongside the existing one, with their respective ids and tags.As explained in "Content trust in Docker", a registry can include multiple images of the same names (but with different ids or tags) | I have a simple question about thedocker loadcommand.If an image exists in the local repository and running thedocker loadcommand loads an image with the same name as the one that is in the repository, does the old image get replaced with the one that is loaded? | Docker load command replaces existing images with same name |
I try a different JRE 1.6 and now I could post my application.It is really weird, I don't know why JRE 1.7 doesn't work. | Closed.This question isnot reproducible or was caused by typos. It is not currently accepting answers.This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may beon-topichere, this one was resolved in a way less likely to help future readers.Closed5 years ago.Improve this questionI wrote a AWS java web project, and it could run on my local server.But when I refer tohttp://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Java.sdlc.htmlto deploy the application on elastic beanstalk. I could only got a blank page. I also tried upload WAR file to elastic beanstalk, but still got an blank page.I SSH into the EC2 instance, and find no folders for my application. I think there should be somewhere in tomcat7/myapp folder. Could anyone tell me why, and how to deploy java app to it?I also try the travelLog example, but still cannot get the page display. | how to deploy java web application to AWS elastic beanstalk? [closed] |
In your nginx config setdefault_typedirectiveDefines the default MIME type of a response. Mapping of file name
extensions to MIME types can be set with the types directive.server {
...
default_type text/html;
location /assets/imgs {
default_type image/png;
}
location /assets/imgs {
default_type image/jpeg;
}
}ShareFollowansweredApr 23, 2019 at 8:13A_SuhA_Suh3,80688 silver badges2323 bronze badgesAdd a comment| | I use Docker to package the Angular project (container use Nginx). When running on Docker, the images shows up ok, but when deploying to Kubernetes, using Ingress, all images in theassetsfolder do not appear.Content-Type running on Docker. It's OK:Link ImageBut when running on Kubernetes. Content type always is text/html:Link ImageConfig Ingress Kubernetes. Service namessite.apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: abc-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: "swing-static-ip"
ingress.kubernetes.io/force-ssl-redirect: "true"
ingress.gcp.kubernetes.io/pre-shared-cert: "abc,xyz"
spec:
rules:
- host: abc.com
http:
paths:
- backend:
serviceName: sservice
servicePort: 8000
- host: xyz.com
http:
paths:
- path : /
backend:
serviceName: ssite
servicePort: 80
- path : /*
backend:
serviceName: ssite
servicePort: 80 | Kubernetes Ingress deploy Angular assets (image) doesn't show |
You shouldn't have permanent js files located in your files folder. Either they should be in your theme or a module that uses them. The files folder is meant for uploaded files and other files that Drupal creates on the fly.
The reason to your problem is probably that Drupal has write access to the folder where you have placed the files, and it cleans out in it, since it's only used for compressions. You should think twice about which files you let drupal write to. Letting Drupal have write access to a script file you use, is an added security risk.
Generally, you don't want to let Drupal write to js or php files. This is because if a cracker would be able to get Drupal to write to those files, he would be able to more or less gain control over your entire site. This is also why the compressed js files that drupal uses has a long and random name.
So try moving those files into your theme and see if that doesn't fix it. If you want to link to them you can do
drupal_add_js(drupal_get_path('theme', 'name_of_your_theme') . 'path/to/file.js');
|
When I delete "Page requisites" cache, my 2 Javascript files that I use for my home page image rotator get deleted.
Here is how I'm adding the javascript for those 2 files into a WYSIWYG editor with PHP code enabled:
<?
drupal_add_js('sites/default/files/js/jquery.jcarousellite.js');
drupal_add_js('sites/default/files/js/cycle.js');
?>
Some html here for the rotator......
Then I also have some JS code added to the home page only using the js Injector .
Any ideas why this is happening?
thanks
| Drupal flushing "Page requisites" cache also deletes javascript files |
Google Drive is included in the Reports API of the Google Apps Admin SDK. It provides similar information to the Google Drive Audit Log, but with additional metadata. That includes the parent folder ID of files which were removed.
To restore the files you should first query the Reports API for files removed by the user in question over the relevant time period, using the Activities:list method.
Then you'll need to setup a Google Apps service account (which is a little confusing), to allow you to impersonate the owners of the documents that were removed.
Lastly, you can iterate over the event report for the removed files and use the Files: patch method in Google Drive REST API, to re-add the parent ID's to each of the files.
See Gist Using Google Drive API to restore files removed from shared folders
for example of the last step.
|
A non-privileged Google Drive user has accidentally removed a large number of files from folders shared across an organisation. They do not have permission to delete the files entirely, because they are not the owner. However, users with edit permissions are able to remove a file from a shared folder. This returns the user to the owner, but seems to leave the file orphaned without a parent folder.
The files were owned by various different users.
How do I restore these files to their correct folders? The Google Drive Audit Log does not contain enough information to restore the folders correctly - the parent folder ID is not included with the "Remove from folder" event.
| How do I restore deleted documents from shared Google Drive folders? |
Use host path:create PV:kind: PersistentVolume
apiVersion: v1
metadata:
name: task-pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/datacreate PVC:kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: task-pv-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3GiUse it in a pod:kind: Pod
apiVersion: v1
metadata:
name: task-pv-pod
spec:
volumes:
- name: task-pv-storage
persistentVolumeClaim:
claimName: task-pv-claim
containers:
- name: task-pv-container
image: nginx
ports:
- containerPort: 80
name: "http-server"
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: task-pv-storagedocumentationThis is just an example, for testing only.For production use case, you will need dynamic provisioning using theStorageClassfor PVC, so that the volume/data is available when the pod moves across the cluster. | I have a 3-node Kubernetes cluster running on vagrant using the oracle Kubernetes vagrant boxes fromhttp://github.com/oracle/vagrant-boxes.git.I want to add a pod including an Oracle database and persist the data so that in case all nodes go down, I don't lose my data.According to how I read the Kubernetes documentation persistent volumes cannot be created on a local filesystem only on a cloud-backed device. I want to configure the persistent volume and persistent volume claim on my vagrant boxes as a proof of concept and training exercise for my Kubernetes learning.Are there any examples of how I might go about creating the PV and PVC in this configuration?As a complete Kubernetes newbie, any code samples would be greatly appreciated. | How do I create a persistent volume on an in-house kubernetes cluster |
The only thing that matters is the order in which resources are submitted to the Kubernetes cluster. TheChart.yamlandvalues.yamlfiles do not contain any executable code and they don't "run"per se. Each of the files intemplates/is processed independently, there is no global state, and a template file doesn't produce anything other than its YAML output, so the template files could be processed in any order or even all at the same time and you'd get the same result.Helm does havea specific orderin which it submits different kinds of objects to a cluster. These are intended to minimize problems from object dependencies being unresolved. For example, a Deployment can reference a ConfigMap, so ConfigMap is early in that list and Deployment much later on. Within each Kubernetes object kind, the objects are submitted in arbitrary order. | When I do hel install <app_name> which file or script among the chart.yaml, values.yaml or any other.Thanks in advance. | Which file/script runs first when i do helm install XYZ? |
You can define a multiline environment variable as below,read -d '' conf << EOF
if ($http_x_azure_fdid !~* "55ce4ed1-4b06-4bf1-b40e-4638452104da" ) {
return 403;
}
EOFOnce the environment variable is defined, refer it in the helm--set-string controller.config.server-snippet=arg as below,helm upgrade --install nginx-ingress-controller ingress-nginx/ingress-nginx \
--namespace "${namespace}" \
--version "${chart_version}" \
--set controller.replicaCount="${replicas}" \
--set-string controller.config.use-forwarded-headers=true \
--set-string controller.config.server-snippet=$conf \
--debugShareFollowansweredNov 27, 2020 at 8:37maanadevmaanadev6633 bronze badgesAdd a comment| | Related Github Issue :https://github.com/kubernetes/ingress-nginx/issues/6519apiVersion: v1
data:
server-snippet: |
if ($http_x_azure_fdid !~* "55ce4ed1-4b06-4bf1-b40e-4638452104da" ) {
return 403;
}
use-forwarded-headers: "true"
kind: ConfigMapHow to achieve the above config using helm when setting the values in the following approach?helm upgrade --install nginx-ingress-controller ingress-nginx/ingress-nginx \
--namespace "${namespace}" \
--version "${chart_version}" \
--set controller.replicaCount="${replicas}" \
--set-string controller.config.use-forwarded-headers=true \
--set-string controller.config.server-snippet=<?> \
--debug | How to set server snippets Config in Nginx Ingress with Helm |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.