Tutorial by Examples: ase

SELECT UPPER('HelloWorld') --returns 'HELLOWORLD' SELECT LOWER('HelloWorld') --returns 'helloworld'
Each migration should have an up() method and a down() method. The purpose of the up() method is to perform the required operations to put the database schema in its new state, and the purpose of the down() method is to reverse any operations performed by the up() method. Ensuring that the down() me...
One might want to group their data by the runs of a variable and perform some sort of analysis. Consider the following simple dataset: (dat <- data.frame(x = c(1, 1, 2, 2, 2, 1), y = 1:6)) # x y # 1 1 1 # 2 1 2 # 3 2 3 # 4 2 4 # 5 2 5 # 6 1 6 The variable x has three runs: a run of l...
The -CaseSensitive parameter enforces switch statements to perform exact, case-sensitive matching against conditions. Example: switch -CaseSensitive ('Condition') { 'condition' {'First Action'} 'Condition' {'Second Action'} 'conditioN' {'Third Action'} } Output: Second Act...
% Define serial port with a baud rate of 115200 rate = 115200; if ispc s = serial('COM1', 'BaudRate',rate); elseif ismac % Note that on OSX the serial device is uniquely enumerated. You will % have to look at /dev/tty.* to discover the exact signature of your % serial device ...
Assuming you created the serial port object s as in this example, then to close it fclose(s) However, sometimes you can accidentally lose the port (e.g. clear, overwrite, change scope, etc...), and fclose(s) will no longer work. The solution is easy fclose(instrfindall) More info at instrfin...
One feature provided for free by case classes is an auto-generated equals method that checks the value equality of all individual member fields instead of just checking the reference equality of the objects. With ordinary classes: class Foo(val i: Int) val a = new Foo(3) val b = new Foo(3) prin...
Given the following history, imagine you make a change that you want to squash into the commit bbb2222 A second commit: $ git log --oneline --decorate ccc3333 (HEAD -> master) A third commit bbb2222 A second commit aaa1111 A first commit 9999999 Initial commit Once you've made your change...
This code can be added to any event like a listener, button, etc. A blocking JDialog will appear and will remain until the process is complete. final JDialog loading = new JDialog(parentComponent); JPanel p1 = new JPanel(new BorderLayout()); p1.add(new JLabel("Please wait..."), BorderLa...
Class based views let you focus on what make your views special. A static about page might have nothing special, except the template used. Use a TemplateView! All you have to do is set a template name. Job done. Next. views.py from django.views.generic import TemplateView class AboutView(Tem...
When contributors add to a project from different machines or operating systems, it may happen that they use different email addresses or names for this, which will fragment contributor lists and statistics. Running git shortlog -sn to get a list of contributors and the number of commits by them co...
Database transactions ensure that a set of data changes will only be made permanent if every statement is successful. Any query or code failure during a transaction can be caught and you then have the option to roll back the attempted changes. PDO provides simple methods for beginning, committing,...
Sometimes you need rewrite history with a rebase, but git push complains about doing so because you rewrote history. This can be solved with a git push --force, but consider git push --force-with-lease, indicating that you want the push to fail if the local remote-tracking branch differs from the b...
The android:process field defines the name of the process where the service is to run. Normally, all components of an application run in the default process created for the application. However, a component can override the default with its own process attribute, allowing you to spread your applicat...
SELECT FIND_IN_SET('b','a,b,c'); Return value: 2 SELECT FIND_IN_SET('d','a,b,c'); Return value: 0
Since Git 1.7.12 it is possible to rebase down to the root commit. The root commit is the first commit ever made in a repository, and normally cannot be edited. Use the following command: git rebase -i --root
angular.module("app") .service("counterService", function(){ var service = { number: 0 }; return service; });
angular.module("app") // Custom services are injected just like Angular's built-in services .controller("step1Controller", ['counterService', '$scope', function(counterService, $scope) { counterService.number++; // bind to...
Private inheritance is useful when it is required to restrict the public interface of the class: class A { public: int move(); int turn(); }; class B : private A { public: using A::turn; }; B b; b.move(); // compile error b.turn(); // OK This approach efficiently pr...
An alternative to extending Enumeration is using sealed case objects: sealed trait WeekDay object WeekDay { case object Mon extends WeekDay case object Tue extends WeekDay case object Wed extends WeekDay case object Thu extends WeekDay case object Fri extends WeekDay case objec...

Page 5 of 40