To enable CORS headers and HTTP OPTIONS method in ServiceStack, add the following code to Configure()
this.Plugins.Add(new CorsFeature());
this.RequestFilters.Add((httpReq, httpResp, requestDto) => {
if(httpReq.HttpMethod == "OPTIONS"){
httpResp.EndServiceStackRequest();
}
});
That’s Real Racing HD on the iPad :-)
Cátia is more and more into frontend development and she talked about AngularJS.
Luís reformated the talk he gave past October about Sql Server isolation levels and concurrency and here is the result.
Isolation Levels exist so that users can control various concurrency problems when creating reading, updating and deleting data from a database. The concurrency problems are the following:
Note: The examples will run assuming that there is only one row in the TestTable, that is {id = 1, Value = 1}, the isolation level will be READ UNCOMMITED, that is the lowest level and allows us to test all the following problems.
Dirty read happens when selected data is being changed by a transaction, but it was not committed.
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRAN Select Value from TestTable where id = 1 COMMIT
BEGIN TRAN UPDATE TesteTble SET Value = 2 where id = 1 --Simulate having some intensive processing here with a wait WAITFOR DELAY '00:00:10' ROLLBACK
If we run the transaction simultaneous, Transaction 1 will tell us that Value is 2, but Transaction 1 is not yet committed, the data we are reading is only valid for 10 seconds.
Non-Repeatable Read is when two selects to the same data under the same transaction return different data.
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRAN Select Value from TestTable where id = 1 WAITFOR DELAY '00:00:10' Select Value from TestTable where id = 1 COMMIT
BEGIN TRAN UPDATE TestTable SET Value = 2 where id = 1 --Simulate having some intensive processing here with a wait WAITFOR DELAY '00:00:05' ROLLBACK
If we run the transaction simultaneous, Transaction 1 will tell us that Value is 2 in the first select and in the second we will have that the Value is 1.
Phantom Reads is when 2 selects to the same data under the same transaction return different number of rows.
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED BEGIN TRAN Select * from TestTable WAITFOR DELAY '00:00:10' Select * from TestTable COMMIT
BEGIN TRAN Insert Into TestTable (Value) Values (2) --Simulate having some intensive processing here with a wait WAITFOR DELAY '00:00:05' ROLLBACK
If we run the transaction simultaneous, Transaction 1 will tell us TestTable has 2 rows {id = 1, Value = 1} and {id = 2, Value = 2}, but the second select will only return 1 row {id = 1, Value = 1}.
Read Uncommitted is the lowest Level (Optimistic) and is when reading operations do not respect locks and don’t lock data, has we said before all concurrency problems can occur with this isolation level.
Read Committed is when reading operation can’t read data that is being changed by another transaction a Dead Lock will occur.
Snapshot is only available in SQL Server. In this level, a reading operation will return data that is being changed by another transaction, but without the changes made by it.
Serializable is the highest Level (Pessimistic) and is when rows and tables being read by a transaction will be locked, Dead Lock will occur in update, insert and delete operations.
Repeatable Read is when rows being read by a transaction will be locked, a deadlock will occur in update operations.
That’s Luis Torres right there!
Last Monday, it was y turn to present the Friday Talk (I know, it’s never on Friday). Lately we have been working on Windows and .NET, and both Luís and Cátia are a tad green on a Linux shell, so I decided to refresh the basics of using the shell on Linux (Ubuntu). The support for this talk wasn’t a slidedeck, it was the following plain text.
Use man to show the manual for a command
Try man man
~ (tilde) is your home directory, tipically /home/userpwd (stands for print working directory) returns the directory you are inls (list) lists the files in a directorycd (change directory)cp (copy) copy a file. For directories, use the -r flag cp -r directory foo (copy recursively)mv (move) move a file to a different location or rename a filerm remove a filermdir delete empty directory. To delete a directory and it’s contents rmdir -rmkdir to create a new directorysudo execute a command as root (dangerous stuff)./filenamedf displays filesystem disk space usage for all mounted partitions. df -h is more useful, being -h the flag for “human-readable”top (table of processes) displays running processes and system resourcesfree displays the amount of free and used memory. free -h (human-readable) shows values in megabytes, and is probably more usefuluname -a prints all system information, inclunding machine name, kernel name & version and more details.lsb_release -a prints version information for the Linux releaseadduser newuser creates a new user called “newuser”passwd someuser changes the password for “someuser”addgroup newgroup creates a new group called “newgroup”useradd -G groupname username creates a new user called “username” and adds it to group “groupname”usermod -a -G sftp pedro adds the existing user “pedro” to the group “sftp”-G for secondary groups, -g for primary groupsid user shows the id for the usergroups user prints the groups to which the user belongssu username The su command is used to become another user during a login session. Invoked without a username, su defaults to becoming the superuser.In Linux and Unix, eveything is a file. Directories are files, files are files and devices are files.
r or 4)w or 2)x or 1)user restrictions
chmod change permissions
chown change file ownerapt-get install acl for more granular permissionscat concatenate files and print on the standard output.grep find a string in a file or stream. It can be used with Regular expression to be more flexible at finding strings.awk pattern scanning and processing language. It’s a beast and I’m not going to discuss it here. More details http://www.grymoire.com/Unix/Awk.html)sed stream editor. Simple example: sed s/day/night/ old.txt > new.txt. A powerful tool as seen here http://www.grymoire.com/Unix/Sed.htmlifconfig (interface configuration) configure, control, and query TCP/IP network interface parameterspingtraceroutenslookupThe pipe makes the output of a command the input for another program. Piping is achieved using the | character.
ls -l | grep 'init' | less
cat files.txt | cp but this does cat files.txt | xargs cp because cp doesn’t read input, only arguments.
cp `cat files.txt`
Shell runs the command ct files.txt, intercepts the standard output and uses the result as parameters to cp
Consider this example ls -l > temp.txt where the output of ls -l is redirected from the screen to a text file. With the > character, it the file exists, it will be replaced. To append to a text use >>
ls -l >> temp.txt
Reversing also works_
grep 'init' < temp.txt
grep 'init' < temp.txt > temp2.txt
#!/bin/bash echo "The simplest of the scripts" exit 0
#!, frequently called Sha-bang#! is the magic number. When the kernel goes to run a program, it looks at the first 16 bits of the file. Simply put, it tells the kernel to execute the file contents with the tool specified after the sha-bangSome other sha-bang lines you can use:
#!/bin/sh #!/bin/bash #!/usr/bin/perl #!/usr/bin/tcl #!/bin/sed -f #!/bin/awk -f #!/bin/python
Note: the file containing the shell script must be executable chmod +x in order to be run like this ./script
ps aux lists all running processeskill -signal pid send the signal “signal” to process with id “pid”. Omit “signal” to just terminate the processkill -9 pid send signal number 9 (SIGKILL) to process with id “pid”. This is a last-resort method to terminate a process.command & runs command in the backgroundtouch change file timestamp, creating file if it doesn’t existhttps://help.ubuntu.com/community/UsingTheTerminal
http://en.wikipedia.org/wiki/Ifconfig
https://help.ubuntu.com/community/FilePermissions
https://help.ubuntu.com/10.04/serverguide/network-configuration.html
http://www.faqs.org/faqs/unix-faq/faq/part3/section-16.html
http://en.wikipedia.org/wiki/Xargs
http://help.lockergnome.com/linux/help-understand-pipe-xargs—ftopict549399.html
http://www.ece.ucy.ac.cy/courses/ece306/Linux%20primers/LinuxBasics.pdf
Today isn’t Friday, but last Friday the team was working at full speed closing features and client requests, so the talk was postponed for today, Monday. It was Catia turn to present, and she chose to talk about Python generators.
Luís, our in-house Microsoft evangelist, talked about concurrency in SQL Server. His slides were in portuguese, so as soon as he rewrites them in english, this post will be updated with the slidedeck.
Edit: Luís talk is available in this post http://blog.i2devlabs.com/friday-talk-isolation-levels-in-sql-server-20
Today we started a new initiative called Friday Talks. Every Friday a team member does a presentation to other team members on a topic he or she chooses. These talks are meant to be small, no more than one hour, and no topic is too small. The whole idea is to share with others that little bits of investigation and reading we (at least I) do on the couch, in the evening.
I was the first one to present and I talked about JavaScript inheritance. Check out the slides.No passado dia 26 de Junho estive no Instituto Politécnico de Leiria a apresentar a i2devlabs e a nossa proposta de estágio aos alunos do Mestrado em Engenharia Informática - Computação Móvel.
Podem ver o vídeo aqui:
Se não quiserem ver o vídeo, podem ver só os slides: