This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
void test(int *vet) | |
{ | |
printf("depois %lu\n", ( sizeof(vet)/ sizeof(vet[0])) ); | |
} | |
int main(int argc, char const *argv[]) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<gerep> andlabs, the element 0 is "g", 1 is "o", etc. When I do [1:4] it will return "g" as the element at position one because it counts the slice starting from zero. If I'm expecting the count to start from 0, the element at position 4 would be "n" and not "a" | |
<gerep> andlabs, and this way, for 4 to be "a", the slice count has to start from 1: position 1 = "g", 2 = "o", etc | |
<andlabs> the element at position 4 starting at 0 is n | |
<gerep> andlabs, yes! | |
<andlabs> ut that 4 is the first element /after the end of the slice/ | |
<andlabs> so you get everything from 1 /up to but not including/ 4 | |
<gerep> andlabs, yes, and why not use [1:3] ? | |
<gerep> andlabs, because the 1 is included but the 4 is not | |
<andlabs> because this type of coordinate specification is easier to reason about | |
<andlabs> how many elements are in the slice? 4-1=3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
type Validation struct { | |
Error string | |
OK bool | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
scores := []int{1,2,3,4,5} | |
scores = removeAtIndex(scores, 2) | |
} | |
func removeAtIndex(source []int, index int) []int { | |
source = append(source[:index], source[index+1:]...) | |
return source | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"log" | |
) | |
type ApiFunc func(w http.ResponseWriter, r *http.Request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = IO.binread("avatar.gif") | |
@parts = [] | |
f.each_char.each_slice(10000).each do |s| | |
@parts << s.join | |
end | |
@text = "" | |
@parts.each { |chunk| @text << chunk } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"bufio" | |
"net" | |
"io" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%dl | |
%dt=label :file, I18n.t("activerecord.attributes.app.file_label") | |
%dd | |
=f.file_field :file | |
%small.block=form_field_message("app", "file", @version.errors[:file]) | |
%dl | |
%dt=label :signature, I18n.t("activerecord.attributes.app.file_label") | |
%dd | |
=f.file_field :signature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
validate_license([License|Host]) -> | |
rpc:call(list_to_atom(string:concat("riak@", string:join(Host, ","))), | |
walk, | |
check_license, | |
[0,0,[License]]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@n = 3 | |
@sequence = '0 8 12'.split(' ').map(&:to_i).sort | |
def ratio | |
(@sequence[-1] - @sequence[0])/@n.to_i | |
end | |
def missing(n, sequence, diff) | |
numbers = [] | |
n.times do |c| |