The programmer's corner.

Please post computer issues here. We will try to help you. Also for showing off your PC.
Peter
The Cluckin' Godfather
Posts: 7056
Joined: Tue Aug 16, 2011 10:11 am
KCNR Username: Peter
Location: Hell
Status: Offline

Fri Feb 05, 2016 1:21 pm

Maybe you can draw over the images that is possible in some cases, bur I'm not sure. I would cut the images up in a ton of smaller ones (google maps does this).
Technically you could load smaller images into google maps (web version at least) and then use google maps to show polylines on this map.
Image

Want your own statistics counter? Look right here: viewtopic.php?f=25&t=1216
(Feature) introduction topic: viewtopic.php?f=25&t=28493
User avatar
iEatGroceries
Gangsta Clucker
Posts: 797
Joined: Mon Aug 24, 2015 5:51 pm
KCNR Username: iEatGroceries
Status: Offline

Sat Feb 06, 2016 3:22 am

Code: Select all

1.Button Maps_Button = (Button)findViewById(R.id.Maps_Button);
2.Maps_Button.setOnClickListener(new View.OnClickListener(){
3.         public void onClick(View v) {
4.                 //i have some code here
5.          }
6.});
I am getting a NullPointerException at the setOnClickListener part i.e Line 2. The Android Studio shows no error when I type the code, the id of the button is correct and it stops during runtime. I have also imported the button widget. Even the XML file is proper. What's wrong here?
I checked for solutions online but all the links say that there wasn't a declaration for the button. But I just declared it on Line 1.
Pls Help me
~~~MEMBER OF CLUCKYMINATI~~~
~~~INDIAN~~~
ImageImage
Peter
The Cluckin' Godfather
Posts: 7056
Joined: Tue Aug 16, 2011 10:11 am
KCNR Username: Peter
Location: Hell
Status: Offline

Thu Feb 11, 2016 10:16 pm

Moved anonymous v2's module code to it's own GIT repository.

https://git.pselten.info/peter/Anonymous


TO DO list:
https://git.pselten.info/peter/Anonymous/wiki/Todo
Image

Want your own statistics counter? Look right here: viewtopic.php?f=25&t=1216
(Feature) introduction topic: viewtopic.php?f=25&t=28493
Peter
The Cluckin' Godfather
Posts: 7056
Joined: Tue Aug 16, 2011 10:11 am
KCNR Username: Peter
Location: Hell
Status: Offline

Wed Mar 16, 2016 1:49 pm

Few bits of CUDA code.

Calculate the reverse complement strand:

Code: Select all

#include <stdio.h>

__global__ void do_reversecomplement(char *nucleotides, char *nucleotides_return){	
	int tid = threadIdx.x;
	int instances = (int)sizeof(nucleotides)/2;

	switch(nucleotides[tid]) {
		case 'A':
			nucleotides_return[instances-tid-1] = 'T';
			break;
		case 'T':
			nucleotides_return[instances-tid-1] = 'A';
			break;
		case 'C':
			nucleotides_return[instances-tid-1] = 'G';
			break;
		case 'G':
			nucleotides_return[instances-tid-1] = 'C';
			break;
	}
}

int main(void){
	char nucleotides1[4] = {'A','T','G','C'};
	int instances = (int)sizeof(nucleotides1);
	int size = instances * sizeof(char);
	char *nucleotides_return;
	char *d_nucleotides_return;
	char *d_nucleotides;

	//Allocate memory.
	nucleotides_return = (char *)malloc(size);
	cudaMalloc((void **)&d_nucleotides, size);
	cudaMalloc((void **)&d_nucleotides_return, size);
	
	//Copy nucleotides1 to d_nucleotides.
	cudaMemcpy(d_nucleotides, nucleotides1, size, cudaMemcpyHostToDevice);
	cudaMemcpy(d_nucleotides_return, nucleotides_return, size, cudaMemcpyHostToDevice);

	//Execute on 1 block with the amount of instances the array is.
	do_reversecomplement<<<1,instances>>>(d_nucleotides, d_nucleotides_return);
	
	//Copy d_nucleotides_return to nucleotides_return
	cudaMemcpy(nucleotides_return, d_nucleotides_return, size, cudaMemcpyDeviceToHost);

	//Display results
	printf("%s\n", nucleotides_return);

	// Cleanup
	cudaFree(d_nucleotides);
	cudaFree(d_nucleotides_return);
	free(nucleotides_return);
}
Simple Hello World in CUDA

Code: Select all

#include "cuPrintf.cu"
#include <stdio.h>

