w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
can't run rake or rails console on vps
I got it to work by specifying the production environment when I ran the commands RAILS_ENV=production rails console RAILS_ENV=production rake db:seed I found this unusual since the app was working.

Categories : Ruby On Rails

Cancan and console command "rake routes"
You definitely need to write it by yourself (I don't know if there are cancan plugins for this). First, cancan doesn't store what you can and cannot access in a specific place connected to routes, cancan only allows you to choose which method you can access for a given class or instance, like can :read, User, it's not tied in any way to the routes and at the same time routes are not tied directly to models (they are tied to controllers). Based on this, it's also not that easy to write such a thing (not impossible, but not easy and I don't think is short). Your best bet is try to emulate tests, you may try to access each route (you can probably parse the output of rake routes or read how that code is generated) with a given user and if the user can't access that path, you mark as non-acc

Categories : Ruby On Rails

running rake task from console produces 'ArgumentError: no method name given' error
You should run rake from terminal, not rails console. If you for some reason want to do it from rails console, you should load tasks like that require 'rake' MyRailsApp::Application.load_tasks Rake::Task['my_task'].invoke

Categories : Ruby On Rails

Use of OpenMP chunk to break cache
Both code snippets that you've given are not equivalent as the first one would keep reiterating over the same elements for n larger than 4. The proper way to process such arrays is to ensure that sizeof(arr[0]) * n / #cores is a multiple of the cache line size. Modern x86 CPUs have cache line size of 64 bytes. If arr is an integer or a single-precision floating point array, then sizeof(arr[0]) == 4 and a single cache line holds 16 elements. For data types with double the size a single cache line holds 8 elements. The best loop schedule chunk size is then a multiple of 16 in the former case or 8 in the latter case. When dealing with statically scheduled loops one tries to maximise the chunk size in order to reduce the number of loops run by each thread. For example, if there are 4 threads,

Categories : C

Python - Mako templates - How to invalidate cache?
Currently I'm using this Beaker specific code to clear the entire cache for a specific template: kw = template.cache._get_cache_kw({}, None) cache = self.cache_manager.get_cache(template.cache.impl.cache.id, **kw) cache.clear() I can't believe that Mako doesn't have basic support for this operation... have I overlooked something?

Categories : Python

How to clean Movable Type cache in tag templates
You need to specify more about your MT versions and how tags is implemented. Usually, Tags are implemented using the internal search. this search have a life time that is 20 seconds by default. (see it you have SearchCacheTTL in your mt-config.cgi) failing that, you can check the database and clear all the session raws that have kind="CS". (this is where the cache is. unless you are using memcache) Good luck.

Categories : Misc

break from infinite loop from console
You could use signals: #include <signal.h> #include <stdio.h> #include <stdlib.h> static void on_close(int signal) { puts("Cleaning up..."); exit(EXIT_SUCCESS); } int main(void) { signal(SIGINT, on_close); while (1) { } return EXIT_SUCCESS; }

Categories : C++

Laravel Blade Templates Section Repeated / cache error
You can achieve this by overwriting the sections.. try what you have already, but with these two updated sub-views: panel1.blade.php @extends('panelTemplate') @section('title') title panel 1 @overwrite @section('body') body panel 1 @overwrite @section('footer') footer panel 1 @overwrite panel2.blade.php @extends('panelTemplate') @section('title') title panel 2 @overwrite @section('body') body panel 2 @overwrite @section('footer') footer panel 2 @overwrite It's tested and working here, though I'm not sure it's the intended use of @overwrite, so test thoroughly!

Categories : Laravel

Does Google Chrome Frame break IE8 console output?
From Google Chrome Frame documentation: You can use the Web Inspector in GCF just as you would in the Google Chrome browser. To use it, right-click and choose "Inspect Element". Logging is available via the console.log method, and you can set breakpoints and inspect network activity.

Categories : HTML

Rails cache from the console returning nothing nil
Change your cache store: the memory store just stores everything in the process's memory, so every instance of the application will have a separate cache. In particular the console won't see anything that is set from the running web application. You could use the file store (which stores data in temporary files in tmp) or you could also use dalli store locally - memcached is very easy to run.

Categories : Ruby On Rails

bundle exec rake db:create:all, errors caused by 2 different versions of rake gem, not sure where to go from here
I don't think it's the multiple versions of rake. The bundle exec bit should do the right thing. Are you missing the /config/boot.rb file referred to at /config/application.rb:1?

Categories : Ruby On Rails

You have already activated rake 0.9.6, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this
At the root of project, do: gem list rake You will see probably more than one version. If so, then remove the version you don't need (i.e. 0.9.6) by command: gem uninstall rake it will ask which version to remove. Or try doing bundle update rake

Categories : Ruby

Console calls (like cache clears or behat) throw an exception but all is fine in browser
I figured out where the problem came from, but without understanding it. It appeared that somewhere in my application I called $this->container->get('twig')->render("Bundle:View:action.html.twig") I changed to $this->container->get('templating')->render("Bundle:View:action.html.twig") twig service is a Twig_Environment instance, and template is a DelegatingEngine instance, both allowing to render a template. And all works great again. If someone could explain me what happened, I'll appreciate :)

Categories : PHP

rake db:migrate Could not connect to server error
To install postgres you may use these commands: sudo apt-get install postgresql-9.1 postgresql-server-dev-9.1 Then you should set password to newly user sudo passwd postgres You have to ensure that database configuration parameters(like username, password etc) in config/database.yml are correct. And then: rake db:setup will create databases and restore schemas if any.

Categories : Ruby On Rails

Rails + Rake: How to simulate running of rake task to see if it works?
Yes you can actually run bundle exec rake COMMAND -n Having a look at rakes help we can see it here. # rake --help --dry-run Do a dry run without executing actions.

Categories : Ruby On Rails

Octopress new post seen in rake preview but not published after rake deploy
From the Octopress docs: Check that the published status of the post isn't set to false. If it is, it won't show up (though rake preview will work).

Categories : Ruby

When i run this rake task its giving an error rake aborted........... anu suggestions
The command: rake -T will show you the available tasks. Since you are using an unix based OS, you can run: rake -T | grep jquery and you will see the jquery related tasks. Also, you should notice that the simple quotation marks are not required, you should run something like: rake jquery_mobile_rails_tasks

Categories : Ruby On Rails

Linux server: Would a cache scheme help reduce hits to 3rd-party server?
I think memcached is a good choice. You can set timeout when you store content to memcached server, if key-value missed, retrieve data from 3rd-part server and store again. There is memcached extension for PHP, check doc here.

Categories : PHP

Rake Routes and Rails Server both fail to routing issue
The problem WAS the routes. It was these two: get 'sessions#new' get 'posts#new' They have to be: get 'sessions/new' get 'posts/new' That was annoying. Hopefully this helps you.

Categories : Ruby On Rails

Are rake db:create and rake db:migrate idempotent?
Yes, they are idempotent and running those two commands should just bring your DB "up-to-date", and once you've running them through to completion, then running them again subsequently should do nothing. However, a better way to set up a brand new machine is to use rake db:setup db:setup just runs these tasks in order: db:create db:schema:load db:seed Notice db:setup does not run db:migrate, and instead simply runs db:schema:load. Migrations are only required when you are upgrading an existing DB to a newer version, since they describe the differences between two versions of your schema. But when you're setting up a new DB entirely, you can skip the whole history of migrations and jump to the most recent state of the schema, i.e., load the current schema with db:schema:load. And db

Categories : Ruby On Rails

You have already activated rake 10.0.4, but your Gemfile requires rake 10.0.3
Use bundle exec infront of your command bundle exec rake assets:precompile This will solve your issue. I always recommend to use "bundle exec" before any such kind of commands.

Categories : Ruby On Rails

Discrepency in "rake preview" vs. "rake deploy"
Is your blog hosted at domain.com/blog? If so, ensure that the site variables url and root in _config.yml are set properly. If that doesn't solve it, can you provide a dump of the browser console? This will help to debug.

Categories : Misc

Rails server not starting with web sockets and redis options in rake task.
Hey thanks for the question, I personally couldn't get a rake task of mine to post to a websocket channel I had open on my rails server. Your synchronize command helped (along with starting a Redis server locally). Your problem through - seems like you're pointing to 3000. Is that your rails server or the Redis instance? If you're running it locally, I'd omit that line.

Categories : Ruby On Rails

Heroku breaks when precompiling assets. with "rake aborted! Can't connect to MySQL server on '127.0.0.1' (111)"
If your application initializes (Rails does in some scenarios) a connection to the database during it's boot stage you run into this problem when compiling assets in production. You need to give your application access to environment variables via a Heroku labs feature heroku labs:enable user-env-compile -a myapp You can read more about this at https://devcenter.heroku.com/articles/labs-user-env-compile

Categories : Ruby On Rails

SQL Server calculation returning 0 instead of a float value
If CTE_3.vote_count type is int or @minimumVotesRequired type is int, then you are getting the truncated int value. Make sure those are floats, or cast them as floats before doing your division. Also, don't forget that COUNT is an integer function. You will want to cast the result of your COUNT as a float as well.

Categories : Sql Server

Fast calculation of partial sums on a large SQL Server table
General advice I can provide now until you provide more information. Updated my query since it was pulling from views to pull straight from the tables. INSERT INTO @ret SELECT SUM(LeistungArbeit) FROM ( SELECT DISTINCT WebID FROM XBauAdmin.dbo.CustKunde ) Web INNER JOIN dbo.TblLeistung ON TblLeistung.WebKundeID=web.webID INNER JOIN dbo.MainRapport ON MainRapport.WebKundeID=web.webID AND TblLeistung.LeistungRapportID=MainRapport.WebSourceID AND MainRapport.RapportBaustelleID = @baustelleID AND MainRapport.RapportDatum <= @datum WHERE TblLeistung.LeistungArbeit is not null AND TblLeistung.LeistungInventarID is null AND TblLeistung.LeistungArbeit > 0 Get rid of the table variable. They have their use, but I swit

Categories : SQL

Calculation order when iterative calculation (circular reference) is enabled
From this page: The first step is the same as a recalculation (or full calculation, depending how the calculation was invoked) that does not involve circular references. This enables all the cells that come before the circular reference to be properly calculated and the list of cells in the circular reference to be identified together with their dependents. During this first step Application.Iteration is False. The second step occurs once on each iteration: The list of cells in the circular reference is calculated sheet by sheet, in alphabetic sheet name sequence. Within each sheet the list of cells and array formulae in the circular reference, and all cells that are dependent on them, is calculated from left to right and top to bottom. (all the columns in the first row from left to rig

Categories : Excel

Server-grade SDK that can load a PDF file and execute the calculation and validation code snippets?
I don't know of any toolkit but between these two documentation sources you might be able to throw together a basic expression processor that will handle your calculation and validation needs. Might be a great open source addition to iTextSharp! Looks like this documentation might be just what you need to get started writing that converter from FormCalc to C# Expression trees! "You can have the C# or Visual Basic compiler create an expression tree for you based on an anonymous lambda expression, or you can create expression trees manually by using the System.Linq.Expressions namespace."

Categories : C#

Multiple String Search and Replace on SQL Server (for templates)
DECLARE @t AS templateVarsType INSERT INTO @t SELECT '{planet}','World' UNION SELECT '{galaxy}','MilkyWay' SELECT dbo.applyTemplate( 'Hello, {planet}! Welcome to the {galaxy}.' , @t ) Check this fiddle http://sqlfiddle.com/#!3/edda3/10

Categories : SQL

render templates for a specific route directly from the server
Honestly, I never tried this solution, but I guess the controller template has not necessarily to be a static file. You need to provide a path to your template, but it could be created dynamically. For example: angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives', 'myApp.controllers']). config(['$routeProvider', function($routeProvider) { $routeProvider.when('/login', {templateUrl: 'partials/login.php', controller: 'LoginCtrl'}); $routeProvider.when('/logout', {templateUrl: 'partials/logout.php', controller: 'LogoutCtrl'}); $routeProvider.otherwise({redirectTo: '/login'}); }]); login.php and logout.php must return a valide AngularJS template. I never tried this, but it should work. I don't know if this is the Angular way of doing things.

Categories : Angularjs

Cannot change web server settings in Visual Studio web project templates?
The "solution" I finally went with does not actually resolve the fact that the section seems to be overwritten, but rather puts a bit of duct tape on it... I implemented a wizard which I added to the template. In the implementation, I put code in the RunFinished method which opens the project file as a xml document, and simply replaces the section with what I want it to be. It sort of works, the only real drawback is that it will alert you that the project has been changed and needs to be reloaded as soon as it is added.

Categories : Visual Studio 2012

Conditionals embedded in client templates in kendo ui MVC grid (server)
Solved it.this may help others facing same problem @(Html.Kendo().Grid(Model) .Name("Grid") .Columns(columns => { columns.Bound(o => o.AccountManager).Title("Account Manager").ClientTemplate("# if (AccountManager == null) { #" + @Html.ActionLink("Assign", "action", "Controller", new { @caseId = "#=CaseID#", @tabIndex = "0" }, new { @Title = "View"}).ToHtmlString() + "# }else {#" + "#=AccountManager#" + "#} #").HtmlAttributes(new {@style = "text-align:center" }); })

Categories : Dotnet

How to cache data in server using files
Caching won't be a replacement for persistence. you can store data in a file system instead of a db but the whole point of having a db in the first place is that data storage and retrieval is much faster in a db than in a normal file system because of better structuring of data and indexing (along with the huge advantage of ease of querying to get data). you can always dump your data in a db in huge file formats (not recommended) For caching, you can use memcached or redis. Note that caching is not 100% reliable. You can configure the cache to specify a time after which cache should be cleared. You also need to keep updating the cache data whenever you create/update some data in your db. If your cache gets full, normally least-used resources will be cleared from the cache first to accommo

Categories : Java

Web cache system on server side
If you look at squid, you're looking at HTTP level caching. Thus, whenever someone is signed in to your system, you'll have to work around the cache: Once the user name appears on the page or some permissions are checked for content access, you can't generically cache on HTTP level other than in the user's browser (or for external media, like CSS, images). For Liferay you can look at Liferay's CDN capabilities: You can configure a CDN (Content Delivery Network) which addresses external hosts that work like reverse proxies - these would serve the cachable content while the portal serves the pages (esp. for logged in users) Liferay also will signal upstream caches that anonymously accessed pages are cacheable if ALL of their content signals that it's cacheable. This is automatic. I assume

Categories : Caching

Magento: need to cache and index on a server and not in another
Caching and Indexing option are saved in database by default, not in the filesystem. So you can do this easily. Just deactivate caching and set index mode to manual in the back office of your dev stage.

Categories : Magento

Datastore write limit tests - trying to break app engine, but it won´t break ;)
Using a non-default TaskQueue with a increased rate limit of 350/tasks/sec led to 20 instances being fired up and plenty of Timeout Exceptions... Thanks Mr. Steinrücken! The Exception is google.appengine.api.datastore_errors.Timeout, which is the same as documented for the db package - so no ndb extras there. PS: Our idea is to catch the exception in our cache handling class as a sign of datastore overload and automatically set up shading for that item... monitoring the quests a minute and diable shading again when not needed...

Categories : Google App Engine

while loop won't break,should break when the counter is no longer less than the length of the array
If you run your code directly in the python shell, you will get a SyntaxError. For more info, see http://bugs.python.org/issue11433 If you save the code down in a file, say test.py, then run python test.py, it will print out the result as expected. Edit: This answer is currently having a -1 rating. Before you downvote, can you actually read and try to understand the answer? This is what I am talking about:

Categories : Python

How exactly mem cache and Ehcahe stores data in server?
The best way to find the internal workings of a caching framework is to go through its source code. I could not find any authoritative article detailing the internal working of these frameworks. Here are few points which differentiates Ehcache from Memcache. Distributed caches like MemCache and EHcache work like a Giant Hashmap. By Distributed, it means that the cache can be spread over multiple servers, virtually extending the storage capability to unlimited number of objects. Although, both Ehcaceh and Memcached appear like a hashmap, the way they work is quite different. Ehcache is general purpose Java Object cache, meaning generally used with the Java Application to cache java objects. Its generally used as an add-on to the application for caching requirements. Ehcache is comple

Categories : Java

How best to cache entire HTML output on the server
Generating different pages depending on User Agents is just bad practice. You shouldn't do that. If you want to cache entire pages because your website is slow, the problem probably has to be searched in your code. On-topic: Write a simple function that hashes the uri being served with a small footprint hash function (md5, sha1,...) e.g. <?php $hash = md5('itemdetail.php-'.$itemid); if ( file_exist('cache/'.$hash.'.html') { echo file_get_contents('cache/'.$hash.'.html'); die(); } and then at the end of your script save the result to 'cache/'.$hash.'.html'; You can offcourse use different kind of extension or folder or... If you want to cache without using PHP, take a look at Varnish. Or the other example posted here.

Categories : PHP

ASP.net cache ASHX file server-side
With the code you've provided you're telling the end user browser to cache the results for 30 minutes, so you aren't doing any server side caching. If you want to cache the results server side you're probably looking for HttpRuntime.Cache. This would allow you to insert an item into a cache that is globally available. Then on the page load you would want to check the existence of the cached item, then if the item doesn't exist or is expired in the cache, go to the database and retrieve the objects. EDIT With your updated code sample, I found http://stackoverflow.com/a/6234787/254973 which worked in my tests. So in your case you could do: public class autocomp : IHttpHandler { public void ProcessRequest(HttpContext context) { OutputCachedPage page = new OutputCachedPage(

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.