archive-dk.com » DK » G » GEHLING.DK

Total: 105

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • middleware | Gehling.dk
    think middleware files ought to go Fill it with this piece of code class DowncaseRouteMiddleware def initialize app app app end def call env Rails 2 3 x routing use REQUEST URI uri items env REQUEST URI split uri items 0 downcase env REQUEST URI uri items join Rails 3 x routing use PATH INFO env PATH INFO env PATH INFO downcase app call env end end Now to telling Rails to use this new middleware class This differs a bit in Rails 2 and 3 Adding the middleware in Rails 3 x Open config application rb and find the lines module YourAppName class Application Add the middleware code like this module YourAppName class Application Adding the middleware in Rails 2 3 x Open up config environment rb and find the line Rails Initializer run do config a lot of config code end Add the middleware code so it looks like this afterwards Rails Initializer run do config config autoload paths Update The line config autoload paths is my general way of using middleware I always places all my middleware classes in a folder called app middleware The line above enables Rails to automatically search the autoload path for a file that matches the middleware class used i e downcase route middleware rb If this is the only middleware class that you use you can simply do a require downcase route middleware rb somewhere in your config initializers I just find the above solution more elegant Restart your rails application and it will now accept all kinds of casing on the routing part Note This code only downcases the part of the URI containing namespace controller action and id It does not touch the querystring parameters and for a good reason too The parameter values could contain some context in

    Original URL path: http://gehling.dk/tag/middleware/ (2016-04-30)
    Open archived version from archive


  • odbc | Gehling.dk
    10 Karmic Koala Our servers run Debian 5 0 Lenny If you run any of these OS versions and encounter an error like the following dbd odbc 0 2 4 lib dbd odbc driver rb 36 in connect DBI DatabaseError INTERN 0 RubyODBC Cannot allocate SQLHENV then help can be found here The problem on both OS es lies in the package libodbc ruby1 8 But it is actually stranger than you might expect which I will explain below Ubuntu first We ll start off with Ubuntu Fire up Synaptic Package Manger and search for libodbc ruby1 8 You will see that the distribution package is versioned 0 9997 2 You need to uninstall this and install version 0 9995 1 instead You can download version 0 9995 1 here http packages ubuntu com hu hardy i386 libodbc ruby1 8 download Now install it with apt get and problem solved Please note however that your automatic package update will revert to version 0 9997 2 unless you uncheck it before running the update Update 19 02 2010 This is also an issue on the 64 bit version of Ubuntu 9 10 Here s a link where you can download the 0 9995 1 deb package for both 32 bit AND 64 bit Thanks Goran http mirrors kernel org ubuntu pool universe libo libodbc ruby Debian next On Debian it s the other way around Debian comes installed with libodbc ruby1 8 version 0 9995 1 and you need to upgrade this to 0 9997 2 This package is currently only found in unstable but you can download it here http packages debian org sid i386 libodbc ruby1 8 download Install it with apt get overriding the previous package Hope this saves you from the days of work that I invested

    Original URL path: http://gehling.dk/tag/odbc/ (2016-04-30)
    Open archived version from archive

  • outsourcing | Gehling.dk
    venture hvor den lokale partner bidrager konstruktivt så er der brug for en ligeværdig partner med et højt niveau af selvstændighed visioner og innovation Og det finder man i Bangladesh Posted on 15 marts 2011 by Carsten Vil du outsource De 3 vigtigste råd Gennem mine 8 år som selvstændig har jeg gjort en dyd ud af at bruge eksterne eksperter Både på de områder hvor jeg ikke selv havde kompetencer men også indenfor mine egne områder hvis der var for meget at lave I de sidste 3 år brugte jeg meget folk fra udlandet Bulgarien Ukraine og Indonesien Det har både været godt men jeg har også brændt fingrene Derfor giver jeg her de 3 vigtigste erfaringer som jeg har gjort mig 1 Ansæt dine programmører for en længere periode af gangen Du skal ikke hyre teams for enkelte projekter f eks programmering af en hjemmeside Alt for ofte vil du opleve ændringer i projektets krav undervejs og så kan du nemt komme til at stå i en klemme Leverandørerne kan desværre vise sig meget ufleksible med at afvige fra det aftalte Det er meget bedre at ansætte en eller flere programmører som du så har fuld råderet over Tro mig du vil altid have noget som de kan lave På den måde er du ikke nær så sårbar overfor ændringer i projekter 2 Sørg altid for at du også får kildemateriale Uanset om du får produceret en flashfilm et design eller et program så skal du udover det færdige produkt også få en kopi af kildematerialet Også selvom du ikke selv har viden til at bruge den Hvis du ikke gør så har du bundet dig til leverandøren Jeg har oplevet at en leverandør skulle lave nogle vigtige ændringer i en flash film 1½ måned efter at projektet var færdigt Men de havde pludselig ikke længere tid fordi de havde fået nogle store opgaver ind fra andre vigtigere kunder Jeg kunne derfor vælge at vente 2 måneder eller få lavet flash filmen helt forfra et andet sted Ikke så fedt 3 Outsourcing er ikke så effektivt som lokalt ansatte Du skal regne med langt mere overhead og projektadministration end hvis du havde dine folk ansat i samme kontor som du sidder i Dels er det sværere at kommunikere på engelsk ikke mindst fordi at leverandørerne ikke altid er super gode til engelsk Men simpelthen også fordi man mangler muligheden for at stå samlet om en white board tavle og tegne fortælle Der findes mange gode kommunikationsværktøjer på nettet men det bliver bare aldrig helt det samme Tommelfingerregel Et projektteam i udlandet har en effektivitet på ca 50 af et der sidder sammen med dig Vær forberedt på at ting skal forklares igen og igen og med mange eksempler før det er helt forstået Forvent at ting skal kodes om 2 3 gange inden den sidder i skabet Vær opmærksom på at du kommer til at bruge meget tid på at koordinere projekterne Du får derfor ikke noget reelt

    Original URL path: http://gehling.dk/tag/outsourcing/ (2016-04-30)
    Open archived version from archive

  • passenger | Gehling.dk
    www gipote dk The last virtual host accepts all other variations on gipote dk except a few I ll come to that as well as an entirely different domain gi pote dk The last virtual host redirects all these requests to www gipote dk The last virtual host relly must be placed at the bottom since it contains wildcards These wildcards gipote dk will catch all hostnames not specified in any virtual host above it Position is vital Now to the second virtual host It requires a bit more explaining Internet Explorer and Firefox has a limit when fetching a webpage concerning concurrent connections to the same host They will only have 2 open connections to a single host at a time So if you have a page with many external files or assets css js images you may find that it is slow to load even if you have a powerful server The bottleneck is at the client this time Rails have a fix for this Every asset specified in the ERB by the asset helpers image tag stylesheet link tag etc Can automatically prepend the URL with an asset host You need to define the asset host in your config environments production rb file config action controller asset host http asset d gipote dk The d is important This will make Rails asset helpers prepend either of http asset0 gipote dk http asset1 gipote dk http asset2 gipote dk http asset3 gipote dk to any asset url It will use exactly these 4 variants and they will be distributed almost evenly out on your assets So image tag logo png will become http asset2 gipote dk images logo png or 0 1 3 The cool thing about this is that the aforementioned browsers will open 2 connections for

    Original URL path: http://gehling.dk/tag/passenger/ (2016-04-30)
    Open archived version from archive

  • programmering | Gehling.dk
    den Hvis du ikke gør så har du bundet dig til leverandøren Jeg har oplevet at en leverandør skulle lave nogle vigtige ændringer i en flash film 1½ måned efter at projektet var færdigt Men de havde pludselig ikke længere tid fordi de havde fået nogle store opgaver ind fra andre vigtigere kunder Jeg kunne derfor vælge at vente 2 måneder eller få lavet flash filmen helt forfra et andet sted Ikke så fedt 3 Outsourcing er ikke så effektivt som lokalt ansatte Du skal regne med langt mere overhead og projektadministration end hvis du havde dine folk ansat i samme kontor som du sidder i Dels er det sværere at kommunikere på engelsk ikke mindst fordi at leverandørerne ikke altid er super gode til engelsk Men simpelthen også fordi man mangler muligheden for at stå samlet om en white board tavle og tegne fortælle Der findes mange gode kommunikationsværktøjer på nettet men det bliver bare aldrig helt det samme Tommelfingerregel Et projektteam i udlandet har en effektivitet på ca 50 af et der sidder sammen med dig Vær forberedt på at ting skal forklares igen og igen og med mange eksempler før det er helt forstået Forvent at ting skal kodes om 2 3 gange inden den sidder i skabet Vær opmærksom på at du kommer til at bruge meget tid på at koordinere projekterne Du får derfor ikke noget reelt udbytte af kun at hyre en programmør Det lyder besværligt skal jeg helt lade være Det er svært at svare entydigt på Du skal i hvert fald ikke lade dig lokke bare af en billig pris Til gipote dk hyrede vi en Rails programmør i Indonesien for 3 måneder af gangen Vi havde nogle helt konkrete opgaver til ham Dem løste han også rimelig godt men til gengæld

    Original URL path: http://gehling.dk/tag/programmering/ (2016-04-30)
    Open archived version from archive

  • rack | Gehling.dk
    think middleware files ought to go Fill it with this piece of code class DowncaseRouteMiddleware def initialize app app app end def call env Rails 2 3 x routing use REQUEST URI uri items env REQUEST URI split uri items 0 downcase env REQUEST URI uri items join Rails 3 x routing use PATH INFO env PATH INFO env PATH INFO downcase app call env end end Now to telling Rails to use this new middleware class This differs a bit in Rails 2 and 3 Adding the middleware in Rails 3 x Open config application rb and find the lines module YourAppName class Application Add the middleware code like this module YourAppName class Application Adding the middleware in Rails 2 3 x Open up config environment rb and find the line Rails Initializer run do config a lot of config code end Add the middleware code so it looks like this afterwards Rails Initializer run do config config autoload paths Update The line config autoload paths is my general way of using middleware I always places all my middleware classes in a folder called app middleware The line above enables Rails to automatically search the autoload path for a file that matches the middleware class used i e downcase route middleware rb If this is the only middleware class that you use you can simply do a require downcase route middleware rb somewhere in your config initializers I just find the above solution more elegant Restart your rails application and it will now accept all kinds of casing on the routing part Note This code only downcases the part of the URI containing namespace controller action and id It does not touch the querystring parameters and for a good reason too The parameter values could contain some context in

    Original URL path: http://gehling.dk/tag/rack/ (2016-04-30)
    Open archived version from archive

  • rails | Gehling.dk
    and they will be distributed almost evenly out on your assets So image tag logo png will become http asset2 gipote dk images logo png or 0 1 3 The cool thing about this is that the aforementioned browsers will open 2 connections for each host So instead of fetching 2 assets concurrently your browser will now fetch 8 at the same time So we need our Apache to deal with this We cannot rely on the last virtual host to do this because it will simply redirect to www gipote dk And we don t want to add these 4 hostnames as alias to the top virtual host because we don t want our users to be able to access our Rails application by any other hostname than www gipote dk So I create the second virtual host Put in all 4 hostnames point it to my Rails public folder Oh and for good performance measure I disable Passenger PassengerEnabled off Otherwise the users would still be able to use the hostnames to access our application Posted on 20 marts 2010 by Carsten How to make Rails routing case insensitive Update 2013 01 06 I have now converted this into a gem Read more Update 2011 03 10 Brian Marquis pointed out that I ve missed showing a good way to actually load the rb file containing the middleware This has now been added to the article Update 2010 11 06 Rails 3 has changed its routing mechanism One of the changes involves which environment variable is used as the source for routing In Rails 2 3 x it was REQUEST URI in Rails 3 it is PATH INFO I have changed the middleware code to take care of both versions At our dog site www gipote dk we have a shop selling dog tags The URL for this shop is www gipote dk hundetegn hundetegn dog tag in danish However one of our marketing guys have a tendency to capitalize the word hundetegn so that URL reads www gipote dk Hundetegn with a capital H Rails will yield a 404 NOT FOUND on this simply because it is case sensitive The Rails core team doesn t seem to want this changed but I found a neat way of doing it myself Using the new Rack Middleware framework First the solution Create a file called downcase route middleware rb and put it in RAILS ROOT lib or wherever you think middleware files ought to go Fill it with this piece of code class DowncaseRouteMiddleware def initialize app app app end def call env Rails 2 3 x routing use REQUEST URI uri items env REQUEST URI split uri items 0 downcase env REQUEST URI uri items join Rails 3 x routing use PATH INFO env PATH INFO env PATH INFO downcase app call env end end Now to telling Rails to use this new middleware class This differs a bit in Rails 2 and 3 Adding the middleware in Rails 3 x Open config application rb and find the lines module YourAppName class Application Add the middleware code like this module YourAppName class Application Adding the middleware in Rails 2 3 x Open up config environment rb and find the line Rails Initializer run do config a lot of config code end Add the middleware code so it looks like this afterwards Rails Initializer run do config config autoload paths Update The line config autoload paths is my general way of using middleware I always places all my middleware classes in a folder called app middleware The line above enables Rails to automatically search the autoload path for a file that matches the middleware class used i e downcase route middleware rb If this is the only middleware class that you use you can simply do a require downcase route middleware rb somewhere in your config initializers I just find the above solution more elegant Restart your rails application and it will now accept all kinds of casing on the routing part Note This code only downcases the part of the URI containing namespace controller action and id It does not touch the querystring parameters and for a good reason too The parameter values could contain some context in their casing Now for the explanation Rails 2 3 introduced Rack middleware A lot of people have already explained this concept so instead of going into details I suggest that you read Pratik s explanation on Rails Guides and Ryan s Railscast on the subject Basically my middleware class gets access to the environment hash and passes it on to the next middleware class on the stack In between I get to modify the nessecary data In this case it s the REQUEST URI In Rails 3 it s PATH INFO since ActionController Dispatcher uses the URI from here to determine the correct route By converting the URI to lowercase ActionController Dispatcher gets the correct path no matter the case entered by the user Posted on 27 februar 2010 by Carsten Simple Amazon S3 file synchronize for Rails application without the need of Capistrano So you have a nice Rails app running and you want all your static assets to reside on Amazon S3 There are other good solutions on the web but most of what I ve seen requires that you also use Capistrano for deploying your app If you have not yet mastered that beast just like me you will like this little rake task that I ve made Just copy paste this code into your favorite editor change the 4 parameters in the top and save it in lib tasks aws rake Then you can do this rake aws sync This will upload all folders and files from your public folder into your Amazon S3 bucket The script creates a file called aws cache in the root of your application folder This is used so that additional calls to rake aws sync only uploads new and modified

    Original URL path: http://gehling.dk/tag/rails/ (2016-04-30)
    Open archived version from archive

  • rails 3 | Gehling.dk
    H Rails will yield a 404 NOT FOUND on this simply because it is case sensitive The Rails core team doesn t seem to want this changed but I found a neat way of doing it myself Using the new Rack Middleware framework First the solution Create a file called downcase route middleware rb and put it in RAILS ROOT lib or wherever you think middleware files ought to go Fill it with this piece of code class DowncaseRouteMiddleware def initialize app app app end def call env Rails 2 3 x routing use REQUEST URI uri items env REQUEST URI split uri items 0 downcase env REQUEST URI uri items join Rails 3 x routing use PATH INFO env PATH INFO env PATH INFO downcase app call env end end Now to telling Rails to use this new middleware class This differs a bit in Rails 2 and 3 Adding the middleware in Rails 3 x Open config application rb and find the lines module YourAppName class Application Add the middleware code like this module YourAppName class Application Adding the middleware in Rails 2 3 x Open up config environment rb and find the line Rails Initializer run do config a lot of config code end Add the middleware code so it looks like this afterwards Rails Initializer run do config config autoload paths Update The line config autoload paths is my general way of using middleware I always places all my middleware classes in a folder called app middleware The line above enables Rails to automatically search the autoload path for a file that matches the middleware class used i e downcase route middleware rb If this is the only middleware class that you use you can simply do a require downcase route middleware rb somewhere in your

    Original URL path: http://gehling.dk/tag/rails-3/ (2016-04-30)
    Open archived version from archive