Posts mit dem Label English werden angezeigt. Alle Posts anzeigen
Posts mit dem Label English werden angezeigt. Alle Posts anzeigen

Mittwoch, 19. Juli 2023

Laravel Forge: fatal: couldn't find remote ref refs/heads

On Laravel Forge I checked out a branch and deleted it from the git server by accident. Now I can not fetch and can not switch branch. Fun fact Forge tells me it switched while it did not:

forge@myserver:~/myserver.de$ git fetch 

fatal: couldn't find remote ref refs/heads/mybranch

fatal: the remote end hung up unexpectedly

This can be fixed be open and edit .git/config

In remote section replace the checked out branch mybranch with * two times:

[remote "origin"]

    url = git@bitbucket.org:me/mygit

--  fetch = +refs/heads/mybranch:refs/remotes/origin/mybranch 

++  fetch = +refs/heads/*:refs/remotes/origin/*

Save and quite.

Now you can run "git fetch" and "git checkout main".

I also deleted the old branch: git branch -d mybranch 

Donnerstag, 13. Juli 2023

Neato lidar laser not spinning

 

My Neato was starting and stopping but it did not move.

Turned out the lidar in the tower was not spinning. You can find a guide how to fix it on YouTube. In the video he uses an old motor from a CD Player he had. If you need to buy one you might be lost. I searched a long time. You can use a "solar" motor but they might break soon again.

I replaced it with RF-300FA-12350 DVD Player Motor from ebay (3,99€).
12V, Size: 24.4 x 12.4 mm with 19.4 mm shaft.

It is important to revers polarity. I cut of the old motor from the plug and soldered the red wire to the black one.

Also if you need to replace the side brush rubber, you can use a 25 x 2 mm seal. 3,50 € for 10 pieces.

Donnerstag, 19. November 2015

PHPStorm open local terminal in project folder

Not sure why this is not default, but can change this.

In Settings > Tools > Terminal change the "Shell path" and add your project path.

Windows: cmd.exe /K cd C:\your_project_path
Linux/Mac: ? (please leave a comment)

Donnerstag, 15. Oktober 2015

PHPStorm: fatal: protocol error: bad line length character: Erro

In PHPStorm I got with git pull and git push this error:

fatal: protocol error: bad line length character: Erro
An error has occurred while processing the shared archive file.
Unable to unmap shared space.

While command line and tortoise worked fine.

Fixed it by changing in PHPStorm settings in Version Control > Git:
"SSH executable" from "Build-in" to "Native"

Only toke me a few hours to figure this out :D

Freitag, 23. Januar 2015

Detect client speed using JavaScript

You can detect how long it toke for the browser to load the page. With load I mean the download time. Have a look at window.performance it contains all the timings. Also see html5rocks.

if (window.performance && window.performance.timing)
{
    var download_time = (window.performance.timing.responseEnd           - window.performance.timing.responseStart);
    var speed = ($('html').html().length) / download_time;
    if (speed < 400)
    {
        alert('slow');
    }
    else    {
        alert('fast');
    }
}

Note that this works best it the page size is large. For small pages the TCP/IP overhead for is large compared to your download time. My page was about 19304 bytes and I was able to detect mobile vs desktop.

Also see this stackoverflow question.

This does not work for IE8 and Safari

Mittwoch, 17. Dezember 2014

IE Post empty with NTLM

With NTLM login enabled sometimes data send with POST is missing. This is because IE has an internal timeout and tries to recheck NTLM.

With fiddler you can see the problem. One hacky solution is to catch this request and response with a fake answer. After this the IE will send the normal POST data.

To get the correct NTLM response use fiddle during a NTLM login. Switch the inspector to "Auth" and look for the "Type: 1" response and replace below with long string behind "WWW-Authenticate: NTLM". Place this at the top of your page and it will catch and respond to any IE NTLM request.


$headers = apache_request_headers();
$auth = $headers['Authorization'];
if ($auth && substr($auth,0,5) == 'NTLM ')
{
    $msg = base64_decode(substr($auth, 5));
    if ($msg[8] == "\x01") {
        header('HTTP/1.1 401 Unauthorized');
        header('WWW-Authenticate: NTLM ');
        exit;
    }
}

Note: This might be a security risk. Make sure to check the user Session and send him to your NTLM login is needed.

Dienstag, 20. Mai 2014

ImageMagick batch convert jpg to tiff windows

To convert all files in current directory create a .bat file containing:

for %%f in (.\*) do (
 convert %%f tiff/%%~nf.tiff
)

Where %%~nf is a special operator returning the file name without extension.

Dienstag, 1. April 2014

Magento how to remove duplicated sku

I messed up an import and got duplicated sku's. To fix it I search for duplicated products and remove all but the one with the newest update timestamp:

<?php
// find same sku, order by updated_at
$r2 = Mage::getModel('catalog/product')->getCollection()
    ->addAttributeToFilter('sku', $product['sku'])
    ->setOrder('updated_at', 'DESC')
    ->load();

// if there is a duplicate
if (count($r2) > 1 )
{
    echo "<br>" . $product['sku'] . ", " . count($r2) . "<br>";
    $i = 0;
    foreach ($r2 as $key => $p)
    {
        if ($i == 0)
        {
            // keep first
            echo $p->getCreatedAt() . ", " . $p->getUpdatedAt() . " keep<br>";
        }
        else
        {
            // remove others
            echo $p->getCreatedAt() . ", " . $p->getUpdatedAt() ." delete<br>";
            $p->delete();
        }
        $i++;
    }
}

Donnerstag, 20. März 2014

Smart Chicken Coop with Open Source Controller

Picture from LachieB1
I like chickens and one day I might build chicken coop. To be prepared I collect some useful links to open source chicken projects.

Mittwoch, 12. März 2014

Magento Export Customers

If you need to export customer data for Excel this script does the job. If you upload and execute it. A file.csv with you customers will be created. The UTF-8 CSV file can be imported in Excel. Don't forget to delete both files afterwords. Also note that personal records should not be mailed without encryption.

<?php
require_once("app/Mage.php");
Mage::app();
Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);
$collection = Mage::getModel('customer/customer')
    ->getCollection()
    ->addAttributeToSelect('*');

$fp = fopen('file.csv', 'w');
foreach($collection as $customer) {
 $customerAddressId = $customer->getDefaultBilling();
    if ($customerAddressId){
        $address = Mage::getModel('customer/address')->load($customerAddressId);

        $fields = array(
            $address->getData('company'),
            $customer->getData('prefix'),
            $customer->getFirstname(),
            $customer->getLastname(),
            $address->getData('street'),
            $address->getData('postcode'),
            $address->getData('city'),
            $address->getCountry(),
            $customer->getData('email')
        );
        fputcsv($fp, $fields);
        var_dump($fields); echo "<br>";
    }
}
?>

I converted the code to html using hilite.me looks nice, what do you think?

Mittwoch, 2. Januar 2013

JavaScript Tutorial for Professionals

If you have used used JavaScript for some time you might want to have look at JavaScript-Garden. It's very helpful!

Dienstag, 11. Dezember 2012

imo.im facebook login missing accounts

For a while now, when ever I login to imo.im using my Facebook account, I am missing all my other accounts. If I manually add one account, all my accounts come back. Today they even have a error message for this:

Your linked accounts on Jabber | Jabber | AIM / ICQ | MSN could not be logged in automatically. In order to fix this, please log into one of your other linked accounts. We recommend using an imo account to link all your other accounts. Register today!

But I wanted a bugfix, so I ask and after just a few hours I got a answer:

I'm afraid that due to some changes in how Facebook allows us to connect with them, it will no longer be possible for us to retrieve your linked accounts. I hate to say this, but it is not something we will be able to fix.

The only fix they can offer is to not sign out or "sign into your imo network account with a password--then you will get all of your accounts in one go.". So I made a password reset and can login with my imo account now.

Still I loved to have a single sign on solution. So I added my google account to imo. That works just fine!


Mittwoch, 8. August 2012

Mittwoch, 18. Januar 2012

Wikipedia: "Imagine a World Without Free Knowledge" hide overlay

The english Wikipedia is blacked out today.
If you still need to view a page, drag this bookmarklet to the favorites bar of your browser and click it after loading a wikipedia page.

Remove Wikipedia Blackout

Dienstag, 22. November 2011

Encode and decode Dreamweaver password in PHP

If you want to generate a Dreamweaver site file (.ste) so you can import it, you need to encode the password for Dreamweaver. You can learn from Andrew Odri that the encryption is very bad. He wrote encode and decode functions for this in Javascript. Doing the same in PHP is way easier. Of course you can use this page to decode your side export. But they do not explain how it works:

function encodePassword($input)
{
  $output = '';
  
  for($i = 0; $i < strlen($input); $i++)
  {
    $output .= dechex(ord($input[$i]) + $i);
  }

  return strtoupper($output);
}


function decodePassword($input)
{
  $output = '';
  
  for($i = 0; $i < strlen($input); $i += 2)
  {
    $output .= chr(hexdec($input[$i].$input[$i+1]) - $i/2);
  }

  return ($output);
}

Mittwoch, 26. Oktober 2011

Howto use the Firebug console where every you are

console.log() does not work in most situations. A simple solution to debug everywhere is to use Firebuglite. Add this small Javascript it your page and your problems are solved. It detects if the console is available and adds it where needed.

Dienstag, 23. August 2011

IE Standalone Tester

Because IE is still popular (damit it) and a lot of different versions are spreaded out it is a must to test your webpages with those browser. Unfortunately you can not run them all at once, only if you use many virtualle maschines... but wait, you can!
Just install IETester and you have IE 5.5 to 10 up and runing even with windows 7.

Donnerstag, 10. Februar 2011

Javascript load from different domain

Because of the same origin policy you can not load Javascript from a different domain. However this only applies to AJAX requests. If you add a HTML script tag to a webside the browser loads and executes it:

javascript:(s=(d=document).createElement("script")).src="http://google.de"; void(d.body.appendChild(s))


With the "javascript:" in front, you can execute it on any webpage. Just copy it in your browsers address bar and press enter. With this you can add new features to other pages. A function to delete all entries from facebooks pinboard or studivz would be nice. To make it look nice, you can add your script as bookmarklet to your browsers bookmarks.

Dienstag, 11. Januar 2011

Debian Squeeze Released! ah ne doch nicht...

Just a moment ago the download folder appeared:
http://cdimage.debian.org/cdimage/squeeze_di_rc1/

Update: Ähm, ja sorry. RC heißt release candidate. Nicht release. Da war ich wohl etwas voreilig :)

Aber es gibt ein release date. Laut Debian Mailingliste am 5. oder 6. Februar 2011.

Mittwoch, 25. August 2010

StarCraft II Top 200 Statistics

The new List of the Top 200 StarCraft II Players is out. I made a graphic showing what races the player used.

Race CountPercentage
Terran 83 41.71%
Protoss 69 34.67%
Zerg 43 21.61%
Random 5 2.51%

Click image to enlarge
Data from 24-Aug-2010

As you can see no one likes to play Zerg. Since the last Top 200 List from 17-Aug-2010 where we had 24.62% Zerg the situation even got worse. It is logical to me that the Terran is the most played race since the campaign is about Terran but that should not affect the top 200 list this much.

Blizzard argues that the situation on the Asian server is very different because there are 9 Zerg in the top 20. They say if the balancing is changed in favour of Zerg would become even to strong in Asian. So they are waiting that Europe and US players learn and get better.

Balancing is a very difficult thing and I don't believe I could make it better than the master minds at Blizzard. Still I want to mention that even on the Asian Top 200 there are only 25.63% Zerg but 37.69% Terran. So yes they have some good Zerg players but the imbalance is visible even in Asia.