Entries tagged function

PHP + Laravel development Packages for atom.io

Posted on 30. Januar 2018 Comments

PHP CS Fixer

brew install php-cs-fixer

apm install php-cs-fixer

Settings:

php path: /usr/local/bin/php

php-cs-fixer path: /usr/local/bin/php-cs-fixer

PHP CS Fixer Rules: @PSR2,blank_line_after_opening_tag,whitespace_after_comma_in_array,blank_line_after_namespace

PHP CS Fixer Arguments: --using-cache=no, --no-interaction, --stop-on-violation

[x] Show Notifications

Ctrl+Cmd+S

Can also be used on commandline for folders, e.g.
$ php-cs-fixer fix app/ --rules=@PSR2,blank_line_after_opening_tag,whitespace_after_comma_in_array,blank_line_after_namespace

 

php-integrator-refactoring (php-integrator-base)

apm install php-integrator-base

apm install php-integrator-refactoring

Linting (also see linter(-php))

Sort use statements

 

linter and linter-php

apm install linter

apm install linter-php

In case linting with php-integrator-base does not work.

 

language-blade and language-vue

apm install language-blade

apm install language-vue

 

minimap

apm install minimap

Short overview over the code on the right side

 

highlight-selected

apm install highlight-selected

 

platform-ide-terminal

apm install platform-ide-terminal

Instead of switching windows, terminal right in atom

Cmd+Shift+T

 

symbols-tree-view

apm install symbols-tree-view

Structured overview on the right side over classes, constants, attributes, methods etc

 

hyperclick and hyperclick-php

apm install hyperclick

apm install hyperclick-php

Cmd+Click on classes, functions etc to go to origin.

Not needed if you installed atom-ide-ui

 

teletype

apm install teletype

Work on the same file with coworkers, encrypted via WebRTC

 

More dependencies might be installed with installing some of these packages

Nullstellenberechnung in Lua

Posted on 16. Dezember 2013 Comments

Nachdem ich 2011 schonmal ein paar Methoden zur numerischen Nullstellenberechnung in MATLAB online gestellt hatte, hier nur dieselben Beispiele in Lua. Ich habe mit Lua gerade erst angefangen und eigentlich erstmal  zur Übung nur den Code übersetzt. Der Code ist natürlich auf GitHub. Eine gute Lua Referenz ist Learn Lua in 15 Minutes von @tylerneylon.

Wie im letzten Beispiel habe ich diese Funktion benutzt:

Ableitung zur Nullstellenberechnung Beipiel

Außer bei Newton(da braucht man noch die Ableitung) sieht das dann in Lua so aus.

function f(x)
  return x^6-x-1
end

Zusätzlich habe ich noch die Genauigkeit Eta global festgesetzt:

eta = 0.00001

Bisektion

function bisection(a,b)
  local i = 0

  if (f(b)*f(a)<0) then
    while (math.abs(b-a)>eta) do
      if (f((a+b)/2)*f(a)>0) then
        a = ((a+b)/2)
      else
        b = ((a+b)/2)
      end
      i = i + 1
    end
    return ((a+b)/2)
  end
end

Newtonverfahren

function newton(x)
  local i = 0
  local diff = 1
  while (diff>eta) do
    nullstelle = x
    t1, t2 = f(x)
    x = x - (t1/t2)
    i = i+1
    diff = math.abs(x-nullstelle)
  end
  return x
end

function f(x)
  return x^6-x-1, 6*x^5-1
end

Regula Falsi

function regula_falsi(a,b)
  local i = 0
  local diff = 1
  if (f(b)*f(a)<0) then
    nullstelle = a
     while (diff > eta) do
      x = (a*f(b)-b*f(a))/(f(b)-f(a));
      if (f(x)<0) then
        a = x
      else
        b = x
      end
      diff = math.abs(x-nullstelle)
      nullstelle = x
      i = i+1
    end
  end
  return nullstelle
end

Sekantenverfahren

function secant(a,b)
  local i = 0
  while(math.abs(b-a)>eta) do
    nullstelle = b
    b = b-f(b)*(b-a)/(f(b)-f(a))
    a = nullstelle
    i = i+1
  end
  return ((a+b)/2)
end

„Incomplete statements not supported yet, sorry, you’ll have to retype“ Error with Scala and Eclipse

Posted on 15. November 2013 Comments

I got this error defining the function

object test {
  val f:AnyVal => String = {
      case 10.0 => "10.0"
      case _: Double => "Double"
      case _: Int => "Int"
      case _: Byte => "Byte"
      case _ => "anything else"
}

 -> Incomplete statements not supported yet, sorry, you’ll have to retype.

However, in REPL it worked just fine.

repat@laptop:~$ scala
Welcome to Scala version 2.10.3 (OpenJDK 64-Bit Server VM, Java 1.6.0_27).
Type in expressions to have them evaluated.
Type :help for more information.

scala>   val f:AnyVal => String = {
     |       case 10.0 => "10.0"
     |       case _: Double => "Double"
     |       case _: Int => "Int"
     |       case _: Byte => "Byte"
     |       case _ => "anything else"
     |   }
f: AnyVal => String = 

scala>

So aparrently the error is in Eclipse. I use the version 3.7.2. Have you tried turning it off and on again? 😉

Set Window position under Windows 7

Posted on 10. Oktober 2013 Comments

Apparently there is no way of setting/configuring a windows position on the screen. I couldn’t find a place to define X and Y or top and left. There is however  a function, if you write your own application in C++(SetWindowPos). Also deleting [-HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\BagMRU] and the like didn’t work for me, especially since the (current) user, wasn’t allowed to use regedit.

Thanks to paradroid on superuser.com, I found another, reasonably usable solution: Hold down CTRL while clicking on the [X]-button of a window. Windows will then remember the position for the next start.

-.-