АРХИВ ПО ТЭГУ "ПРОГРАММИРОВАНИЕ"
МАЙ 26, 2015

Приветос,

Зацените демку различных iOS анимаций: https://github.com/chupakabr/valera-cv

Еще хотелось бы много всего добавить, но выходные закончились, и пора спать icon smile iOS animations demo %d1%82%d0%b5%d1%85%d0%bd%d0%be%d0%bb%d0%be%d0%b3%d0%b8%d0%b8

ios animations demo valera chevtaev cv resume iOS animations demo %d1%82%d0%b5%d1%85%d0%bd%d0%be%d0%bb%d0%be%d0%b3%d0%b8%d0%b8

АПРЕЛЬ 17, 2015

Just a note on how to get running time for a query defined by regex:

  1. SELECT datname,waiting,now()-query_start,current_query
  2. FROM pg_stat_activity
  3. WHERE current_query ilike '%YOUR QUERY REGEX GOES HERE%'
  4. ORDER BY procpid;
НОЯБРЬ 19, 2014

Hi,

Very interesting thing: Java compiler generate pretty clever code when you operate with strings, i.e. when you concatenate two or more Strings JVM creates StringBuilder transparently to a programmer and concatenates passed strings using that builder object and only then assigns the value to resulting string.

So typical interview question «What is more efficient for concatenating strings: ‘plus’ operator on strings or using StringBuilder class?» you can simply answer «both ways are efficient, and actually almost the same». Let’s do some disassembling now to make sure. I was using both Java 1.6 and Java 1.7 to test my statement.

  1. class Str{
  2.   public static void main(String[] args) {
  3.     String s = "first";
  4.     int i = 5;
  5.     String s2 = "second";
  6.  
  7.     String res = s + i + " " + s2;
  8.  
  9.     System.out.println(res);
  10.   }
  11. }

And now bytecode generated using javac (Java 1.7):

Compiled from «Str.java»
  1. class Str {
  2.   Str();
  3.     Code:
  4.        0: aload_0      
  5.        1: invokespecial #1                  // Method java/lang/Object."":()V
  6.        4: return        
  7.  
  8.   public static void main(java.lang.String[]);
  9.     Code:
  10.        0: ldc           #2                  // String first
  11.        2: astore_1      
  12.        3: iconst_5      
  13.        4: istore_2      
  14.        5: ldc           #3                  // String second
  15.        7: astore_3      
  16.        8: new           #4                  // class java/lang/StringBuilder
  17.       11: dup          
  18.       12: invokespecial #5                  // Method java/lang/StringBuilder."":()V
  19.       15: aload_1      
  20.       16: invokevirtual #6                  // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
  21.       19: iload_2      
  22.       20: invokevirtual #7                  // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
  23.       23: ldc           #8                  // String  
  24.       25: invokevirtual #6                  // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
  25.       28: aload_3      
  26.       29: invokevirtual #6                  // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
  27.       32: invokevirtual #9                  // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
  28.       35: astore        4
  29.       37: getstatic     #10                 // Field java/lang/System.out:Ljava/io/PrintStream;
  30.       40: aload         4
  31.       42: invokevirtual #11                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
  32.       45: return        
  33. }
НОЯБРЬ 14, 2014

Screen Shot 2014 11 13 at 23.00.36 Lottery numbers generator script (bash) %d1%82%d0%b5%d1%85%d0%bd%d0%be%d0%bb%d0%be%d0%b3%d0%b8%d0%b8

Привет,

Решил вот сгенерировать скриптец на баше и поучаствовать в национальной лотерее Великобритании.

#!/bin/bash
  1.  
  2. # Print usage info
  3. function usage() {
  4.   echo "Usage: $0 "
  5.   echo " * lotto   — Lotto"
  6.   echo " * eurom   — Euro Millions"
  7.   echo " * tball   — Thunderball"
  8.   echo " * hotpick — Lotto Hotpicks"
  9.   echo "More info about UK National Lottery visit https://www.national-lottery.co.uk/games/lotto"
  10. }
  11.  
  12. # Check input params
  13. if [ -z "$1" ]; then
  14.   usage
  15.   exit 1
  16. fi
  17.  
  18. type=$1
  19.  
  20. # Generate random number from 1 up to {limit} and print it
  21. function gen_num() {
  22.   limit=$1
  23.   echo -n $[1 + $[ RANDOM % $limit ]]" "
  24. }
  25.  
  26. # Main app
  27. echo -n "Your lucky numbers for $type are: "
  28. case $type in
  29. lotto)
  30.   for i in {1..6}; do gen_num 59; done
  31.   ;;
  32. eurom)
  33.   for i in {1..5}; do gen_num 50; done
  34.   echo -n "+ lucky stars "
  35.   for i in {1..2}; do gen_num 11; done
  36.   ;;
  37. tball)
  38.   for i in {1..5}; do gen_num 39; done
  39.   echo -n "+ thunderball "
  40.   for i in {1..1}; do gen_num 14; done
  41.   ;;
  42. hotpick)
  43.   for i in {1..5}; do gen_num 49; done
  44.   ;;
  45. *)
  46.   usage
  47.   ;;
  48. esac
  49.  
  50. echo ""
  51. echo "Good luck icon smile Lottery numbers generator script (bash) %d1%82%d0%b5%d1%85%d0%bd%d0%be%d0%bb%d0%be%d0%b3%d0%b8%d0%b8 "
АПРЕЛЬ 9, 2014
АПРЕЛЬ 2, 2014

Привет,

Пошутить не успел, был очень занят вчера. Так что без шуток сразу к C++11 icon smile C++11 %d1%82%d0%b5%d1%85%d0%bd%d0%be%d0%bb%d0%be%d0%b3%d0%b8%d0%b8

Move semantics explanation article.

C++11 features list.

Страницы:12345...10