__global__ void device_greetings(void){	
	int tid = threadIdx.x;
	int bid = blockIdx.x;

	cuPrintf("Hello, world from the device!\n");
}

int main(void){
	// greet from the host
	printf("Hello, world from the host!\n");

	// initialize cuPrintf
	cudaPrintfInit();

	// launch a kernel with one block and one thread per block
	device_greetings<<<10,10>>>();

	// display the device's greeting
	cudaPrintfDisplay();

	// clean up after cuPrintf
	cudaPrintfEnd();

	return 0;
}

Simple math in CUDA, where 2 arrays are added to each other.

Code: Select all

#include <stdio.h>

__global__ void do_addition(int *num1, int *num2){	
	int tid = threadIdx.x;
	num1[tid] = num1[tid]+num2[tid];
}

int main(void){
	int array1[10] = {0,1,2,3,4,5,6,7,8,9};
	int array2[10] = {0,1,4,9,16,25,36,49,64,81};
	int *d_array1;
	int *d_array2;
	int *h_results;
	int instances = sizeof(array1)/sizeof(int);
	int size = instances * sizeof(int);

	//Allocate memory.
	cudaMalloc((void **)&d_array1, size);
	cudaMalloc((void **)&d_array2, size);
	h_results = (int *)malloc(size);

	//Copy array1 & array2 to d_array1 and d_array2.
	cudaMemcpy(d_array1, array1, size, cudaMemcpyHostToDevice);
	cudaMemcpy(d_array2, array2, size, cudaMemcpyHostToDevice);

	//Execute on 1 block with the amount of instances the array is.
	do_addition<<<1,instances>>>(d_array1,d_array2);
	
	//Copy d_array1 to h_results
	cudaMemcpy(h_results, d_array1, size, cudaMemcpyDeviceToHost);

	//Display results
	for (int i=0; i<instances; i++) printf("%d %d\n", i, h_results[i]);

 	// Cleanup
	cudaFree(d_array1);
	cudaFree(d_array2);
	free(h_results);

	return 0;
}
Image

Want your own statistics counter? Look right here: viewtopic.php?f=25&t=1216
(Feature) introduction topic: viewtopic.php?f=25&t=28493
wasay0029
Clucker
Posts: 226
Joined: Wed Dec 25, 2013 10:12 am
KCNR Username: Jackman
Status: Offline

Wed Mar 16, 2016 7:51 pm

Nice, try mentioning the language also always, it'll be helpful for me and others who aren't good at this.
Peter
The Cluckin' Godfather
Posts: 7056
Joined: Tue Aug 16, 2011 10:11 am
KCNR Username: Peter
Location: Hell
Status: Offline

Wed Mar 16, 2016 9:13 pm

wasay0029 wrote:Nice, try mentioning the language also always, it'll be helpful for me and others who aren't good at this.
I said it's CUDA :P
Image

Want your own statistics counter? Look right here: viewtopic.php?f=25&t=1216
(Feature) introduction topic: viewtopic.php?f=25&t=28493
wasay0029
Clucker
Posts: 226
Joined: Wed Dec 25, 2013 10:12 am
KCNR Username: Jackman
Status: Offline

Thu Mar 17, 2016 12:40 am

I'm stupid, nevermind
Fuet
Gangsta Clucker
Posts: 1968
Joined: Sun Dec 18, 2011 3:04 pm
KCNR Username: Fuet
Status: Offline

Thu Sep 08, 2016 6:40 pm

Changes current weather ID to number of ammo remaining in clip.

https://www.youtube.com/watch?v=MitvBH7a1do

I'm actually going to share the complete source code for this, it is extraordinarily lengthy, so be prepared.

Ready?
Spoiler!

Code: Select all

mov [00C81320], edx
Image
User avatar
Ragna
Gangsta Clucker
Posts: 1435
Joined: Sun May 24, 2015 3:05 pm
KCNR Username: Ragna
Location: Formerly known as Ragnarokk
Status: Offline

Thu Sep 08, 2016 7:11 pm

That looks awesome :O
and that code,too long man..
**Ragna**
**Part from
Majestic 12**
**From Bosnia and Herzegovina**

**Newcomer of the Year 2015**
**Deluxe Donator**


U SUX NONAME
[/size][/color]
Image
Image
User avatar
Aztec.is back
Gangsta Clucker
Posts: 1875
Joined: Fri Jul 17, 2015 6:40 am
KCNR Username: Aztec.
Status: Offline

Thu Sep 08, 2016 8:42 pm

Wow, Good one fuet! (that's why you never lose a race? Hmm) :D
it took me 1 hour ¼ to read that code
How do you know you are not a patient
Post Reply