Response
stringlengths
15
2k
Instruction
stringlengths
37
2k
Prompt
stringlengths
14
160
I think you misunderstand what memory stores like Redis or memcached can do for you.They are not connected to PostgreSQL or any other RDBMS. It is the job of your application to write the data in both stores: the permanent store (PostgreSQL in your case) and the transient one (Redis).Redis and memcached do not offer many connectivity features. For caching, they have a rather simple and unobtrusive behavior. The smart part to manage the cache is on application side, and it is your job to define it.You can imagine several strategies:each time you write in the RDBMS, you write in the cache. Each time you need to read the data, read first in the cache. If nothing is found, read from the RDBMS and write it back to the cache.each time you write in the RDBMS, you just invalidate the data in the cache (delete it). Each time you need to read the data, read first in the cache. If nothing is found, read from the RDBMS and write it back to the cache.The tricky part is to clearly define a policy regarding the consistency of the data (between the RDBMS and the cache).
I'm new to Redis and wondering how to use Redis and PostgreSql together — specifically using Redis just for LRU caching in Postgres.Is there any special configuration for connecting Redis to Postgres?Then if I want to store data, should I store it in Postgres db? If so, what does Redis do?Thanks.
How can I use Redis for LRU caching with Postgresql?
Somebody else pointed me to this help page:https://help.github.com/articles/about-commit-email-addresses/Which explains that you can have your personal emailadress hidden from all commits. If you want to hide your email, check the correct setting in github. This will give you a no-reply emailadress from github, which you can configure to use in any git repo via the typical git config user.email "[email protected]". Also, any changes made in the online github webpage will also use this no-reply emailadress.This is the solution to keep your personal emailadress private for pulic repo's.
I have a question: I recently made my personal github account to make some open-source projects. As a test, I created a dotfiles repo. From my machine, where the global properties point to my work github account, I have made some commits. That made my work remail show up in the public repo, which I didn't want. With rebasing and force pushing I solved that issue. I have rebased the author to my correct username of my personal github account, but left my email blank, because I also dont want to have my personal email show up. However, now the author of the commits has the right username, but it does not link to my account. This leads to my question:How do I config git to use my personal github account, so it links correctly, without showing any emailadress in any commit?Can I just config git so my user.email is my personal email, but can I count on it not showing up online?
How to link my commits to my github account, without showing emailadress in commit?
As per K8S documentation (Running in multiple zones), there is no requirement for master and worker node to be in same zone. It can span across multiple zones.It also states that if availability is an important concern, replicas should be created for control plane components and for pods across availability zones.ShareFollowansweredDec 6, 2021 at 18:23NansNans2155 bronze badgesAdd a comment|
I am beginner in K8s and searching for information running multiple worker nodes in different time-zones managed bysinglemaster node. Can someone guide me here?
Is it required that master and worker nodes should always run in same time-zone?
Instead of looping through columns you can try checking their values using exists. from pyspark.sql import functions as F columns_list = [f"`{c}`" for c in columns_list] df_reject = source_data.filter(F.exists(F.array(*columns_list), lambda x: x.rlike("[\"\"]"))) df_cols_add = df_reject.select('*', F.lit('Yes').alias('flag_quotes'), F.lit(err).alias('Error'))
I need to do a double quotes check in a dataframe. So I am iterating through all the columns for this check but takes lot of time. I am using Azure Databricks for this. for column in columns_list: column_name = "`" + column + "`" df_reject = source_data.withColumn("flag_quotes",when(source_data[column_name].rlike("[\"\"]"),lit("Yes")).otherwise(lit("No"))) df_quo_rejected_df = df_reject.filter(col("flag_quotes") == "Yes") df_quo_rejected_df = df_quo_rejected_df.withColumn('Error', lit(err)) df_quo_rejected_df.coalesce(1).write.mode("append").option("header","true")\ .option("delimiter",delimiter)\ .format("com.databricks.spark.csv")\ .save(filelocwrite) I have got around 500 columns with 40 million records. I tried union the dataframes every iteration but the operation does OOM after sometime. So I save the dataframe and append it every iteration. Please help me with a way to optimize the running time.
Out of memory while checking string columns and saving error values to Databricks
Constants have no storage location at runtime. All access to constant identifiers results in the literal value of that constant replacing the identifier when the code is compiled.
In my code design, I've included a lot of constants. When a new object is created, is memory allocated for that object's constants, or is it stored permanently in a single instance, like a static variable is? In terms of memory storage, where exactly do static items end up? In other words, if I define 100 objects, will there be 100 copies of the same constant value? If they are defined in static memory (wherever that is), and I would expect that they are, does accessing them require the computer to switch memory pages? Is there a performance hit for constantly accessing constants instead of variables? Thanks Ares
Does each object allocate memory for constants?
You need to fix your regex as^and$are not matched in the middle:RewriteRule ^api/geopointsnearlocation/(-?(?:\d+|\d*\.\d+))/(-?(?:\d+|\d*\.\d+))/?$ api/GeoPointsRestController.php?lat=$1&lng=$2 [NC,QSA,L]
I am trying to write aRewriteRulein my.htaccessfile so that it accepts two double arguments (a latitude and a longitude) and redirects to a php webservice controller with those arguments asGETvariables.So far and with the help ofthis answer, I got this rule:RewriteRule ^api/geopointsnearlocation/(/^-?(?:\d+|\d*\.\d+)$)/(/^-?(?:\d+|\d*\.\d+)$)/$ api/GeoPointsRestController.php?lat=$1&lng=$2 [nc,qsa]but when I use this url:http://localhost/api/geopointsnearlocation/29%2E9876/50%2E8765/to call my webservice I get this error message:The requested URL /api/geopointsnearlocation/1.2/2.3/ was not found on this server.Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.I tried to pass the numbers as29.9876or29, but none of them work.I am guessing somehow my regular expression is wrong.could anybody help me?PS: I am pretty sure thatGeoPointsRestController.phpexists and is in the right path
a .htaccess RewriteRule that takes to Double arguments and sends it to a webservice in php
I had the same problem and I followed the official installation guide and it worked. I think my keyrings was outdated or something.https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository# Add Docker's official GPG key: sudo apt-get update sudo apt-get install ca-certificates curl gnupg sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg # Add the repository to Apt sources: echo \ "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get updateNote:If you use an Ubuntu derivative distro, such as Linux Mint, you may need to use UBUNTU_CODENAME instead of VERSION_CODENAME.# Remember to start the docker container after installation by running $: sudo service docker start
The Ubuntu machine contains the latest upgrades, but unable to install docker-compose-pluginsudo apt-get install docker-compose-plugin Reading package lists... Done Building dependency tree... Done Reading state information... Done E: Unable to locate package docker-compose-plugin cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=22.04 DISTRIB_CODENAME=jammy DISTRIB_DESCRIPTION="Ubuntu 22.04.2 LTS"
sudo apt-get install docker-compose-plugin fails on jammy
You've misled yourself because as a human, you know that "01", "02", etc are a sequence of numbers. Regular expressions don't care about numbers, they care aboutcharacters.[01-09]doesn't mean "01 to 09", it means "0; or 1 to 0; or 9" - which clearly doesn't make sense.If you break it down character by character, you have:"0""x""0" or "1" (in regex terms, the set[01])"0" to "9" (the character range[0-9]), or "A" to "F" ([A-F])plus the special case of "0x7F"So you could for instance write:0x[01]([0-9]|[A-F])|0x7FYou can combine the two ranges into one, giving:0x[01][0-9A-F]|0x7FSharing the0xdoesn't actually make it any shorter:0x([01][0-9A-F]|7F)
I have tried to write the htaccess for the set of rules.below is the rule pattern I want to match0x00|0x01|0x02|0x03|0x04|0x05|0x06|0x07|0x08|0x09|0x0A|0x0B|0x0C| 0x0D|0x0E|0x0F|0x10|0x11|0x12|0x13|0x14|0x15|0x16|0x17|0x18|0x19| 0x1A|0x1B|0x1C|0x1D|0x1E|0x1F|0x7FI have tried as0x([01-09]|[0A-0F]|[10-19]|[1A-1F]|7F)
Pattern for matching a rule
Had to reach out to BitBucket to clear the repo on their end first before allowing me to push.ShareFollowansweredAug 21, 2018 at 15:46Joe ScottoJoe Scotto11.3k1717 gold badges6767 silver badges142142 bronze badgesAdd a comment|
I accidentally pushed some large files that were supposed to be ignored to git and as a result my repo is over 2gb. I'm trying to clear some files out with BFG and have been able to clear around 400mb but when trying to push I get the following errorCounting objects: 1510, done. Delta compression using up to 8 threads. Compressing objects: 100% (621/621), done. Writing objects: 100% (1510/1510), 373.84 MiB | 11.69 MiB/s, done. Total 1510 (delta 879), reused 1403 (delta 778) remote: Resolving deltas: 100% (879/879), completed with 95 local objects. remote: repository is in read only mode (over 2 GB size limit). remote: remote: Learn how to reduce your repository size: https://confluence.atlassian.com/x/xgMvEw. To https://bitbucket.org/HIDDEN/REPO.git ! [remote rejected] feature/feature -> feature/wikitude (pre-receive hook declined) error: failed to push some refs to 'https://bitbucket.org/HIDDEN/REPO.git'I read online that a force push could solve this but I feel that might be risky, I do have a backup with--mirrorof my repo before the file deletions with bfg.
Can't push to >2gb repo after clearing files with BFG
.NET 8 ASP.NET Core Docker images have a breaking change - Default ASP.NET Core port changed from 80 to 8080: The default ASP.NET Core port configured in .NET container images has been updated from port 80 to 8080. We also added the new ASPNETCORE_HTTP_PORTS environment variable as a simpler alternative to ASPNETCORE_URLS. Previous behavior Prior to .NET 8, you could run a container expecting port 80 to be the default port and be able to access the running app. For example, running the following command allowed you to access the app locally at port 8000, which is mapped to port 80 in the container: docker run --rm -it -p 8000:80 <my-app> So you need either to change port mapping 8860:8080 or change the port for the container (for example by passing -e ASPNETCORE_HTTP_PORTS=80 argument to docker run or adding ENV ASPNETCORE_HTTP_PORTS=80 after FROM mcr.microsoft.com/dotnet/aspnet:8.0).
I migrated my application to .NET 8.0, ran it locally and it works perfectly. Then I created an image, the container. As a result, the page that was working before now returns a "1.2.3.4 refused to connect." Before, when I was in .NET 7.0, the API worked. My basic DockerFile FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env WORKDIR /app COPY *.csproj ./ RUN dotnet restore COPY . ./ RUN dotnet publish -c Release -o out FROM mcr.microsoft.com/dotnet/aspnet:8.0 WORKDIR /app RUN chmod -R 755 /app COPY --from=build-env /app/out . ENTRYPOINT ["dotnet", "myapi.dll"] My api runs on port 8860 49de1a3ce47c myapi "dotnet myapi.dll" 13 minutes ago Up 13 minutes 0.0.0.0:8860->80/tcp, :::8860->80/tcp Logs: info: Microsoft.Hosting.Lifetime[14] Now listening on: http://[::]:8080 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Production info: Microsoft.Hosting.Lifetime[0] Content root path: /app
.NET 8.0 WebAPI/Swagger Docker Refused to connect
Your pods might have quality of service class set to Guaranteed, that's possible reason they are not getting evicted.See:https://kubernetes.io/docs/tasks/configure-pod-container/quality-service-pod/#qos-classes
I changed the default eviction policy set by kops to include the conditionmemory.available<1Gi. The--eviction-hardflag is now set as:memory.available<1Gi,nodefs.available<10%,nodefs.inodesFree<5%,imagefs.available<10%,imagefs.inodesFree<5%The available memory on one node right now is at 400Mb and has been like this for quite a while. No pod eviction is happening.Why isn't the kubelet evicting pods to make room? There's plenty of room on other nodes.Is there anANDbetween eviction conditions? How can I see what the kubelet sees for memory usage?
Kubernetes does not evict nodes despite limit being set
Just create individual location blocks and include/exclude whatever you want. You can repeat "includes" in each as neededFor example:location ~ ^/front/? { # Here we only include the common_auth file include common_auth.conf.inc; } location ~ ^/(index|index_(rest|cluster|treemenu_tags))\.php(/|$) { # Here we also only include the common_auth file include common_auth.conf.inc; .... } location / { # Here we also include the common_auth file # As well as the ez_rewrite_params include ez_params.d/ez_rewrite_params; include common_auth.conf.inc; }Note that you don't use "last" for including filesShareFolloweditedAug 25, 2015 at 20:44answeredAug 25, 2015 at 19:02DayoDayo12.6k55 gold badges5353 silver badges6767 bronze badgesAdd a comment|
I have the following .conf in Nginxlocation / { if ($uri !~ ^/front/? ){ include ez_params.d/ez_rewrite_params last; } include common_auth.conf.inc; location ~ ^/(index|index_(rest|cluster|treemenu_tags))\.php(/|$) { #bunch of rules here } }What I am trying to do here here is excluding the /front/ folder from all EzPublish rewrite rules. However, not only does this not work, it even gives me an error while trying to load this file:"nginx: [emerg] "include" directive is not allowed here in /etc/nginx/conf.d/staging-preview.conf:51 nginx: configuration file /etc/nginx/nginx.conf test failed"I found out that using the "if" is pretty much not done, seehttp://wiki.nginx.org/IfIsEvil, but I don't understand what I should do instead.
Nginx excluding directory from redirect rules
From what AWS claims about RDS proxy: The same consideration applies for RDS DB instances in replication configurations. You can associate a proxy only with the writer DB instance, not a read replica. https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/rds-proxy.html
I created an RDS Proxy with existing Aurora PostgreSQL cluster. But I want to pair the proxy with specific read replica instance of the cluster. Is that possible?
Can AWS RDS Proxy be paired with read replication instance directly?
You can convert the pixel format fromBGRtoBGRASeethisexample.
Whenever i read a colored image with 3 channels via cv::imread; its data alignment is a bit awkward (neither a byte nor an integer) and slows me down when i read a single pixel data on GPU memory. And it seems cv::Mat class's logic behind the alignment is a bit different than what i had initially thought. It does not add an extra byte between two pixels in a single row in order to have each pixel in a row started at every 4 bytes; but rather it pads some extra bytes at the END of each row for which any row may start at every 4 bytes boundary.What should i do to pack each pixel data into a single unsigned integer? Is there a built-in method in OpenCV so that i do not have to use logical OR operation for packing each pixel data one by one?Kind Regards.
Packing Pixel Data in OpenCV
I solve this problem using ssh link instead of https.
I have already cloned repository into my computer from github. For clone I used GitHub client. After that I import my project in Android Studio and say about git linking in settings of Version Control.Meantime my colleague push 1 commit into master branch and ask me for updating project. Usual situation.After that I trying to update project and AS ask me about credentialsI put correct credentialsand click OK. But I was confused when Android Studio ask me about entering credentials again and again, thought 3 times, and show errorFetch failed.I try to pull and rebase via GitHub Shell client, and all was good. But when I trying to update my project via Android Studio it produces error above.I really confused about this, maybe I do something wrong?
Android Studio determines credentials for GitHub as invalid
5 You can modify or add your /etc/sysconfig/docker ADD_REGISTRY='--add-registry 192.168.0.169:5000' INSECURE_REGISTRY='--insecure-registry 192.168.0.169:5000' then modify /etc/systemd/system/docker.service or /usr/lib/systemd/system/docker.service ExecStart=/usr/bin/dockerd --registry-mirror=http://192.168.0.169:5000 when you pull a image,docker will pull it from your private registry first,and then docker hub if not found in your private registry.I am working on CentOS 7 Docker 1.12. Share Improve this answer Follow edited Dec 21, 2016 at 10:45 answered Dec 21, 2016 at 10:17 pigletflypigletfly 1,05111 gold badge1717 silver badges3232 bronze badges 1 This is exactly what I was looking for – Dinesh Dec 17, 2019 at 17:13 Add a comment  | 
I am using docker-registry to pull my own docker images, but I want to do so without the need to specify the host. meanning: instead of writing: docker pull <host>:<port>/<dockerImage> I want to write: docker pull <dockerImage> and first it will try to pull the docker from my private registry, before trying to pull it from the public docker registry. Is it possible? I tried to change the DOCKER_INDEX_URL to [my_docker_registry_host]:[port], but it doesn't work.
Pull Docker from my private docker-registry without specifying the host
4 I am working with Java AmazonS3 client, but the process should be the same. There is a strategy that can be used to handle this situation. You could use a fixed date time as an expiration date. I set this date to tomorrow at 12 pm. Now every time you generate a url, it will be the same throughout that day until 00:00. That way browser caching can be used to some extent. Share Follow answered Jun 11, 2019 at 12:18 Developer ThingDeveloper Thing 2,75433 gold badges2222 silver badges2727 bronze badges 3 1 Nice way. Full explanation: bennadel.com/blog/… – Adarsh Madrecha Jan 26, 2021 at 9:19 I use this function s3.getSignedUrl("getObject", {Bucket: "mybucket", Key:'myImage", Expires:18000} ) which specifies the url to expire in 180000seconds or 5 hours. How to set fixed date time instead of a amount of time as expiration? – KJ Ang Jul 27, 2021 at 16:25 1 @AdarshMadrecha answer is the way. I tested his answer and it works. Read the link he provided: advancedweb.hu/cacheable-s3-signed-urls. It has detailed explanation of the approach. – KJ Ang Jul 28, 2021 at 5:37 Add a comment  | 
I am generating signed urls on my webapp (nodejs) using the knox nodejs-library. However the issue arises, that for every request, I need to regenerate an unique GET signed url for the current user, leaving browser's cache-control out of the game. I've searched the web without success as browsers seem to use the full url as caching key so I am really curious how I can, under the given circumstances (nodejs, knox library) get the issue solved and use caching control while still being able to generated signed urls for each and every request as I need to verify the user's access rights. I cannot believe there's no solution to that though.
S3, Signed-URLs and Caching
You can declare environment vars on YAML as on Docker Files, just with different syntax.Here's the example you requested:apiVersion: v1 kind: Pod metadata: name: envar-demo spec: containers: - name: envar-demo image: busybox args: - sleep - "86400" env: - name: spring.datasource.url value: "jdbc:postgresql://192.168.100.100/my_database" - name: spring.datasource.username value: "my_username" - name: spring.datasource.password value: "my_password!@#$"Now I'll create a simple busybox container to show in runtime the variables activated:user@minikube:~$ kubectl apply -f envar-pod.yaml pod/envar-demo created user@minikube:~$ kubectl get pods NAME READY STATUS RESTARTS AGE envar-demo 1/1 Running 0 8s user@minikube:~$ kubectl exec -it envar-demo -- /bin/sh / # printenv HOSTNAME=envar-demo SHLVL=1 HOME=/root TERM=xterm spring.datasource.password=my_password!@#$ spring.datasource.url=jdbc:postgresql://192.168.100.100/my_database spring.datasource.username=my_username PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PWD=/ / #For more information refer toEnvironment Variable Expose
So the other day I just learned about Docker and I could use in my Docker-Compose YAML file something like:environment: - spring.datasource.url=jdbc:postgresql://192.168.100.100/my_database - spring.datasource.username=my_username - spring.datasource.password=my_password!@#$$I like to implement this on my Kubernetes YAML file. How can I do this?
How do I set the environment for spring.datasource on a spring-boot container using a Kubernetes YAML file ? Is it the same as Docker YAML?
0 One reason those numbers are so different is that the process can reserve virtual address ranges as inaccessible, simply to prevent future calls such as mmap() from using them accidentally. Such inaccessible ranges are included in VSS, but not in Committed_AS. Here are two examples of when such inaccessible ranges are used: 1) If you are using libc malloc in a multi-threaded process, it typically creates multiple "arenas" as a way to help reduce lock contention between threads doing malloc at the same time. For every arena other than the first one (called the main arena) the memory is reserved in fixed size heaps. In the 64-bit case those heaps are 64 megabytes each but when a heap is initially created, only the beginning is given RW access. The tail of the heap is made inaccessible and as the heap grows the process gradually expands the part that is readable and writable and shrinks the part that is inaccessible. 2) When shared libraries are loaded, some of the sections have alignment constraints as large as 2MB in a recent 64-bit Linux process. Typically this leaves one inaccessible region in the middle of the address range used by each shared library, and such regions are generally either 2MB or 2MB-4K in size. Share Improve this answer Follow answered Jun 14, 2018 at 15:39 Tim BoddyTim Boddy 1,03977 silver badges1313 bronze badges Add a comment  | 
I'm running the following two commands on my system and coming up with different numbers: [root@rhel6 ~] grep Committed_AS /proc/meminfo Committed_AS: 82964 kB [root@rhel6 ~]# ps aux | awk '{vsz+=$5}END{print vsz}' 1580824 My understanding is that Committed_AS is the amount of virtual memory currently allocated on the system. In my second command I'm summing the VSZ column (allocated virtual memory reported in kB) from the output of 'ps aux'. Why aren't these numbers the same? They're VERY different, so I'm obviously not understanding something along the way. Any help?
Difference between Committed_AS and sum of the VSZ column in ps
You will need to add anAccept: application/vnd.github.spiderman-previewheader to your request in order to access the Repo Traffic API whilst it is in preview form. From theAPI docs:APIs for repository traffic are currently available for developers to preview. During the preview period, the APIs may change without advance notice. Please see the blog post for full details.To access the API you must provide a custom media type in the Accept header:application/vnd.github.spiderman-preview
I was using github API in Meteor but could not solved this issue:This code tries to get the total number of traffic for a certain repo.HTTP.call( 'GET', 'https://api.github.com/repos/hackmdio/hackmd/traffic/views', { headers: { 'Content-Type':'application/json', "Accept":"application/vnd.github.v3+json", "User-Agent": "whales" }, }, function( error, response ) { if ( error ) { console.log('---------------------------error occurred-----------------------------------') console.log('---------------------------error occurred-----------------------------------') console.log( error ); } else { console.log('--------------------------data got it!!-------------------------------------') console.log('--------------------------data got it!!-------------------------------------') console.log(response); } });Error:{ "message": "If you would like to help us test the Repo Traffic API during its preview period, you must specify a custom media type in the 'Accept' header. Please see the docs for full details.", "documentation_url": "https://developer.github.com/v3" }I searched for similar issues and added "Content-Type" and "Accept" but it's still not working.I then tried doing this in Postman and also in terminal with the same headers but this error kept happening.Thanks a lot.
github API unsupported media type 415
You can see an animated gif in thiskellim/farmers-market-finderREADME file.Thesource codeshows that gif embedded as any other picture:![Farmers Market Finder - Animated gif demo](demo/demo.gif)You have the same method used in "How to add GIFs to your GitHub README" fromJoe Cardillo.
The animated gif I have is 2.5MB size Converted it from mp4 video.
How can I add embed animated gif to a github repository README.md?
You only need to re-examine your algorithms when your customers complain about the slowness of your program or it is missing critical deadlines. Otherwise focus on correctness, robustness, readability, and ease of maintenance. Until these items are achieved any performance optimization is a waste of development time.Page faults and disk operations may be platform specific. Alwaysprofileyour code to see where the bottlenecks are. Spending time on these areas will produce the most benefits.If you're interested, along with page faults and slow disk operations, you may want to aware of:Cache hits -- Data Oriented DesignCache hits -- Reducing unnecessary branches / jumps.Cache prediction -- Shrink loops so they fit into the processor's cache.Again, these items are only after quality has been achieved, customer complaints and a profiler has analyzed your program.
Once again, I find myself with a set ofbroken assumptions. The article itself is about a 10x performance gain by modifying a proven-optimal algorithm to account for virtual memory:On a modern multi-issue CPU, running at some gigahertz clock frequency, the worst-case loss is almost 10 million instructions per VM page fault. If you are running with a rotating disk, the number is more like 100 million instructions.What good is an O(log2(n)) algorithm if those operations cause page faults and slow disk operations? For most relevant datasets an O(n) or even an O(n^2) algorithm, which avoids page faults, will run circles around it.Are there more such algorithms around? Should we re-examine all those fundamental building blocks of our education? What else do I need to watch out for when writing my own?Clarification:The algorithm in question isn't faster than the proven-optimal one because the Big-O notation is flawed or meaningless. It's faster because the proven-optimal algorithmrelies on an assumption that is not true in modern hardware/OSes, namely that all memory access is equal and interchangeable.
Algorithms for modern hardware?
The underlying virtualization solutions are calledproviders. To work with Vagrant, you have to install at least one provider (e.g. Virtualbox, VMWare)Provisioning in Vagrant is the process of automatic installation and configuration of the system within during$ vagrant upand the tools to perform this operation are calledprovisioners(e.g. Shell scripts, Chef, Puppet).
I think the words "Provider" and "Provisioner" sound very similar which may lead to confusion especially among beginners confronted with documentation where both terms are mixed up or used synonymous (already seen on the net). Even more confusing it gets when beginners seeDocker as ProviderandDocker as Provisionermentioned onVagrant´s website.So this question is actually about three things:What is a Vagrant Provider?What is a Vagrant Provisioner?How does Docker fit in here?What could be a typical use case for Docker as Vagrant Provider?What could be a typical use case for Docker as Vagrant Provisioner?I appreciate explanations, examples and links for further reading which illustrate things clearly (even for noobs).
What is the difference between a Vagrant Provider and a Vagrant Provisioner?
Look like the reason why code is not covered is in theFAQCode with exceptions shows no coverage. Why?JaCoCo determines code execution with so called probes. Probes are inserted into the control flow at certain positions. Code is considered as executed when a subsequent probe has been executed. In case of exceptions such a sequence of instructions is aborted somewhere in the middle and not marked as executed.Still i don't understand why the coverage of the direct throw still appears on sonarShareFollowansweredJan 25, 2015 at 3:38Thai TranThai Tran9,84577 gold badges4545 silver badges6666 bronze badges2Which version of SonarQube are you using?–CSchulzJan 27, 2015 at 8:45@CSchulz: I used both 4.2 and 4.5–Thai TranJan 28, 2015 at 2:13Add a comment|
I am writing code coverage for my project and experiencing a weird behavior. I have a function like thispublic void testException(int i) throws Exception { if (i == 0) { throw new Exception("exception"); } }and the test case@Test public void testException() { try { mapper.testException(0); fail("Wrong"); } catch (Exception ex) { assertEquals("exception", ex.getMessage()); } }After running test case through maven (mvn sonar:sonar), then the branch is covered in Sonar. However, if the tested function is like thispublic void testException(int i) throws Exception { if (i == 0) { throwException(); } } public void throwException() throws Exception { throw new Exception("exception"); }then theifbranch is not covered, though the inner ofthrowExceptionfunction is actually executed. Is there anyway to overcome this problem? I need to cover 100% of the class
Sonar cannot cover branches calling to Exception throwing function
It depends a bit on your Bamboo and beanstalk config as well as the type of application you are planning to deploy on AWS Beanstalk. We did some things for Java Web Apps: Since Bamboo understands maven, you can have a look at the following maven plugin: http://beanstalker.ingenieux.com.br/beanstalk-maven-plugin/configurations-and-templates.html We are using it for some environments to create wars and upload them to elastic beanstalk. You can then create a maven task in bamboo to call the plugin. If you downloaded and installed Bamboo on a machine you own yourself you could use the Elastic Beanstalk command line interface (CLI). This is probably the most powerful approach, but you need to install the CLI on the bamboo instance. Then you can do almost anything. This approach should also work for other environments besides Java/Tomcat. Another idea: If you use Beanstalk using git (i.e. you deploy by making a code change and pushing to Beanstalk), then you can also use the new "Deployment Project" Feature in Bamboo to push the code once it passes all tests.
I want to integrate Atlassian Bamboo with AWS Elastic Beanstalk. Is there anyway to do this?
How to integrate Atlassian Bamboo with AWS Elastic Beanstalk
Unless it's for academic purposes, you rarely see a C++ program using manual memory allocation, you don't need to do it since you have a set of containers in the STL containers library that do this memory management reliably for you. In your particular example, a std::vector is recommended. That said, to answer your question: It won't print anything if delete[] arr is above return arr[6] (Using Visual Studio 2019). If you delete the array before accessing the data stored in it the behavior is undefined. It's only natural that it doesn't print anything. It could also print the expected result, that's one of the features of undefined behavior. Using Visual Studio or not, it's the same. But if return arr[6] is above delete[] arr, would the memory be freed or this sentence be skipped? Yes it would be skipped, or more accurately, all code after the return statement will not be executed. The memory will not be freed. Or should I declare arr inside main() then free it in main()? If the data should belong in the main's scope you should definitely declare it there, you can pass it to the function as an argument: #include <cassert> #include <iostream> int fun(int* arr) { assert(arr); for (int i = 0; i < 10; i++) { arr[i] = 5; } return arr[6]; } int main() { int* arr = new int[10]; std::cout << fun(arr); delete[] arr; return 0; }
I have a function like this: int fun(){ int* arr = new int[10]; for(int i = 0; i < 10; i++){ arr[i] = 5; } delete[] arr; // return arr[6]; } int main(){ std::cout << fun(); return 0; } What am i going to do is to free the memory whick is pointed to by the pointer arr. But the function is not returning pointer arr. So i tryed to free it inside the function. It won't print anything if delete[] arr is above return arr[6] (Using Visual Studio 2019). But if return arr[6] is above delete[] arr , would the memory be freed or this sentence be skipped? Or should i declare arr inside main() then free it in main()?
How to free memory allocated in a function without returning its pointer?
This is probably going to end up fine, and Git will not produce duplicate code. When you do a merge, Git looks at the two heads (the branches you're merging), plus the merge base, which is usually the most recent common commmit. If both heads have the exact same contents for a file, then the merge is trivial, and Git picks that result. If they don't, it tries to incorporate the changes from each side. When it does this, if the changes are to two separate areas of code, the merge succeeds, because Git will include the change from each side. If the changes are to the same area, but they're identical changes, then Git just takes that identical piece (once) and uses it in the result. If you have different changes to the same area, then Git will conflict and you'll have to resolve things manually. If the merge succeeds without conflicts, then Git will probably have done the right thing and you'll get a sane result, although sometimes merges do result in odd behavior because Git only operates on lines and doesn't intrinsically know about the structure of your code. Usually you can detect this by building and testing your code, and in typical practice, unexpected behavior happens very rarely. Git doesn't duplicate code if both sides have similar changes; at worst, it conflicts and lets you figure out what to do. If the merge has conflicts, you'll have to resolve them by hand. If you're doing the merge through GitHub using a pull request, it will tell you if there are conflicts or not in the pull request. If you're doing them on the command line, then you just have to try and see how it works out.
I have a branch A which i want to merge with branch B (updated), there have been some code/files commit to branch A manually from branch B. Now i want to auto merge complete chages from branch B to A. I have below queries/doubts on this - When i tried to do automatic merge, git shows new code/files addition/update which are already present in branch A as part of manual update/commit previously done. Is it fine if go ahead and merge them, would there be code/file duplicacy ? Or should i be doing manual merge ? but there are lots of changes Give me chance to explain more if its not clear. Any help would be appreciated.
Git automatic merge on top of maual update/commit from the same branch which is going to be merged
You needRewriteCond:RewriteModule On RewriteCond %{HTTP_USER_AGENT} Mac\ OS\ X.*Chrome RewriteRule .* /path/to/something [L,R]
I need to redirect if the user is accessing the site usingChrome OS X, but notChrome Windowsor any other OS - and the same for Safari.Can I detect, specifically,Chrome OS Xand ignoreChrome Windows? Ithinkthese are the user-agents for the two:Chrome, MAC OS Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.91 Safari/534.30 Chrome, Windows 2008 Mozilla/5.0 (Windows NT 6.0) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.91 Safari/534.30
.htaccess rewrite for specific browser/operating-system combination
Yes, you can use VirtualAlloc and VirtualProtect to set up sections of memory that are protected from read/write operations. You would have to re-implement operator new and operator delete (and their [] relatives), such that your memory allocations are controlled by your code. And bear in mind that it would only be on a per-page basis, and you would be using (at least) three pages worth of virtual memory per allocation - not a huge problem on a 64-bit system, but may cause problems if you have many allocations in a 32-bit system. Roughly what you need to do (you should actually find the page-size for the build of Windows - I'm too lazy, so I'll use 4096 and 4095 to represent pagesize and pagesize-1 - you also will need to do more error checking than this code does!!!): void *operator new(size_t size) { Round size up to size in pages + 2 pages extra. size_t bigsize = (size + 2*4096 + 4095) & ~4095; // Make a reservation of "size" bytes. void *addr = VirtualAlloc(NULL, bigsize, PAGE_NOACCESS, MEM_RESERVE); addr = reinterpret_cast<void *>(reinterpret_cast<char *>(addr) + 4096); void *new_addr = VirtualAlloc(addr, size, PAGE_READWRITE, MEM_COMMIT); return new_addr; } void operator delete(void *ptr) { char *tmp = reinterpret_cast<char *>(ptr) - 4096; VirtualFree(reinterpret_cast<void*>(tmp)); } Something along those lines, as I said - I haven't tried compiling this code, as I only have a Windows VM, and I can't be bothered to download a compiler and see if it actually compiles. [I know the principle works, as we did something similar where I worked a few years back].
Having read this interesting article outlining a technique for debugging heap corruption, I started wondering how I could tweak it for my own needs. The basic idea is to provide a custom malloc() for allocating whole pages of memory, then enabling some memory protection bits for those pages, so that the program crashes when they get written to, and the offending write instruction can be caught in the act. The sample code is C under Linux (mprotect() is used to enable the protection), and I'm curious as to how to apply this to native C++ and Windows. VirtualAlloc() and/or VirtualProtect() look promising, but I'm not sure how a use scenario would look like. Fred *p = new Fred[100]; ProtectBuffer(p); p[10] = Fred(); // like this to crash please I am aware of the existence of specialized tools for debugging memory corruption in Windows, but I'm still curious if it would be possible to do it "manually" using this approach. EDIT: Also, is this even a good idea under Windows, or just an entertaining intellectual excercise?
Is it possible to protect a region of memory from WinAPI?
usually means bad gateway (there is no connection) and that IP address looks like an internal IP address. GrafanaCloud is a cloud service so it does not have access to internal IP addresses.Your options are:Install Grafana locally if you do not want to open up anything over the internet.Use direct mode instead of proxy mode. This means that requests will go directly from your browser to the elasticsearch server and not go through the Grafana backend server. However, GrafanaCloud is on https so you will get a mixed content warning and you would need to solve that by having a proxy in front of your elasticsearch server (or by setting up https for your server).Make your server accessible over the internet. Setup a static IP address for your elasticsearch server, setup firewall rules etc. so that GrafanaCloud can query your server.
I'm using grafana cloud for creating visualization but when i'm trying to load the data source with elasticsearch i'm getting 502 error.
Cannot access data source of elasticsearch using grafana cloud
Periods 4 and 5 are not set globally but on the project level. Double-check your first project to make sure it has a valid Period 5 value.
I have setup a project with a specific date in sonar.timemachine.period5 in my project.properties file. This usually works perfectly, but sometimes the sonarqube runner doesn't make the comparison.sonar.timemachine.period5=2015-11-04Here is a part of the log output from two consecutive sonar-runner analysis:This one is not comparing against period 5:10:28:17.546 INFO - Loaded quality gate 'MyProject' 10:28:17.591 INFO - Compare to previous analysis (2015-10-26) 10:28:17.596 INFO - Compare over 30 days (2015-10-24, analysis of Mon Oct 26 09:26:01 CET 2015) 10:28:17.597 INFO - Compare to previous version (2015-10-26)while this one is....10:37:43.996 INFO - Loaded quality gate 'MyProject' 10:37:44.054 INFO - Compare to previous analysis (2015-11-23) 10:37:44.060 INFO - Compare over 30 days (2015-10-24, analysis of Mon Oct 26 09:26:01 CET 2015) 10:37:44.061 INFO - Compare to previous version (2015-11-23) 10:37:44.062 INFO - Compare to date 2015-11-04 (analysis of 2015-11-23Any clues on why this is happening?The result is that the project sometimes passes the qualitygate when it certainly shouldn't.Im running SonarQube 5.1.2 and using Sonar-Runner 2.4
Sometimes Sonarqube doesn't compare to period 5
As binarygiant requested I am posting my comment as an answer. I have solved this problem by adding No-Cache headers to the response on server side. Note that you have to do this for GET requests only, other requests seems to work fine. binarygiant posted how you can do this on node/express. You can do it in ASP.NET MVC like this: [OutputCache(NoStore = true, Duration = 0, VaryByParam = "None")] public ActionResult Get() { // return your response }
I currently use service/$resource to make ajax calls (GET in this case), and IE caches the calls so that fresh data cannot be retrieved from the server. I have used a technique I found by googling to create a random number and append it to the request, so that IE will not go to cache for the data. Is there a better way than adding the cacheKill to every request? factory code .factory('UserDeviceService', function ($resource) { return $resource('/users/:dest', {}, { query: {method: 'GET', params: {dest: "getDevicesByUserID"}, isArray: true } }); Call from the controller $scope.getUserDevices = function () { UserDeviceService.query({cacheKill: new Date().getTime()},function (data) { //logic }); }
Better Way to Prevent IE Cache in AngularJS?
If you want to rewrite url only if the file doesn't exist you can use named location intry_filesdirective.location /services { try_files $uri $uri/ @service_pages; } location @service_pages { rewrite ^/services/page([1-3]).html /page$1.html; }
I have the nginx config:server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /var/www/site/public; index main.html; server_name localhost; location / { try_files $uri $uri/ =404; }At root directory I also have html files:page1.html, page2.html, page3.html. I would like to configure route mysite.com/services/page1 to file page1.html. etc. How can I do it? I tried it:location = /services/page1 { try_files /page1.html;}But it doesn't work.
nginx how to configure route to html file?
You could prepend another rule to exclude only that directory:RewriteCond %{REQUEST_URI} ^/menu RewriteRule . /club/index.php [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /club/index.php [L]ShareFolloweditedSep 15, 2011 at 1:03answeredSep 14, 2011 at 18:06fcingolanifcingolani59122 silver badges55 bronze badges1Thanks! I will check this soon. I managed to solve this problem with a directory and a index.php file where I included the wp-load file, after that the theme header and footer and after that the embeded flash file. Thank you very much and I'm sure that I will need this soon!–Adrian FlorescuSep 15, 2011 at 22:45Add a comment|
I have a Wordpress website with permalinks with post name. Now I have a new template on a specific page that uses files from exactly the same url path, and I can't change that. How can I make Wordpress access my requested page (example.com/meniu/) and ignore the folder name with same name? (example.com/menu/swf/)Thank you!This is my .htaccess. How can I add exclusions?<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /club/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /club/index.php [L] </IfModule>
Wordpress - Permalinks and folders (.htaccess ?)
In the branch protection rules, there's a setting "Include administrators". Make sure to enable that as well.More information can be found in thedocs.
Starting to setup branch protection rules for our Main branches and currently have the following options enabled:Require a pull request before mergingRequire approvals = 1Require conversation resolution before mergingHowever I noticed in a PR there was an option to "Merge without waiting for requirements to be met (bypass branch protection)":Is there a way to disable this option for all users? I did see an option for "Allow specified actors to bypass required pull requests", but is not really the same thing.Thanks in advance!
GitHub Branch Protection Disable Bypass
If a space is used in the URI query, it must either be replaced by%20(percent encoding) or by+(application/x-www-form-urlencodedcontent typefor forms). In your case the data seems to be encoded three times (%is encoded with%25).Try these rules to replace such sequences it with+:RewriteCond %{QUERY_STRING} (.*?)%(25)+20(.*?%(25)+20.*) RewriteRule ^ %{REQUEST_URI}?%1+%3 [N] RewriteCond %{QUERY_STRING} (.*?)%(25)+20(.*) RewriteRule ^ %{REQUEST_URI}?%1+%3 [L,R=301]
When I click on my index'd pages in Google the plus signs in my query string are being replaced (encoded?) for %252520.Anyone know why?Example:lovelakedistrict.com/result/?q=Private%252520car%252520park&page=2should belovelakedistrict.com/result/?q=Private+car+park&page=2I have heard that this is a result of redirecting my urls in htaccess?
Plus signs being replaced for %252520
TL;DR run it from the root directory: docker build . -f ./path/to/dockerfile the long answer: in dockerfile you cant really go up. why when the docker daemon is building you image, it uses 2 parameters: your Dockerfile the context the context is what you refer to as . in the dockerfile. (for example as COPY . /app) both of them affect the final image - the dockerfile determines what is going to happen. the context tells docker on which files it should perform the operations you've specified in that dockerfile. thats how the docs put it: A build’s context is the set of files located in the specified PATH or URL. The build process can refer to any of the files in the context. For example, your build can use a COPY instruction to reference a file in the context. so, usually the context is the directory where the Dockerfile is placed. my suggestion is to leave it where it belongs. name your dockerfiles after their role (Dockerfile.dev,Dockerfile.prod, etc) thats ok to have a few of them in the same dir. the context can still be changed: after all, you are the one that specify the context. since the docker build command accepts the context and the dockerfile path. when i run: docker build . i am actually giving it the context of my current directory, (ive omitted the dockerfile path so it defaults to PATH/Dockerfile) so if you have a dockerfile in dockerfiles/Dockerfile.dev, you shoul place youself in the directory you want as context, and you run: Dockerfile0 same applies to Dockerfile1 build section (you specify there a context and the dockerfile path) hope that made sense.
I'm having some trouble building a docker image, because the way the code has been structured. The code is written in C#, and in a solution there is a lot of projects that "support" the application i want to build. My problem is if i put the dockerfile into the root i can build it, without any problem, and it's okay but i don't think it's the optimal way, because we have some other dockerfiles we also need to build and if i put them all into the root folder i think it will end up messy. So if i put the dockerfile into the folder with the application, how do i navigate into the root folder to grab the folders i need? I tried with "../" but from my point of view it didn't seem to work. Is there any way to do it, or what is best practice in this scenario?
How to navigate up one folder in a dockerfile
Objectrefers to permissions to access the object (file) itself, such as downloading the object.Object ACLrefers to permissions to access/change the Access Control List of the object. That is, the permissions associated with the object.
I added a file into AWS S3 bucket. The access of the bucket is set to public. In the permissions, I setobjectandobject ACLtoreadfor everyone.But I am not clear about the difference betweenObjectandObject ACL, could you please explain their differences?Thanks
what is the difference between Object and Object ACL in AWS S3?
Yes. It does have a limit, if you look at thesource code(alsohere) you see that it's defined as anint32in Golang.Then, if you look at theint32docs for the builtin-types you see that it's range is-2147483648through2147483647. In theory, you can specify--maxon the helm command line as a positive number so2147483647would be your limit. (Surprisingly, I don't see where the absolute value for the int32 gets generated)ThereleaseInfostructure has a memory footprint, so if you have a lot of releases you will run into a limit depending on how much memory you have on your system.
The commandhelm historyprints a list of the past revisions for a release. Is there a limit to the size of this history? i.e. a numbernsuch that if there aren + 1revisions then the first revision is no longer available? I'm aware of themaxflag for thehelm historycommand which limits the length of the list returned, so this question could be equivalently asked as: does themaxflag have a limit for its value?This is in the context of wanting to do ahelm rollback- that command requires a revision and I want to confirm that there will never be a problem with Helm forgetting old revisions.Thanks
Does Helm have a limit to the size of its history?
This function will list the users, just use the aws key and secret, user pool region and id and call the function getUsers(). You can use filters in params to do a more specific request.https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#listUsers-propertyvar AWS = require('aws-sdk'); exports.getUsers= () => { var params = { UserPoolId: USER_POOL_ID AttributesToGet: [ 'ATTRIBUTE_NAME', ], }; return new Promise((resolve, reject) => { AWS.config.update({ region: USER_POOL_REGION, 'accessKeyId': AWS_ACCESS_KEY_ID, 'secretAccessKey': AWS_SECRET_KEY }); var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider(); cognitoidentityserviceprovider.listUsers(params, (err, data) => { if (err) { console.log(err); reject(err) } else { console.log("data", data); resolve(data) } }) });}
I'm developing a web application using Angular 4 (with TypeScript language) front-end side, and using AWS services back-end size. This application can be only accessed by a group of users (each has its own mail and password). This group of users is defined in AWS Cognito - User Pool. How can I have the entire list of these users with their properties to see her in the frontend? And how do I change their properties only frontend side?I saw the JavaScript methods for AWS Cognito (https://github.com/aws/amazon-cognito-identity-js), but I didn't find anything for what I want to do.I would like to use some method to show the full list of users with their properties (as seen in the AWS mangement console of Cognito) and that always, thanks to another method, my application it's able to edit some information as a "group" of a user.Can anyone tell me if this is possible?
AWS Cognito: Methods to Get a List of users?
For htaccessRewriteEngine on RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^www.example.com$ RewriteCond %{REQUEST_URI} !project/public/ RewriteRule (.*) /project/public/$1 [L]Put it into your public_html/ or www/ folder where is the root of example.com/ShareFollowansweredApr 23, 2015 at 16:44Germanaz0Germanaz091488 silver badges1818 bronze badges21Somehow this doesn't work with localhost as URL. (The 3rd line is the issue I believe, not sure why)–BenDec 14, 2015 at 22:12As @BenFransen said above this didn't work for me in localhost. Just changed to the dev linux machine hostname and it's working fine now.–cdsaenzOct 11, 2020 at 3:06Add a comment|
I have this structure:My domain: www.example.comand this is my laravel's project folder:http://www.example.com/projectand I would like to redirect tohttp://www.example.com/project/publicI know this answer has been answered before but I try to implement it and not work for me.Sorry for my english, I just speak spanish
How to redirect to public folder on laravel
+50From the comments it appears the docker service was not configured to automatically start on boot. Docker is a client server app, and the server runs from systemd with a separate service for the docker socket used by the client to talk to the server. Therefore it's possible for any call with the docker command to cause the server to get launched by hitting the docker socket.The service state in systemd can be checked with:systemctl status dockeror you may want to check:systemctl is-enabled dockerIt can be manually started with:systemctl start dockerAnd it can be enabled to start with:systemctl enable dockerAll of the above commands need to be run as root.
I have some containers which all of them have the always restart value in the docker-compose file like this:version: "3.7" services: container: image: ghost:latest container_name: some_container restart: always depends_on: - ... ports: - ... ...As soon as the OS (Flatcar Linux / CoreOS) has updated itself none of the containers restart. But if I just do$ sudo docker psall of the containers starts at once. Whats up with that and how do I fix it so my containers automatically restarts after an update?EDIT:Not sure what is unclear about my question,restart: alwaysis turned on. Unless I'm missing some vital thing in the documentation, this command should restart the container even if the docker daemon is restarted (after an os reboot).Copy of one my comments from below:Ok, so help me out here. As you can see in my question, I have restart: always turned on. All these containers are started successfully and are running well. Then the OS updates itself automatically and restarts itself. After this restart the docker daemon is restarted. But for some reasons the containers I had running WITHRESTART: ALWAYSturned on DOES NOT START. If I enter my server at this moment, typesudo docker psto list my running containers, suddenly all containers are booted up and I see the list. So why wasn't the containers started, even though the daemon is running?
Can a docker container 'go to sleep'? [duplicate]
0 You can try this way. git clone https://github.com/zeromq/php-zmq or download zip archive from repo RUN apt-get install -y libzmq5 libzmq5-dev gcc unzip && \ unzip php-zmq-master.zip && cd php-zmq-master && phpize && ./configure && \ make && make install && docker-php-ext-enable zmq Share Improve this answer Follow answered Dec 27, 2023 at 16:48 user9550639user9550639 1 Add a comment  | 
What is wrong with this Dockerfile? FROM php:8.1-apache RUN apt-get update && apt-get install -y libzmq5 # Install the ZeroMQ extension RUN pecl install zmq-beta # Enable the ZeroMQ extension RUN docker-php-ext-enable zmq It seems that I cannot install php-zmq extension in PHP 8.1. Any tips on how can I proceed with the installation?
Installing php-zmq extension on PHP 8.1 in a docker container
As pointed out by Rickard von Essen the answer was to copy my script to /var/lib/cloud/scripts/per-instance which would execute my script on every instance launched from this AMI. Alternately you can put your script in /var/lib/cloud/scripts/per-boot if you needed this to happen each time the instance boots. In my case since I wanted to register the instance with a 3rd party service I only had it execute once per instance creation.
So I'm trying to use Packer to create an AWS image and specify some user data via user_data_file. The contents of this file needs to be run when the instance boots as it will be unique each time. I can't bake this into the AMI. Using packer I have the following: { "variables": { "ami_name": "" }, "builders": [ { "type": "amazon-ebs", "region": "us-east-1", "source_ami": "ami-c8580bdf", "instance_type": "t2.micro", "ssh_username": "ubuntu", "ami_name": "{{ user `ami_name` }}-{{ isotime | clean_ami_name }}", "user_data_file": "user_data.sh", "tags": { "os_version": "ubuntu", "built_by": "packer", "build_on": "{{ isotime | clean_ami_name }}", "Name": "{{ user `ami_name` }}" } }], "provisioners": [ { "type": "ansible", "playbook_file": "playbook.yml", "user": "ubuntu" }] } The contents of my user_data shell script are just a few basic config lines for a package that was installed via the ansible scripts that were run in the provisioners step. Watching the output of Packer I can confirm that the ansible scripts all run. Packer completes and creates the AMI, but the user data piece is never executed. No record of it exists in resulting image. There is no /userdata.log file and /var/lib/cloud/instance/user-data.txt is empty I feel like I missing something basic as this should be a very simple thing to do with Packer.
AWS user_data with Packer
Had the same issue trying to forward GUI from Ubuntu Server to my Mac.On Ubuntu, installing the swrast driver for OpenGL rendering solved the issue -sudo apt-get install -y mesa-utils libgl1-mesa-glx
I'm running a GUI application in a container in privileged mode on a MAX OS X host. I'be been successfully able to start the GUI in the container using this link:http://kartoza.com/en/blog/how-to-run-a-linux-gui-application-on-osx-using-docker/Now within my GUI application, I'm trying to pop up another window and I get the following: Using Volk machine: avx_64_mmx_orc libGL error: failed to load driver: swrastHow do I go about solving this?
libGL error: failed to load driver: swrast - Running Ubuntu Docker container on Mac OS X host
Unfortunately, I don't think you can. Here is what AWS says in theirdocs-To be able to undelete a deleted object,you must have had versioning enabledon the bucket that contains the object before the object was deleted.
Unfortunately, this morning I accidentally deleted a number of images from my S3 account, and I need to restore them. I have read about versioning, however this was not enabled on the bucket at the time of deletion (I have now enabled).Is there any way of restoring these files either manually, or via Amazon directly?Thanks, Pete
Restoring Amazon S3 files that are not versioned
You need to run the sail up command from inside your WSL2 Ubuntu Image not directly from your terminal. Once you do that it should work okShareFollowansweredFeb 28, 2021 at 23:53MikeBrandlMikeBrandl11611 silver badge33 bronze badges9do i have to cd to the laravel project or just anywhere ? also i saw some ppl say that i have to move my project to the image,to directory same as this as example–Ahmed Wagih RefaeyMar 1, 2021 at 0:06\\wsl$\Ubuntu-20.04\home\wagih\mzaedh–Ahmed Wagih RefaeyMar 1, 2021 at 0:062You have tocd /mnt/c/path/to/laravel@AhmedWagihRefaey–0xLogNMar 1, 2021 at 1:28thanks, it worked, no one mentioned it at the tutorials, although it needed some permissions to run the command but right now after the container downloaded and stuff,i cant run the project–Ahmed Wagih RefaeyMar 1, 2021 at 2:31[Mon Mar 1 02:25:38 2021] PHP 8.0.2 Development Server (0.0.0.0:80) started this is at the ubuntu image terminal but once i run that at the browser it gives nothing–Ahmed Wagih RefaeyMar 1, 2021 at 2:33|Show4more comments
I installed docker and downloaded an ubuntu distro to run with laravel sail,planing to use swoole php,and made it default,also made wsl version to 2with docker-compose.yml ready from laravel sail docker-compose.yml:but every time I try to run the sail up cmd,it gives me this error " Unsupported operating system [MINGW64_NT-10.0]. Laravel Sail supports macOS, Linux, and Windows (WSL2)."any ideas how to fix this ?
Unsupported operating system with Docker on windows 10 with wsl2
So you're doing this downloading in a view controller (as evidenced by you putting it in a "viewDidLoad" method). What is likely happening is that when you move to another view, or when the view controller is deallocated from memory, is that the "manager" object that you are using in that dispatch_queue is also being released when the view controller is leaving memory as well. That's why the download stops. To prove that I am right, leave the view on screen that is doing all this GCD work. I bet you'll get all your images, not just 30 or 40. What you need to do is move this code to somewhere where it can live until it's done downloading (perhaps not a view controller, which is only on the screen for as long as the user wants to see it)?
i have to download large number of web images in my app. now i am trying to download images in my initial class using Grand Central Dispatch. code: - (void)viewDidLoad { [super viewDidLoad]; dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul); dispatch_async(queue, ^{ // Perform non main thread operation for (NSString *imageURL in tempoaryArr1) { NSURL *url = [NSURL URLWithString:imageURL]; SDWebImageManager *manager = [SDWebImageManager sharedManager]; [manager downloadWithURL:url delegate:self options:0 success:^(UIImage *image, BOOL cached) { } failure:nil]; } dispatch_sync(dispatch_get_main_queue(), ^{ // perform main thread operation }); }); } But the above code only download 30 to 40 images at the first launch of app after that it stop downloading images in cache until i stop the app and run it again then the second time it download the some more images in cache and after that stop downloading so on. So my question is why it stop after downloading some images,i want that it keeps downloading images in cache until it download all the images.
How to download web images in Cache before displaying using SDWebimage?
<div class="s-prose js-post-body" itemprop="text"> <p><strong>Unix</strong></p> <p>To delete all containers including its volumes use,</p> <pre><code>docker rm -vf $(docker ps -aq) </code></pre> <p>To delete all the images,</p> <pre><code>docker rmi -f $(docker images -aq) </code></pre> <p>Remember, you should remove all the containers before removing all the images from which those containers were created.</p> <p><strong>Windows - Powershell</strong></p> <pre><code>docker images -a -q | % { docker image rm $_ -f } </code></pre> <p><strong>Windows - cmd.exe</strong></p> <pre><code>for /F %i in ('docker images -a -q') do docker rmi -f %i </code></pre> </div>
<div class="s-prose js-post-body" itemprop="text"> <p>I recently started using Docker and never realized that I should use <code>docker-compose down</code> instead of <code>ctrl-c</code> or <code>docker-compose stop</code> to get rid of my experiments. I now have a large number of unneeded docker images locally. </p> <p>Is there a flag I can run to delete all the local docker images &amp; containers?</p> <p>Something like <code>docker rmi --all --force</code> --all flag does not exist but I am looking for something with similar idea. </p> </div>
How can I delete all local Docker images?
3 If you want to force Python to run out of memory, this should make it happen very quickly regardless of how much memory is available: x = [None] while True: x += x This will double the length of x on every iteration until it fails. Share Improve this answer Follow answered Jan 11, 2021 at 15:08 Tom KarzesTom Karzes 23.3k33 gold badges2424 silver badges4242 bronze badges Add a comment  | 
I'm working on a system that has about 128KB of RAM, one of my scripts occasionally causes a ERRNO 12 Cannot Allocate Memory error. I have a few solutions I want to test. But how can I replicate the problem when it seemingly happens randomly once a day? Any bad scripts that will cause ERRNO 12 Cannot Allocate Memory error? Most posts are trying to solve Memory errors, I want to cause one to test the robustness of my code.
How can I cause a Memory Error in python 2.7?
If your site is stored in your user'sSitesfolder (i.e./Users/username/Sites/) then you also need to setAllowOveridein the user-specific configuration file in/etc/apache2/users/username.conf. After making the change restart apache by disabling and re-enabling Web Sharing in the Sharing preference pane.
I'm working on a mac running OS X Lion and PHP 5.3.6 and have tried bothAddType,AddHander, andAllowOverridehas been set toALLin the httpd.conf; however, the PHP codes in HTML/JS/CSS files are still parsed as text. Files ending with .php are all good. I'm now getting really desperate after hours of googling.Here are the contents of my.htaccessfile:AddType application/x-httpd-php5 .html .js .css AddType application/x-httpd-php .html .js .css AddHandler application/x-httpd-php5 .html .js .css AddHandler application/x-httpd-php.html .js .css
AddType / AddHandler Not Working
You'll need to usegit filter-branchto modify your whole history, removing thewp-config.phpfile from the repository. See thegithub helpfor an example.ShareFollowansweredJan 29, 2013 at 9:15Michael WildMichael Wild25.4k33 gold badges4343 silver badges4444 bronze badgesAdd a comment|
my wordpress website is on my laptop with a lot of older versions in it using Git.Until today, I've had my own Git server but now I would like to push the repository into Github. So I have edit the.gitignorefile to ignore thewp-config.phpand avoid having my database passwords opened to everyone, but when I push my repository I can see on github the older versions of this file.Is there any way to completely ignore any version of this file when I push to github?
public passwords in github
this section here might help you out:http://developer.android.com/training/displaying-bitmaps/manage-memory.html
I have an application with one activity one fragment class and five viewgroups. To start with I pass the first viewgroup to my fragment class and when a certain area in the viewgroup is touched a call is sent up to the activity to notify it that the next viewgroup should be loaded. I call getFragmentSupportManager().beginTransaction() then replace the old fragment with the next one using fragmentTransaction.replace(R.id.primaryContainerView, currentFragment, "Title"); Some of my viewgroups have up to 20 images associated with them and the background for each is being set using imageView.setImageResource(mContext, R.drawable.myImage); The first time I run my app everything works great but sometimes on subsequent runs it throws an outofmemory exception. Some of the ImageViews use pictures up to 1733x1017 because they're background images and several of the Viewgroups have their backgrounds replaced before sending a call to 5 he main activity to load the next viewgroup. How can I make sure my images are recycled properly so I don't get the outofmemory?
outofmemory error with setimageresource for ImageView
You seem to have something wrong with your github repository layout. The files that you want to add to your repository must be within the repository source tree.The way I understand it, your git repo is in~/todoand you want to add files from~/public_html/todo, but this is not how git works. Copy your files into~/todo(cp -r ~/public_html/todo/* ~/todo/) and try again.
I made a GitHub repository for my PHP project. All files are located in/home/nikola/public_html/todo/. However, I don't know how to add it. First time I made it by typing this:git add ~/public_html/todoThis time, it just doesn't work. When I try to do:git add ~/public_html/todoand type git status it says that one file is not yet commited (todo) but that's directory with files and directories in it! I can't find solution. I have cloned repository normal in/home/nikola/todoand tried to do this.
How to add folder from public_html to GitHub repository?
I'd need more info to fully understand the current situation, such as the current size of the repo, how many times you've pushed, how many other colloborators are working in the same repo, but here are several possible courses of action: If you don't have any collaborators (you are the only user), it's quite possible that you have a full copy of the repo locally. Are all the files intact locally? Wait until next month, when you get another 1 Gb+ of free bandwidth, download the repo first thing, then change your settings. It may be possible to download the latest commit as a zip file directly on the Github website if only command line access has been limited, not sure if this option is available with LFS. Pay to get it unlocked Check the options to see if Git-LFS can be disabled remotely (I don't think this is possible) Once you can get the full repo cloned locally, you can turn off Git-LFS, make a commit, and either push back up to the current repo, or push up to a new repo (either at Github or a different hosting site). I'm not 100% sure if disabling Git-LFS in the config locally will also disable it fully on Github for the remote repo.
H! I installed LFS in my github repository to track my *.csv files but when someone else tried to upload other csv and I wanted to make the pull of my repository this was the result This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access. My question is How can I recover the access to my repository, it doesn´t matter if I can not use anymore LFS I will move my csv files to other place, I just want to recover the access to my github repository and being able to push and pull.
This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access
You can use the--querylogic to filter the list objects locally to only those that are zero-byte big:aws s3api list-objects-v2 --bucket example-bucket --query 'Contents[?Size==`0`]'Or, if you just want to see the list of keys without other meta-data, you can further filter the list:aws s3api list-objects-v2 --bucket example-bucket --query 'Contents[?Size==`0`].Key'(For both of these, replace the outer'with"when running on Windows.)Further, if the goal is the remove these objects, you can use jq and a subshell to construct a query that deletes the targeted objects:aws s3api delete-objects --bucket example-bucket --delete \ "$(aws s3api list-objects-v2 --bucket example-bucket --query 'Contents[?Size==`0`].Key' |\ jq '{"Objects": map({"Key":.})}')"There isn't a direct way to do this same sort of construct with Windows's command interpreter.
at the moment there's some files being uploaded where they are getting corrupted. They'll have a filesize of 0 bytes. May I ask how do I query my s3 bucket and filter by specific size, i'm trying to query when byte is 0?At the moment I have two queries.First one list all the files recursively in the bucket but no sorting.aws s3 ls s3://testbucketname --recursive --summarize --human-readableSecond one sorts but only when provided a prefix, in my case the prefix is the folder name. My current bucket structure is as followed{accountId}/{filename}aws s3api list-objects-v2 --max-items 10 --bucket testbucketname --prefix "30265" --query "sort_by(Contents,&Size)"30265 is the accountId/folder name. When the prefix isn't provided, the sort doesn't quite work.Any help would be greatly appreciated.This query works well for filtering the name which is a stringaws s3api list-objects --bucket testbucketname --query "Contents[?contains(Key, '.jpg')]"Unfortunately I couldn't use contains for Size and there isn't a equals.
How to get query s3 bucket by specific file size
The solution is ImageMagick, which will cache sections of extremely large images to disk to keep from running out of memory. A command prompt tool and a Python wrapper for the tool exist.
We have a laser writer in our lab that takes in black and white .bmp images and use those to determine what spots on a plane will be illuminated by a laser. Each pixel is a fixed unit of area, and in order for the total write to be the size we need, we need a .bmp that's about 50,000x50,000 pixels.We need to generate those .bmp files from .svg files. I have python code that can do that for relatively small imagesfrom svglib.svglib import svg2rlg from reportlab.graphics import renderPM drawing = svg2rlg(outfile + '.svg') renderPM.drawToFile(drawing, outfile + '.bmp', fmt='BMP')but when trying to create one of our needed large images, Python runs out of memory and crashes on a 32GB memory computer. Are there any libraries that are designed to be extremely memory efficient for such tasks? Or are there significant optimizations available with the current libraries?
Convert .svg to extremely large .bmp in Python
If I understand you correctly this is what you're looking for?http://wiki.nginx.org/XSendfileShareFollowansweredApr 23, 2013 at 23:11C.NC.N22811 silver badge1010 bronze badges13Please add more information, or a breve summary of what is on the link, link only answers are generally frowned upon–jsedanoApr 23, 2013 at 23:31Add a comment|
At the moment I try to build a site with public and private area. I use Node.js server-side. Node.js mainly provides data via REST Web Services for the front-end and handle the login. All data will be stored in a MongoDB. The front-end is built with AngularJS. At the moment I use nginx for static files and only REST calls (/api/…) and the login (/login) will be pass to node.js.This is my current file structure:www |-- public | |-- css | |-- img | |-- js | | +-- templates | | +-- login.html | | | +-- index.html | |-- private | |-- css | |-- img | |-- js | | +-- templates | | +-- someprivatestuff.html | | | +-- index.htmlIn Node.js I use passport for authentication.app.post('/login', passport.authenticate('local'), function(req, res) { res.redirect('http://localhost/private'); });If the user authed successfully, he will be redirected to /private. The problem is that the file structure above, will be served by the nginx. Because they are static files. How can I prevent people from accessing the private-area directly by typing the url /private (or other files in that directory). Should I use node.js also for the static files to handle the access to the files? But I read to use nginx in front of Node.js is a common approach.
How to implement a login with Node.js (behind nginx) and AngularJS
alpine images doesn't have bash installed out of box. You need to install it separately. RUN apk update && apk add bash How to use bash with an Alpine based docker image?
I am trying to build a docker image for a nodejs web backend which currently looks like this: FROM node:10-alpine WORKDIR /usr/src/smart-brain-api COPY ./ ./ RUN npm install CMD ["/bin/bash"] When I do docker run -it after building an image, I get this weird error internal/modules/cjs/loader.js:638 throw err; ^ Error: Cannot find module '/bin/bash' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3) however if I edit the docker file and change CMD ["/bin/bash"] to CMD ["/bin/sh"] everything works I am working on a macbook air 13, I don't know if that could be a factor.
Docker cannot find module /bin/bash
The inability to use wildcards for the Authorized Origin URIs is a bug that we are fixing, the fix should go out soon. If you need to work around this issue ASAP you can use one of our SDKs (like the Stormpath Node SDK) to programmatically add URLs the the application.
I created app with react and express (client-side rendering). I usereact-stormpath. When I addedhttps://my-app-name.herokuapp.comintoAuthorized Origin URIsin Stormpath Admin it works ok. But when I created pipeline with review apps, it created new subdomain with every request e.g.https://my-app-name-pr-1.herokuapp.comand there is problem with CORS, because this new url is not in Authorized Origin URIs. And I can't use wildcards like:https://*.herokuapp.com.Some hints how to manage it? Because I really don't want to add new Authorized Origin on every pull request.Really thanks!
Heroku pipelines with react stormpath
0 You can use mysqldump utility with --all-databases switch to dump entire databases like below mysqldump -u root -p --all-databases > TotalBackup.sql But above command will dump everything in a single file. Found This blog which has a nice solution to it. A script to do the job of pulling the backup in different files. Take a look. Share Follow answered Apr 13, 2015 at 18:28 RahulRahul 77k1313 gold badges7474 silver badges128128 bronze badges 2 thanks dude, I tried to vote up your response. But it says I need 15 rep points. I think i'm going to try that script. Could I get the version for what I need ? Since my password is shadow'd there - – user2103549 Apr 14, 2015 at 3:14 shadowed as mysqldump -uadmin2 -p$(cat /etc/psa/psa.my/.psa.myshadow) Not sure how to correctly add that to script. I thank u for this. – user2103549 Apr 14, 2015 at 3:16 Add a comment  | 
This question already has answers here: Run MySQLDump without Locking Tables (14 answers) Closed 8 years ago. I'm having significant server issues at the moment, and am worried the server will go at any moment. I need to backup my SQL databases immediately. Could I please get a command just to dump all my databases (different domains) into their own sql backup files? I'd like to work with this cron syntax, since it already works fine for backing up individual SQL files. mysqldump -uadmin2 -p$(cat /etc/psa/psa.my/.psa.myshadow) MyActualDB > /var/www2/backup/mybackup1.sql The above syntax is just for one SQL file. But I need to add: all-databases syntax in there somewhere. Also, for each backup, to backup to their own SQL file (preferably using their already established database name).
How to back up MySQL databases to SQL files? [duplicate]
From the docker hostUse thedocker inspectcommand:docker inspect --format='{{.HostConfig.Privileged}}' <container id>And within a bash script you could have a test:if [[ $(docker inspect --format='{{.HostConfig.Privileged}}' <container id>) == "false" ]]; then echo not privileged else echo privileged fiFrom inside the container itselfYou have to try to run a command that requires the--privilegedflag and see if it failsFor instanceip link add dummy0 type dummyis a command which requires the--privilegedflag to be successful:$ docker run --rm -it ubuntu ip link add dummy0 type dummy RTNETLINK answers: Operation not permittedwhile$ docker run --rm -it --privileged ubuntu ip link add dummy0 type dummyruns fine.In a bash script you could do something similar to this:ip link add dummy0 type dummy >/dev/null if [[ $? -eq 0 ]]; then PRIVILEGED=true # clean the dummy0 link ip link delete dummy0 >/dev/null else PRIVILEGED=false fi
Would like to know via bash script, if current running container was started in--privilegedmode frominsidethe container (not from the host machine).For now I'm stuck with passing an env var with the flag but is not an ideal solution.
How to know if a docker container is running in privileged mode
All you need to need to do is solving the conflict you see mentioned at the end of your pull --rebase. See "HOW CONFLICTS ARE PRESENTED": you will have to open those files, and remove the conflict markers. For the .tern-port file, you need to decide if you want to keep your file, and remove it, as it has been removed in the upstream repo. I forgot to configure my .gitignore file. If you realize that because of tracked files that should not be tracked, don't forget to un-track them first, before adding them to your .gitignore git rm --cached -- afile echo afile >> .gitignore git add .gitignore That can be done during your conflict resolution stage. Once that stage is done, add them (git add .), and continue the rebase (git rebase --continue). After that, if the git status is clean, you can push.
I'm trying to push my commit, but couldn't since there is another commit (same-level in the HEAD race :) I know I need to merge those two commits together, not exactly sure how to do it. I already tried git pull --rebase. My GIT-CLI:
git push rejected, merge conflicts, git pull --rebase
You cannot count download times for a specific file.You can count download time for a release artifacthttps://docs.github.com/en/rest/releases/releases#list-releases
Is there a way that I can get the download count of a specific file in a repository (downloaded viaraw.githubusercontent.com)?I'm not meaning the Github Releases download count.
GitHub get download count from specific file
Since you say that at some point in time all tokens need to be freed at the same time, you can go with a memory pool. Write a token allocator that will malloc tokens and store the allocated pointer in some array, linked list or however you want to solve it. When you're done with all the processing, call a function that will free all the tokens at the same time. Something like this (not tested, but you should get the idea): struct token { struct token *token_next; enum token_type type; size_t length; char *text; }; struct token_pool { struct token *token_list; }; struct token * token_alloc(struct token_pool *pool, size_t len, enum token_type type) { struct token *t; if ((t = malloc(sizeof(*t) + len)) == NULL) return NULL; t->length = len; t->text = (char *)(t + 1); t->type = type; t->token_next = pool->token_list; pool->token_list = t; return t; } void token_free_pool(struct token_pool *pool) { struct token *t; while ((t = pool->token_list) != NULL) { pool->token_list = t->token_next; free(t); } } The advanced level here is to allocate the memory in larger slabs so that you don't need to call malloc that many times, but since you're going with dynamic sizes it's probably just overkill. This is something that's used by apache with their apr_pool API. Many of the things that are allocated in apache have a very specific life time (per-server or per-call) so it's quite easy and efficient to avoid leaks and optimize allocations and freeing.
I am writing a program that tokenizes a text and transforms it based on the tokenization. The tokens are represented by a struct: struct token { enum token_type type; size_t length; /* as returned by strlen(token.text); */ char text[]; /* 0-terminated */ }; The tokenizer provides an iterator interface that allocates and yields the next token when called. The caller of this function then processes the token, passes it to several functions (some of which might store the token on their own) and might store it somewhere. At a certain point of time, token processing is finished and all tokens can be freed. How should I go on about tracing the tokens' allocations? I had three ideas for this: Each token contains a pointer to the previous token; at the end, I can simply traverse the linked list to free all tokens. This gets complicated once I create tokens in more than one place. Each token contains a reference counter. This is complicated because I need to pay close attention to where I keep a reference to a token. Each function duplicates tokens instead of keeping references to them. If a function gets passed a token as an argument, it must not keep them. This might lead to a lot of unneccessary memory allocation. It would be nice to have some information from more experienced programmers.
How to manage the allocation of many small objects being passed around?
4 Starting with SqlServer 2005 onwards(and therefore applicable to sqlserver 2008R2 ) , Sql Cache Dependency works by using the query change notification mechanism.They use a notification infrastructure and messaging system that’s built into the database, called the Service Broker. Sql server 2000 and earlier versions employed the polling mechanism. you may be interested in further reading as suggested below:: Jess Liberty, author of Book: programming in asp.net (Oreilly Media) Says: There is NO need to configure the database with aspnet_regsql.exe and there is NO need to add <sqlCacheDependency> element in your web.config in case you use sqlserver 2005 or later with Query Notification mechanism. MSDN also says that :: This configuration setting i.e. <sqlCacheDependency> has no effect when you use the sqlCacheDependency element in conjunction with query notifications on SQL Server 2005. This does means that setting the pollTime will have NO effect when using Query Notifications. Share Improve this answer Follow answered Jun 16, 2014 at 7:27 R.CR.C 10.5k22 gold badges3636 silver badges4848 bronze badges 2 Thanks! Is there a special flag or setting which I should set to make sqlCacheDependency work in conjunction with query notifications? – Ramesh Jun 16, 2014 at 7:41 1 Yes, there are some steps to be done for enabling query notifications. check this URL: srikanthtechnologies.com/blog/dotnet/sqlcachedependency.aspx – R.C Jun 16, 2014 at 7:52 Add a comment  | 
My Need is to build a simple configuration framework on top of a Key value table. As this is frequently used and rarely changed, would prefer to cache the table values. One requirement is if the value is changed in DB it should reflect immediately in the App. So, I planned to implement SqlCacheDependency. Doc says The query notification mechanism of SQL Server 2005 detects changes to data that invalidate the results of an SQL query and removes any cached items associated with the SQL query from the System.Web.Caching.Cache From the sample I noticed there is a property in the config called PollTime. Doc says Gets or sets the frequency with which the SqlCacheDependency polls the database table for changes. I am confused here on whether it uses the Query Notification technique or it uses Polling mechanism. My stack is .NET 4.0 and SQL Server 2008 R2.
Does SqlCacheDependency use polling or query notification?
For Amazon Linux use "0/5" instead of "*/5". This expression means every 5th minute from 0 through 59.Next, do not specify relative paths in your crontab. Use only absolute paths.
I ran a cron job as ec2 user, in AWS server.I set the cron command, like this */5 * * * * ec2-user bash ./dailyMailSend.shincrontab -efile.It was set to run after every 5 minutes. But it runs every minute. Don't know why ?
Why does this cron job run every minute?
One possible solution would be to use theGitHub API for Gists, in order to:list gists for one account,for each gist:clone it via the URL provided bygit_pull_url.create an empty giston your target accountpush the local gist repo to the newly create empty gist via the URL provided bygit_push_url.
I have a lot of github gists on one account and I want to move them to my main account. How do I do that? Surely I'm not the first to want to do that.
How to move my gists from one account to another?
I've had this problem - and because there's multiple class loaders around in my projects (axis2, tomcat), it can be pretty hard to figure out where to put the cache.ccf file. I ended up not using a .properties file and configuring it directly - here's how I did it...CompositeCacheManager ccm = CompositeCacheManager.getUnconfiguredInstance(); Properties props = new Properties(); props.put("jcs.default","DC"); props.put("jcs.default.cacheattributes", "org.apache.jcs.engine.CompositeCacheAttributes"); // lots more props.put - this is basically the contents of cache.ccf ccm.configure(props); JCS sessionCache = JCS.getInstance("bbSessionCache");ShareFolloweditedOct 24, 2012 at 11:41razlebe7,14466 gold badges4343 silver badges5757 bronze badgesansweredOct 24, 2012 at 11:21JonJon10111 silver badge33 bronze badges11In jcs 1.3 all the properties prefixed with org.apache.commons.jcs. shoud be replaced with org.apache.jcs.–Cristian FlorescuDec 6, 2014 at 8:48Add a comment|
I'm trying to change path of cache.ccf file about an hour...When I'm callingJCS.getInstance("myRegion");I'm getting this error:Exception in thread "main" java.lang.IllegalStateException: Failed to load properties for name [/cache.ccf]I tried to put cache.ccf into src folder. In this case everything's OK. But I want it to be in./config/directory, not in./src. I tried to change config file name:JCS.setConfigFilename("../config/cache.ccf");But it's not working and I'm getting the same error:Exception in thread "main" java.lang.IllegalStateException: Failed to load properties for name [../config/cache.ccf]It seams that JCS tries to find the file named"../config/cache.ccf"in src directory.Herei found this sentence:The classpath should include the directory where this file is located or the file should be placed at the root of the classpath, since it is discovered automatically.But my applilcation don't work even if cache.ccf file is in the root directory of project.How can I change cache.ccf file's path?
How to change JCS cache.ccf file's path?
Vasanthan, if you have just installed docker and all the docker images will be resolved through docker hub, you can set up the same environment in Artifactory by using the default docker remote repository as below,As you can observe that it is by default v2 and hitting the "https://registry-1.docker.io/" which hits the docker hub. There is no need to use the "https://index.docker.io/v2 " instead use the "https://registry-1.docker.io/". I hope this helps.
Installed Docker version 19.03.12 on ubuntu . using the command docker infoit is showing registry as like belowRegistry:https://index.docker.io/v1Can anyone suggest a method to change the registry to v2 (https://index.docker.io/v2)There is an issue to pull the image from the docker artifactory repository v2
change the registry in the docker https://index.docker.io/v1/ to V2
On Windows, winsock uses closesocket to properly close and cleanup a socket.
I have written a very small function in C, opens a socket, accepts connection and immediately closes them. The problem is, each connections eats some memory without releasing it at anytime to the OS. I ran ab (apache benchmark) with about 300K requests, and the processes memory is continuously growing (at the end few hundred megabytes). I'm aware that a process is not always returning its free memory to the OS. But as soon as it gets over few megabytes, I think it should return the memory or am I wrong? This happens only on Windows. On Linux is my memory usage all the time nearly the processes startup usage. Compiled with GCC 4.8.2. Tested on Windows Server 2008 R2 and Windows 8.1. void http_server_start(void) { int rc; struct sockaddr_in cfg; #ifdef _WIN32 WORD ver; WSADATA data; ver=MAKEWORD(2,2); rc=WSAStartup(ver, &data); if(rc != 0){ printf("Error: Unable to initialize WSA (%d)", rc); } #endif memset(&cfg, 0, sizeof(cfg)); cfg.sin_family = AF_INET; cfg.sin_addr.s_addr = htonl(INADDR_ANY); cfg.sin_port = htons(PORT); server = socket(AF_INET, SOCK_STREAM, 6); int reuseaddr=1; if (setsockopt(server, SOL_SOCKET, SO_REUSEADDR, (char*)&reuseaddr, sizeof(reuseaddr)) == -1){ rc=GetLastErrorEx(); printf("Error: Unable to set SO_REUSEADDR (%d)\n", rc); } else if (bind(server, (struct sockaddr *)&cfg, sizeof(cfg)) < 0 ) { rc=GetLastErrorEx(); printf("Error: Unable to bind socket (%d)\n", rc); close(server); } else if (listen(server, QUEUE_SIZE) < 0) { rc=GetLastErrorEx(); printf("Error: Unable to listen (%d)\n", rc); close(server); } else { printf("Listening on %s:%d\n", inet_ntoa(cfg.sin_addr), ntohs(cfg.sin_port)); int client; struct sockaddr_in addr; int addrlen=sizeof(addr); do { client=accept(server, (struct sockaddr*)&addr, &addrlen); if(client != -1){ shutdown(client, SHUT_RDWR); close(client); } } while(1); } }
Socket accept is consuming my memory on windows without release
There are many factors here which may be impacting performance.RegardingcudaMallocPitch, if it happens to be the first cuda call in your program, it will incur additional overhead.RegardingcudaMemcpy2D, this is accomplished under the hood via a sequence of individual memcpy operations, one per row of your 2D area (i.e. 4800 individual DMA operations). This will necessarily incur additional overhead compared to an ordinarycudaMemcpyoperation (which transfers the entire data area in a single DMA transfer). Furthermore, peak transfer speeds are only achieved when the host side memory buffer is pinned. Finally, you don't indicate anything about your platform. If you are on windows, then WDDM will interfere with full transfer performance for this operation, and we don't know what kind of PCIE link you are on.4800*4800*4/0.050 = 1.84GB/s which is a significant fraction of the ~3GB/s that is roughly available for a non-pinned transfer across PCIE 2.0. The reduction from 3GB to 1.84GB is easily explainable by the other factors I list above.If you want full transfer performance, use pinned memory and don't use a pitched/2D transfer.
As mentioned in title, I found that the function ofcudaMallocPitch()consumes a lot of time andcudaMemcpy2D()consumes quite some time as well.Here is the code I am using:cudaMallocPitch((void **)(&SrcDst), &DeviceStride, Size.width * sizeof(float), Size.height); cudaMemcpy2D(SrcDst, DeviceStride * sizeof(float), ImgF1, StrideF * sizeof(float), Size.width * sizeof(float), Size.height, cudaMemcpyHostToDevice);In implementation, theSize.widthandSize.heightare both 4800. The time consuming forcudaMallocPitch()is about 150-160ms (multiple tests in case accidents) andcudaMemcpy2D()consumes about 50ms.It seems not possible that the memory bandwidth between the CPU and GPU is so limited, but I cannot see any errors in code, so what is the reason?By the way, the hardware I am using are Intel I7-4770K CPU and Nvidia Geforce GTX 780(quite good hardware without error).
In CUDA, why cudaMemcpy2D and cudaMallocPitch consume a lot of time
Both trust stores and key store are KeyStore objects. Just the usage is different. So, the example that you found should work for either a key store or a trust store, since they are objects of the same type.
My server program uses the trust store for client certs which works fine for the two way handshake, however I would like to be able to get the certs from the trust store for other things. I noticedthis examplefor Key stores. How do I do about it for trust stores?I setup the trust store in following way for my SSL two way handshake, but I want to use the certs for something else.System.setProperty("javax.net.ssl.trustStore", "store.jts"); System.setProperty("javax.net.ssl.trustStorePassword", "PASS);
How can I access java trust store certs
Thanks kapep, good advice. Wasn't sure how to phrase as a question - but answering my own question I can do! First of all to ensure an image IS cacheable you must inspect the Response Headers to ensure the following headers are set to valid values: 'Cache-Control' is set to private or public. 'Expires' is a date in the correct format that is in the future. (eg. Thu, 21 Jun 2012 06:20:49 GMT) 'Last-Modified' is not more recent than the 'Date' header. 'Content-Disposition' is not set to "attachment;" If you're convinced the headers are set correctly and it still seems like the images aren't arriving from the cache, ensure the following: You are NOT F5 refreshing the page to check for caching as firefox will fetch new copies of the images if you refresh. Ensure you are reloading your page by navigating to another page and re-visiting the same page (as would be normal behaviour by one of your users). In your about:config (just type this in your address bar to access hidden settings) browser.cache.memory.enable = true and browser.cache.disk.enable = true
Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 10 years ago. Improve this question EDIT: Answer provided below. I've struggled for a couple of days to understand why Mozilla Firefox continually failed to retrieve images from its' cache as opposed to fetching new copies everytime I reloaded a page. Google Chrome didn't appear to have this issue, but that's because refreshing the page in Chrome does NOT force it to reload images (unless a CTRL-F5 is used). Below I've answered my own question and added some extra info that I hope will save someone else some time in getting their head around this issue.
Why does firefox not appear to be caching images? [closed]
BUCKET_NAME = 'enter your bucket name' KEY = 'enter full path where to store the image' df = pd.read_csv('./gene_expression.csv') df.hist(by='Cancer Present', figsize=[12, 8], bins=15) img_data = io.BytesIO() plt.savefig(img_data, format='png') img_data.seek(0) s3 = boto3.resource('s3') bucket = s3.Bucket(BUCKET_NAME) bucket.put_object(Body=img_data, ContentType='image/png', Key=KEY)ShareFollowansweredFeb 8, 2023 at 9:48sahildabhi0101sahildabhi010111As it’s currently written, your answer is unclear. Pleaseeditto add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answersin the help center.–CommunityBotFeb 11, 2023 at 2:31Add a comment|
Can you save a graph to s3 without saving the file locally first?from boto.s3.connection import S3Connection from boto.s3.key import Key k = Key(bucket) k.key = "mykey" plt.savefig(k.key) //??
Save Matplotlib image to s3 without saving locally using Boto
I'm not great at preg expressions, but what you're looking for is something like thisRewriteCond %{REQUEST_URI} .*\.domain\.com/.*/.*$ [NC] RewriteRule ^(.*)\..*/(.*)/(.*)$ master5.php?uid=$1&wid=$2&camid=$3 RewriteCond %{REQUEST_URI} .*\.domain\.com/.*/$ [NC] RewriteRule ^(.*)\..*/(.*)/$ master5.php?uid=$1&wid=$2The conidition determines whether the rule should run, and the rule says how to translate the URL provided into the actual URL you wish to execute. You may wish to try and refine the preg into precisely what you want using something likehttp://regextester.com/to fine tune it.Edit: Note, you must have setup your DNS entry for *.domain.com rather than for www.domain.com otherwise no subdomains will be passed through to your server anyway.
I need to convert the following where website url that user inputs ,var1 is a wildcard set by user to login to his account details.http://var1.domain.com/var2/var3redirect to:http://domain.com/master5.php?uid=var1&wid=var2&camid=var3and another rule i need isvar1.domain.com/var2/redirect to:domain.com/master5.php?uid=var1&wid=var2if possible I need to cloak them too so user actually only seevar1.domain.com/var2/var3
Help On Programming .htaccess to redirect to controller
Finally, I finished my task and I want to share some useful things. Instead of generate_series I used this hook: WITH date_range AS ( SELECT trunc(current_date - (row_number() OVER ())) AS date FROM any_table -- any of your table which has enough data LIMIT 365 ) SELECT * FROM date_range; To get list of URLs which I have to fill with the data I used this: WITH url_list AS ( SELECT url AS gapsed_url, MIN(timestamp_gmt) AS min_date, MAX(timestamp_gmt) AS max_date FROM daily_table WHERE url IN ( SELECT url FROM daily_table GROUP BY url HAVING count(url) < (MAX(timestamp_gmt) - MIN(timestamp_gmt) + 1) ) GROUP BY url ) SELECT * FROM url_list; Then I combinet given data, let's call it url_mapping: SELECT t1.*, t2.gapsed_url FROM date_range AS t1 CROSS JOIN url_list AS t2 WHERE t1.date <= t2.max_date AND t1.date >= t2.min_date; And to get data by closest date I did the following: SELECT sd.* FROM url_mapping AS um JOIN daily_table AS sd ON um.gapsed_url = sd.url AND ( sd.timestamp_gmt = (SELECT max(timestamp_gmt) FROM daily_table WHERE url = sd.url AND timestamp_gmt <= um.date) ) I hope it will help someone.
I'm trying to fill daily data for missing dates and can not find an answer, please help. My daily_table example: url | timestamp_gmt | visitors | hits | other.. -------------------+---------------+----------+-------+------- www.domain.com/1 | 2016-04-12 | 1231 | 23423 | www.domain.com/1 | 2016-04-13 | 1374 | 26482 | www.domain.com/1 | 2016-04-17 | 1262 | 21493 | www.domain.com/2 | 2016-05-09 | 2345 | 35471 | Expected result: I wand to fill this table with data for every domain and every day which just copy data from previous date: url | timestamp_gmt | visitors | hits | other.. -------------------+---------------+----------+-------+------- www.domain.com/1 | 2016-04-12 | 1231 | 23423 | www.domain.com/1 | 2016-04-13 | 1374 | 26482 | www.domain.com/1 | 2016-04-14 | 1374 | 26482 | <-added www.domain.com/1 | 2016-04-15 | 1374 | 26482 | <-added www.domain.com/1 | 2016-04-16 | 1374 | 26482 | <-added www.domain.com/1 | 2016-04-17 | 1262 | 21493 | www.domain.com/2 | 2016-05-09 | 2345 | 35471 | I can move a part of the logic into php, but it is undesirable, because my table has billions of missing dates. SUMMARY: During a few last days I foud out that: Amazon-redshift works with 8-th version of PostgreSql, that's why it does not support such a beautiful command like JOIN LATERAL Redshift also does not support generate_series and CTEs But it supports simple WITH (thank you @systemjack) but WITH RECURSIVE does not
Fill the table with data for missing date (postgresql, redshift)
Sounds like you've exhausted swap space on your box. The java.lang.ProcessBuilder.start() ultimately must boil down to a fork or clone system call on a Unix-like OS to create a new process. That takes swap space. And you seem to not have enough. This is more in the Unix system admin realm, not Java.
Here's what I believe to be the relevant error message: Caused by: java.io.IOException: Cannot run program "/usr/bin/git" (in directory "/var/lib/hudson/jobs/Goals/workspace"): java.io.IOException: error=12, Cannot allocate memory at java.lang.ProcessBuilder.start(ProcessBuilder.java:474) at hudson.Proc$LocalProc.<init>(Proc.java:192) at hudson.Proc$LocalProc.<init>(Proc.java:164) at hudson.Launcher$LocalLauncher.launch(Launcher.java:638) at hudson.Launcher$ProcStarter.start(Launcher.java:273) at hudson.Launcher$ProcStarter.join(Launcher.java:280) at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:319) ... 15 more Caused by: java.io.IOException: java.io.IOException: error=12, Cannot allocate memory at java.lang.UNIXProcess.<init>(UNIXProcess.java:164) at java.lang.ProcessImpl.start(ProcessImpl.java:81) at java.lang.ProcessBuilder.start(ProcessBuilder.java:467) ... 21 more You can also see the full output from Hudson here: http://hudson.pastebin.com/KLSNrY1D Any ideas? How can I stop this from happening? I'm not a Java dev, so I don't know much about what's going on here. I have to restart Hudson entirely to fix the issue, but clearly this is not the best answer.
Why am I getting this java.io.exception "Can't allocate memory" from Hudson?
See my question and answerhere.Basically it depends on your organization and the application. If your company, developers and customers all speak the same native language and you expect it to stay that way, then it would be extremely counter-productive to have everyone become a part-time translator as well. Considerable productivity loss for a purely hypothetical future advantage. YAGNI.If it's a large international company, or if there are concrete plans to expand internationally or have some work done offshore, it's a different matter, of course.
Most programming code, I imagine is written in English. But I'm curious how people are handling the issue of naming herein. A lot of programming is done within some bussiness domain, usually with well established terms for certain procedures, items.I'm from Denmark for instance, and something I work a lot with has a term called "indblikskode", which sort of translates to "insight code". So, do I use the line "string indblikskode = ..." in the C# code for some web service related to this? Or do I try to use a translation, such as "insightcode"? The bussiness I'm in isn't even consistent in its language, for instance using the term "organisatorisk enhed" (organizatorical unit), but just as often using the abbreviation "OU", which is obviously abbreviated from the English.How do other people handle this naming issue, while keeping consistent, and sane (in everything from simple variable names in your code, to database tables, to server names)?Duplicates:Should identifiers and comments be always in English or in the native language of the application and developers?Do you use another language instead of English?
Non-English domain naming issues in programming
You can't really ask a question like this without also specifying a specific python version/implementation. If you're talking about the reference implementation (CPython), you can look at this reference or this one for python3.x. Specifically: It is important to understand that the management of the Python heap is performed by the interpreter itself and that the user has no control over it So it's impossible to answer whether the memory location will still be valid. What we can talk about is whether the object will be collected by the garbage collector. Since CPython relies on reference counting, when you assign a different value to p, the reference count on the original value decreases by one. If that reference count drops to zero, the object will be collected by the garbage collector. That means that the memory location becomes available for some other object or possibly that python will return that memory back to the operating system. As a user, you have no control over which of these actions the python interpreter will take (or when). Basically, the python interpreter takes care of all of the details necessary to prevent memory leaks/memory overflow, etc. As a python programmer, you don't need to worry about these details the same way that you would need to worry about them if you were coding in a lower level language like C.
>>p = 5 >>id(p) 140101523888800 >>p = 5.56 >>id(p) 140100617985840 I know on assigning the new value to an existing variable, it points to the new location in the memory at which the new value is stored. But my question is, will the memory location containing the previous value 5 still exists? If yes, won't it cause memory overflow after a few reassignments?
Will the reassignment delete the previous value from the memory in Python?
To sum only positive values, you do not need to sort your initial values, use thrust::transform_reduce:template<typename T> struct positive_value : public thrust::unary_function<T,T> { __host__ __device__ T operator()(const T &x) const { return x < T(0) ? 0 : x; } }; float result = thrust::transform_reduce(data.begin(), data.end(), positive_value<float>(), 0, thrust::plus<float>());
I'd like to use Thrust (as most of my method is implemented using thrust data types) or C CUDA if necessary to sum only the positive floating point elements of a vector. The data is not initially sorted. My initial stab was very bad: basically, copy off the vector, sort it, find the zero crossing by passing it to a kernel which compares sequential pair-wise values and writes those that match the zero crossing. Basically after sorting (which I do with Thrust)...int i = blockIdx.x * blockDim.x + threadIdx.x; if (i < n - 1) { float a = vector[i]; float b = vector[i + 1]; if (a >= 0.0 && b < 0.0) answer = i + 1; }This is really dumb witted, lots of threads match the conditional, way too many reads, branch divergences, etc. So, it totally fails, each call will give different results on the same data, etc.I have yet to find a good way to implement this in Thrust, which is what I would prefer. After sorting I don't know how to find the zero crossing. Any advice on a jumping off point here? An actually working simple CUDA C implementation would be just fine too.
Sum only positive elements of a vector CUDA/THRUST
There are quite a few approaches. Here are just a few.Number 1.Add thisbeforeyour rules:# do not do anything for js/css/image files # (will affect ALL such files in ALL folders) RewriteRule \.(css|js|jpe?g|gif|png|ico)$ - [L]The rule above will leave protocol as is for ALL css/js/image files (anywhere on a site)Number 2.Add thisbeforeyour rules:# do not do anything to any files in css/js/images folders RewriteRule ^(css|js|images)/ - [L]The rule above will leave protocol as is for ALL files in css/js/image folders (e.g.example.com/js/main.js,example.com/images/logo.pngor evenexample.com/js/compress.phpIf you want-- you can combine them into single rule (to be more specific) -- but that is unnecessary (from my point of view).
I've got the follow problem.I have a website and for the directories /members and /admin I have a .htaccess which forces these URLs to go to https:// All other URLs are forced to go to normal https://Now, for /members which is https:// I have in the pages a reference to /js/script.js which in imported into the page, but ofcourse this directory /js is forced to normal http:// while the page is displayed in https://Internet Explorer users are shown a popup if they want to view non-secure content in the secure page, if they click yes, it's ok. If they click no, then the javascript doesn't work.The /js is used in the normal http:// website and also in the /members secure website. This also is the case for the /images directorySo i'm not sure how to solve this problem. Other than say that /js and /images can be https or http. But I have no clue on how to configure this in the htaccess file.Any help would be much appreciated!This is the htaccess file I use now :#Turn SSL on everything, except members and admin RewriteCond %{HTTPS} =off RewriteCond %{REQUEST_URI} ^(/members|/admin) RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # Turn SSL off everything, except members and admin RewriteCond %{HTTPS} =on RewriteCond %{REQUEST_URI} !^(/members|/admin) RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
https and http combined .htaccess
Picasso is designed to be a singleton, so there's isn't a new instance created every time. This is the with() method : public static Picasso with(Context context) { if (singleton == null) { synchronized (Picasso.class) { if (singleton == null) { singleton = new Builder(context).build(); } } } return singleton; } Note that it is a static method so you don't call with() on a particular instance, Picasso is managing its own instance, which is only created if singleton is null. There's no problem with passing an Activity as the context, because the Builder will use the ApplicationContext which is a single, global Application object of the current process : public Builder(Context context) { if (context == null) { throw new IllegalArgumentException("Context must not be null."); } this.context = context.getApplicationContext(); } As for the cache, the same one is use everytime, since it is retained by the singleton : public Picasso build() { // code removed for clarity if (cache == null) { cache = new LruCache(context); } // code removed for clarity return new Picasso(context, dispatcher, cache, listener, transformer, requestHandlers, stats, defaultBitmapConfig, indicatorsEnabled, loggingEnabled); }
Is it okay to create a new instace of picasso for loading every image.For E.g something like: Picasso.with(context) .load(url) .placeholder(R.drawable.placeholder) .error(R.drawable.error) .centerInside( .tag(context) .into(holder.image); in getView() of a listAdaptor.Does it not create new LruCache everytime which will eventually lead to OOM. Also can the Context passed to Picasso can be an Activity Context: /** Start building a new {@link Picasso} instance. */ public Builder(Context context) { if (context == null) { throw new IllegalArgumentException("Context must not be null."); } this.context = context.getApplicationContext(); }
Is it okay to create new Instance of picasso everytime
13 "Memory address" of an object reference does not make sense since objects can move across Java Heap. You cannot explicitly free space allocated by Unsafe.allocateInstance, because this space belongs to Java Heap, and only Garbage Collector can free it. If you want your own memory management outside Java Heap, you may use Unsafe.allocateMemory / Unsafe.freeMemory methods. They deal with raw memory addresses represented as long. However this memory is not for Java objects. Share Improve this answer Follow answered Jun 26, 2014 at 13:19 apanginapangin 95.4k1111 gold badges199199 silver badges257257 bronze badges Add a comment  | 
Java Unsafe class allows you to allocate memory for an object as follows, but using this method how would you free up the memory allocated when finished, as it does not provide the memory address... Field f = Unsafe.class.getDeclaredField("theUnsafe"); //Internal reference f.setAccessible(true); Unsafe unsafe = (Unsafe) f.get(null); //This creates an instance of player class without any initialization Player p = (Player) unsafe.allocateInstance(Player.class); Is there a way of accessing the memory address from the object reference, maybe the integer returned by the default hashCode implementation will work, so you could do... unsafe.freeMemory(p.hashCode()); doesn't seem right some how...
How to free memory using Java Unsafe, using a Java reference?
I'll try one by one: I. You need to use git filter-branch only if you need to remove the files from your history completely. If those files do not contain any credit card information, then i think the following should be enough: git rm --cached .DS_Store git commit -m "{Your message}" then add this file to .gitignore and commit it. This will commit the removal of the file from the repository but will keep the file in working directory. If you push it though and then somebody else will pull this commit, they might have their file removed, so you MUST communicate this. By committing .gitignore you will prevent other developers from adding this file again. If you're not a maintainer, then i don't think you should do anything, but address this issue to the maintainer. II. I'm a strong believer that hidden files of any nature are most of the time not supposed to be put into the repository exactly for that reason. Therefore i think that you should do the same thing with .xcodeproj as with .DS_Store and put it into .gitignore and commit it. .gitignore is the exception for the rule above. III. If those files are properly ignored , then there will be no issues in future with them. If they are already in the repo and somebody wants do such cleanup it should be done by maintainer and communicated inside the team. Hope that helps!
I can create a repo and use GitHub / BitBucket fine for my own projects. I have had problems when collaborating with other developers or trying to fork a project on GitHub. I am aware of other answers like Best practices for git repositories on open source projects but there are OSX / Xcode specific problems I want to know how to solve. .DS_Store files can be a pain. You can use .gitignore to prevent, but what happens if they have already been included, or another developer adds them back in through a clumsy git command? The .xcodeproj will have changes to the directory names and developer profiles for the other person. What's the best way to do merges or to avoid conflicts? If I have forked or pulled from a github project, how can I clean up these issues and also minimise merge conflicts for the maintainer? If people have an example .gitignore created for Xcode, or scripts they use to initialise their repos then that would be great!
Best practices for Xcode + Git for multi-developer projects
Yes, you should consider usinglabelsto disambiguate metrics (e.g. Counters) by instance.You'll need to determine a unique identifier to use.Kubernetes provides aDownward APIthat enables you to surface information from the Pod to a container. One of these values should be useful.You can then use PromQLignoringto e.g. sum across Counters and ignore one or more labels.With this approach, you get to choose whether to sum by instance or across instances.
I have service A which is a consumer from some queue.I can monitor and count any consumed message, easily with Prometheus :)from prometheus_client import start_http_server, Counter COUNTER_IN_MSGS = Counter('msgs_consumed', 'count consumed messages') start_http_server(8000) while(queue not empty): A.consume(queue) COUNTER_IN_MSGS.inc()But than, one day I decide to duplicate my consumer to 10 consumer which do the same {A1, A2..., A10}, by using the same code but running on 10 different dockers (containers on K8s in my case).How can I monitor them using Prometheus?? Should I change my code and some id to each consumer as label?What is the best practice to do in order to be able to sum them all together but also count on each by its own?
how to monitor multiple instances of docker using Prometheus?
It's part of the infrastructure. This container is started first in all Pods to setup the network for the Pod.It does nothing after the Pod has started.Here is thesource code.
I set up thekubernetescluster, and I found thepause-amd64:3.0container on master or minion like this:[root@k8s-minion1 kubernetes]# docker ps |grep pause c3026adee957 gcr.io/google_containers/pause-amd64:3.0 "/pause" 22 minutes ago Up 22 minutes k8s_POD.d8dbe16c_redis-master-343230949-04glm_default_ce3f60a9-095d-11e7-914b-0a77ecd65f3e_66c108d5 202df18d636e gcr.io/google_containers/pause-amd64:3.0 "/pause" 24 hours ago Up 24 hours k8s_POD.d8dbe16c_kube-proxy-js0z0_kube-system_2866cfc2-0891-11e7-914b-0a77ecd65f3e_c8e1a667 072d3414d33a gcr.io/google_containers/pause-amd64:3.0 "/pause" 24 hours ago Up 24 hours k8s_POD.d8dbe16c_kube-flannel-ds-tsps5_default_2866e3fb-0891-11e7-914b-0a77ecd65f3e_be4b719e [root@k8s-minion1 kubernetes]#so what doesk8suse this for ?
what does kubernetes use the container pause-amd64 for?
Disclaimer: My experience is with git rather than hg, but as I understand it the concepts apply equally to both systems. An advantage of backing up to a remote repo is that if your local repo becomes corrupted (perhaps due to a problem with the underlying filesystem), that corruption does not get transferred over to the backup, unless the files in your working tree themselves are corrupted. For example, it's possible for some of the objects in the repository, perhaps those which are rarely accessed because you don't change them, to become corrupted. It could be months before you use one of those files again, and so months before you notice (though I think doing a garbage collect run, eg git gc, will detect corruption). So if you are backing up by pushing commits, you're creating an independent version of those objects, and using checksums (ie the commit hash) to verify the transfer of any new files. Whereas if you are backing up to a backup provider, you're duplicating the actual objects in the repo, in whatever state they are in, and duplicating any changes to those files, including corruption of them. Usually backup providers will give you rollback (spideroak seems to be particularly good for this) but you'll still have to sift through a lot of versions to figure out when the corruption happened; also with some providers, the rollback period is limited (especially for free accounts).
I'm currently signed up with a third party service that hosts my mercurial repositories as a central hub to push my changes to as a sort of backup. Now, I'm looking at a system to backup my laptop and am concidering Mozy. I'm a loan developer, and work on a laptop and am usualy connected to my internet via wifi with my laptop only really being on when I'm working, so feel something like Mozy is my best option. My question is, if I'm the only developer, could I get away with just using local mercurial repos and using Mozy to backup everything up? Rather than pushing to an external repo? Many thanks Matt
Can I use "Online Backup" to backup my DVS instead of pushing to an external repo?
That worked for meRUN apt-get install -y locales RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ && sed -i -e 's/# pt_BR.UTF-8 UTF-8/pt_BR.UTF-8 UTF-8/' /etc/locale.gen \ && locale-genShareFollowansweredApr 29, 2019 at 14:43Rodrigo CrispimRodrigo Crispim13111 silver badge33 bronze badges2solved it for me aswell, Django container with python:3-7-slim-buster as the base.–elmcrestNov 20, 2019 at 16:35For other people, in my case, I needed to putRUN apt-get updatebefore.–Diego GaonaNov 30, 2022 at 16:00Add a comment|
When I try "docker run -p 8050:8050 app1" in docker I get:Traceback (most recent call last): File "app1.py", line 6, in <module> locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') File "/usr/local/lib/python3.6/locale.py", line 598, in setlocale return _setlocale(category, locale)My dockerfile looks like this:FROM python:3.6 USER root WORKDIR /app ADD . /app RUN apt-get update && apt-get -y install locales RUN locale-gen en_US.UTF-8 ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en ENV LC_ALL en_US.UTF-8 RUN pip install --trusted-host pypi.python.org -r requirements.txt EXPOSE 8050 ENV NAME World CMD ["python", "app1.py"]How can i set a local language in the app1.py without getting this error? thanks in advancePS: Already restarted docker.
Docker "unsupported locale setting" when running Python container
According to the logs it looks as if theTaskManagercannot connect to the new leader. I assume that this is the same for the web ui. The logs say that it tries to connect toflink-job-manager-0.flink-job-svc.flink.svc.cluster.local/10.244.3.166:44013. I cannot say from the logs whetherflink-job-manager-1binds to this IP. But my suspicion is that the headless service might return multiple IPs and Flink picks the wrong/old one. Could you log into theflink-job-manager-1pod and check what its IP address is?I think you should be able to resolve this problem by defining for eachJobManagera dedicated service or if you use the pod hostname instead.
I'm trying to deploy Apache Flink 1.6 on kubernetes. With following the tutorial atjob manager high availabiltypage. I already have a working Zookeeper 3.10 cluster from its logs I can see that it's healthy and doesn't configured to Kerberos or SASL.All ACL rules are let's every client to write and read znodes. When I start the cluster everything works as expected every JobManager and TaskManager pods are successfully getting into Running state and I can see the connected TaskManager instances from the master JobManager's web-ui. But when I delete the master JobManager's pod, the other JobManager pod's cannot elect a leader with following error message on any JobManager-UI in the cluster.{ "errors": [ "Service temporarily unavailable due to an ongoing leader election. Please refresh." ] }Even if I restart this page nothing changes. It stucks at this error message. My suspicion is, the problem is related withhigh-availability.storageDiroption. I already have a working (tested withCloudExplorer)minios3 deployment to my k8s cluster. But flinkcannotwrite anything to the s3 server. Here you can find every config fromgithub-gist.
Flink HA JobManager cluster cannot elect a leader
The thing about locmem is that it really is just a local memory storage. Looking atthe code, it's clear that the data is just being saved in a module-level variable,_caches, in that module. So you can just dofrom django.core.cache.backends import locmem print(locmem._caches)
I was trying to use the locmem cache for my web application but couldn't find any documentation on how to see the contents of the cache. I mean I want to check if my keys are being set correctly in the cache. How can I list all the keys in this cache or is that even possible?I found the questionGet list of Cache Keys in Djangobut it's about memcache, not the locmem cache.
Contents of locmem cache in Django?
No, the string is a complete object, with an object header (containing a type reference, sync block etc), length, and whatever characters are required... which will be a single null character (two bytes) and appropriate padding to round up to 4 or 8 bytes overall. Note that although strings in .NET have a length field, they're still null-terminated for the sake of interop. The null character is not included in the length. Of course, string.Empty will only refer to a single object no matter how many times you use it... but the reference will be 4 or 8 bytes, so if you have: string a = string.Empty; string b = string.Empty; string c = string.Empty; that will be three references (12 or 24 bytes) all referring to the same object (which is probably around 20 or 24 bytes in size).
How much space does string.Empty take in CLR? I'm guessing it's just one byte for the NULL character.
How much space does string.Empty take in CLR
21 Localhost inside each container (like the nginx container) is different from localhost outside on your container. Each container gets its own networking namespace by default. Instead of pointing to localhost, you need to place your containers on the same docker network (not the default bridge network) and use the container or service name with Docker's built in DNS to connect. The target port will also be the container port, not the published port on your host. Share Improve this answer Follow answered Jul 9, 2017 at 11:36 BMitchBMitch 246k4444 gold badges509509 silver badges473473 bronze badges 3 1 Oh,The reason I realized the problem was network .Finally,I change the localhost in "proxy_pass localhost:8080" to "10.2.8.158"(this is IPv4 in my computer).That's it.Thanks. – Z.Qng Jul 10, 2017 at 2:25 3 That will connect you outside of docker and then back in. If you run things in a docker network, they can connect directly, container to container, which is much more portable. – BMitch Jul 10, 2017 at 17:52 I found the solution here. may work for you :-) – dinu0101 Jul 27, 2019 at 19:11 Add a comment  | 
I use nginx in the docker,this is my nginx configure server { listen 80; server_name saber; location / { root /usr/share/nginx; index index.html; } location /saber { proxy_pass http://localhost:8080; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_connect_timeout 90; } } when I use "http://localhost/saber/blog/getBlog.do" in browser ,browser give me a error with "502". and nginx`s error.log have new. 2017/07/09 05:16:18 [warn] 5#5: *1 upstream server temporarily disabled while connecting to upstream, client: 172.17.0.1, server: saber, request: "GET /saber/blog/getBlog.do HTTP/1.1", upstream: "http://127.0.0.1:8080/saber/blog/getBlog.do", host: "localhost" I can promise the "http://127.0.0.1:8080/saber/blog/getBlog.do" have response success in browser. I try search answer in other question,i find a answer is "/usr/sbin/setsebool httpd_can_network_connect true",this is question url "nginx proxy server localhost permission denied",but I use the docker in win10,the nginx container dont hava setsebool,because the container dont find SELinux. This all,Thank you in advance.
docker nginx appear "502".1 upstream server temporarily disabled while connecting to upstream
Your syntax for sending the OAuth Token is wrong. You need to use either this formatcurl -H "Authorization: token xxxxxxxxxxxxxxx"https://api.github.com(or)curlhttps://api.github.com/?access_token=xxxxxxxxxxxxxxxxxReference:https://developer.github.com/v3/#authentication
I'm using authenticated Git API request using access token. But still, I get the request rate limit 60 req/hr. But the document says, for authenticated requests the rate limit is 5000 req/hr. Why I'm getting 60 req/hr. or is there any wrongs in curl comment which I'm using?Eg: curl -H "Content-Type: application/json" -H "authToken: xxxxxxx" -ihttps://api.github.com/repos/d3/d3/git/refs/tags/3.5.3"
Rate limit of authenticated git API request
You're misinterpreting the post. It doesn't say that looping inference increases GPU utilization - it posits looping inference as a test to see if the bottleneck is loading data. It's a test, not a solution.Looping inference loads data once, then runs inference multiple times, allowing you to see the GPU performance without i/o overhead. If GPU performance improves when looping inference, it indicates an i/o bottleneck.
I was looking for a solution for an issue I was having with my interface speed. I saw thisansweronline but I don't understand what the solution was. The person is using a hugging face model with pytorch and the solution was to loop the real inference call to increase the GPU utilization. This was caused by a bottleneck from accessing the data. Can I get some help understanding how to implement this solution? Thanks
understanding looping real inference call
A gray folder on GitHub looks like a submodule. See for instance: "What is this grey git icon?" "What does a grey icon in remote GitHub mean" Try in the parent module a git rm --cached sub-directory (no trailing slash). Check if you have a .gitmodules file at the root of your main repo, with that same sub-directory in it. See more at "Cannot remove submodule from Git repo" cd /path/to/parent/respository git rm --cached submodule-name # no trailing slash: not submodule-name/ git commit -m "Remove submodule entry" git push Note the --cached option here: we don't want to remove the sub-folder, only the special entry in the index which marks it as a submodule.
I have just realised I ran a 'git init' command from a sub-directory by mistake and then created a master repo at the root of my project. This was a mistake, so I ran the 'rm -fr' command (delete) on the nested directory '.git' not in the root of the project - thinking that this would solve my issue (how wrong I was) The problem is now that when I push the project to GitHub the nested folder is greyed out as if it was ignored. Is there any way to undo what I have done? or do I just have to start again? I'm new to this and was trying to complete a sample app tutorial but the directory I've seemingly ruined is essential to the deployment in a production env.
Nested GIT Repository mistake method to remove it?
There is a GitHub action that could help to maintain the README file base on some data files. For example, you can easily maintain a big Markdown-based table from some YAML files. See also https://github.com/LinuxSuRen/yaml-readme
I'm new to github, and recently I finished an action with auto craw and process data on a daily basis. So, after with the workflow, I can have latest dataset. My question is, in github readme file, is there a way to show the last date in my dataset. For example, after my daily workflow finished, the last row of my dataset is '05/09/2022', and I want to see that on my readme file, without manually edit it. I tried to google it, but haven't found anything, maybe because I don't know how to search the right question? Was wondering if anyone know how to achieve this? Thanks in advance. Update: I found a way to display code in readme file, called permalink, it could show exactly what i want, but i need it changed from code to data
How to auto update readme file with specific data in files?
If you don't need all the feature from the native GitHub issues page, you could consider listing those issue to generate your own include/presentation. See "possible to embed Github list of issues (with specific tag) on website?" Kasper Souren proposes below in the comments the following fiddle: var urlToGetAllOpenBugs = "https://api.github.com/repos/jquery/jquery/issues?state=open&labels=bug"; $(document).ready(function () { $.getJSON(urlToGetAllOpenBugs, function (allIssues) { $("div").append("found " + allIssues.length + " issues</br>"); $.each(allIssues, function (i, issue) { $("div") .append("<b>" + issue.number + " - " + issue.title + "</b></br>") .append("created at: " + issue.created_at + "</br>") .append(issue.body + "</br></br></br>"); }); }); });
I'd like to put it in the Progress section of my project's webpage. I tried using an iframe, and I tried using $.load(), but neither of these work. Any ideas?
Is there any way to embed the GitHub Issue Tracker in a webpage?
3 I came across this question when I was looking for the same thing, and now I have found an answer! You can detect this event by creating a Cloud Trail that logs management events for your account, and looking for an event where the EventName = RunInstances, and the ErrorCode field is populated. I have seen this particular event come through as ErrorCode: Server.InsufficientInstanceCapacity. There are a variety of ways to consume and alert on the Cloud Trail logs, including CloudWatch. Share Improve this answer Follow answered Jul 8, 2022 at 3:10 jpepinjpepin 3122 bronze badges Add a comment  | 
I have a Kubernetes cluster that relies on AWS EC2 spot requests. I sometimes have this failure message from the aws auto-scaling group: Could not launch Spot Instances. InsufficientInstanceCapacity - There is no Spot capacity available that matches your request. Launching EC2 instance failed. I knew the downfall of using spot requests and that's not why I am here. I'd like to track this kind of failed activity from my auto-scaling group and I did not find anything inside CloudWatch. Is there any "legit" way of doing this? The final aim is to have an alert where AWS does not have capacity for my instance request(s) so I can act appropriately.
How to track InsufficientInstanceCapacity from AWS EC2?
One general solution to this kind of requirement is reactive, not proactive. Write automation based on CloudTrail Logs or AWS Config or by simply enumerating the current state of your AWS account periodically, and raise alerts (or terminate resources) if your policies have not been complied with.
I am trying to see if its possible to restrict(set some max limit) the number of EC2 instances which are created by an IAM user? Can i create custom policy for this?Note:I am looking for IAM user level permission. Not AWS Account level restriction.Similarly i am also looking for restricting EBS storage limit per IAM user.
AWS IAM user - Limit number EC2 instances and limiting EBS storage