Joined February 2013
·

Dustin

Netzkern
·
germany
·

Posted to Using .Any to optimize linq queries. over 1 year ago

What´s the background of this benefit? Why does this work?

I don´t understand you article because .data() and .attr() have different goals and can´t compete. With the data() function you can write and read user defined HTML5 data-* Attributes and with the attr() function you can write and read an "normal" attribute of an element.

.data("*") shorthand for .attr("data-*")

Your comparison should be:

.prop() VS attr()

It´s just a variable assignement. It should be clear that $(<selection>) executes every time a new query on the DOM.

Seriously? then you can also use this. In my opinion one more nice-looking.

#define InfiniteLoop for(;;)
InfiniteLoop {

}

Sorry @Ivan Đurđevac but this method is even more elegant ^^

while (sleep 5 && php /home/user/desktop/test.php) &
do
wait $!
done

I have not much knowledge about linux shell scripting but with some minutes i found out that there are many things you must know before you use it as cron alternative:

  1. Your Script execute in the main shell process so the shell is completely blocked I think cause the semicolon behind the while statement (In my case restart was necessary)
  2. To ensure that the job execute in a subshell you must use the & for executing the command asynchronously but you must also wait for this subprocess with ẁait $!

This works nice:

while [ 1 ]
do
(sleep 5 && php /home/Username/Desktop/test.php) &
wait $!
done

Use more secure method (sleep 15 && command ...) & to ensure that the interval is finished and use & for executing the command asynchronously in a subshell.

Posted to forget !important over 1 year ago

CSS selectors are classified according to his significance so a selector which selected an element by ID has an higher significance as a selector which only selected an element by a class. In the case of when the significance is the same and you don´t want/can change the data you must use the !important statement i.e third party plugins which dont´t know the environment.

But you´re right the use of !important make the hierarchical order of your css statements unpredictable and less elegant.

Posted to Pass Go slices as C array parameters over 1 year ago

@ysgard strange that I don´t get any notifiaction about comments sry. A Slice is always just a reference to an array with a length and a capacity so the overhead is very small. In this case &intSlice referenced to the Slice not to the underlying Array. By the reason that a Slice ist just a reference to the Array the first element of a Slice &intSlice[0] is the first Element of the underlying Array (without reslicing) and so the start address of the Array.

var c int = 1

intSlice := []int{100, 1, 2, 3, 4}
newSlice := intSlice[c:]


fmt.Printf("Points to the Slice %p\n",&intSlice) //0xc20005d020
fmt.Printf("Points to the first Element of the underlying Array: %d\n",&intSlice[0]) //833223995872


//Important!!!!!!!!
fmt.Printf("Points to the newSlice first Element and not to the Array: %d\n",&newSlice[0]) //833223995880
fmt.Printf("%v",newSlice[0]) //0


ref := reflect.ValueOf(newSlice)
t := reflect.TypeOf(newSlice)

//Start address of the underlying Array. But that´s critical in my opinion.
addr := int(ref.Pointer()) - (t.Align() * c) //833223995872

fmt.Printf("Addr of the underlying data: %d\n",addr) //833223995872

underArray := (*[5]int)(unsafe.Pointer(uintptr(addr)))
fmt.Println( *underArray ) //[100 1 2 3 4]
Posted to javascript: string to int over 1 year ago

That´s an explicit type conversion to int by the interpreter cause the double NOT bitwise operator. Bitwise operators can be used only on number values. The parseInt() function is the right choice.

Good job :) But why the transfer of python parts in C-Code ? Are such speed improvements for an SASS's SCSS -compiler really essential ?

Posted to Pass Go slices as C array parameters over 1 year ago

yes, the reason is here:

struct Slice
    {   // must not move anything
        byte*   array;      // actual data
        uint32  len;        // number of elements
        uint32  cap;        // allocated number of elements
   };
Posted to Object-like C structs over 1 year ago

When I try your example I get this error (gcc):
((base_struct)s).value = 37; // "conversion to non-scalar type requested"

This solution works (with same structs):

sub_struct s;
s.value2 = 13;

base_struct *b;
b = ((base_struct*) &s);
b->value = 43;


printf("%d\n",b->value); //print 43
printf("%d\n",s.value2); //print 13

printf("%p\n",&s); //Points to super base_struct
printf("%p\n",&s.super); //Points to super base_struct
printf("%p\n",&b);
printf("%d",s.super.value); // 43
Posted to Object-like C structs over 1 year ago

Reminds me of the Go type-system:


type Base struct {}
type Sub struct {  Base  } //type embedding

http://starp-germany.de/blog/go-specials/

Posted to Easier Java object initialization over 1 year ago

At first sight I thought it is a magic feature but it´s just an anoynmous inner class with an initialization block. You can add double braces so much as you like. Intersting is the fact that initializers are run before constructors but not before superclass constructors.

Achievements
135 Karma
20,950 Total ProTip Views