[QUOTE=Alternative Account;44516721]Why... are you learning Perl as a beginner?[/QUOTE]
I've worked with Java and Python before but it's for Uni work.
[QUOTE=ExtReMLapin;44515695]Greetings,
Is there a cross-compiler to compile something to Linux-ARM from Windows ?
And, does it really works ?
Thanks.[/QUOTE]
There's probably not. My only suggestion is that you set up a Linux VM and use its tools.
[QUOTE=ashxu;44516659]programming beginner here but can anyone explain the following logic in perl?
If you have a text file with more than one line and you use split on it, printing $array[0] will print the entire first column, $array[1] second column etc. If you use a foreach loop it will properly print everything. I tried treating it as a two dimensional array but $array[0][0] will only print blank space.[/QUOTE]
[code]#!perl
my @array;
print("FILE:\n");
open (INFILE,"testfile") or die "Cannot open file\n";
while(<INFILE>)
{
chomp;
print "$_\n";
push(@array,[split(" ")]);
}
close(INFILE);
print "RANDOM ACCESS:\n";
print "$array[0][0]\n";
print "$array[1][1]\n";
print "$array[2][2]\n";
print "$array[3][0]\n";
[/code]
[quote]FILE:
one two three
four five six
seven eight nine
ten eleven tweleve
RANDOM ACCESS:
one
five
nine
ten
[/quote]
[editline]11th April 2014[/editline]
You're probably not writing to the array right. If I try to read it without splitting the input correctly then I get the same result as you. But if you try to read what's at $array[0] in my example then you get garbage output.
Just looking for some advice.
Doing a Multimedia technologies course, and for the assessment, we have to implement a general purpose lossless enoder and decoder, using some algorithm of our choosing. Has to be done in Java and it reads from the standard input, and gives standard output. Testing will be with a few kilobytes to tens of megabytes input, with test data in the form of various text types and uncompressed binary multimedia data.
Wondering, do any of you have experience in this field? Any recommendations for algorithms to look into etc
[QUOTE=Over-Run;44521629]Just looking for some advice.
Doing a Multimedia technologies course, and for the assessment, we have to implement a general purpose lossless enoder and decoder, using some algorithm of our choosing. Has to be done in Java and it reads from the standard input, and gives standard output. Testing will be with a few kilobytes to tens of megabytes input, with test data in the form of various text types and uncompressed binary multimedia data.
Wondering, do any of you have experience in this field? Any recommendations for algorithms to look into etc[/QUOTE]
You could implement [URL="https://www.youtube.com/watch?v=goOa3DGezUA"]LZ compression[/URL], it's super easy and gives good results for text.
Hi guys, Im trying to use SFML 2.1 to open a font. I used this code:
[CODE]
if(!font.loadFromFile("res\\arial.ttf")) // Set path to your font
{
return 1;
}
[/CODE]
When I hit the debug button in visual studio, it says that it cant open the file. However, when navigate to the .exe in windows explorer and open it there, everything works fine. What can I do to fix this? Thank you.
This shows my problem:
[IMG]http://i1369.photobucket.com/albums/ag202/magnolium1/Untitled1_zps9f25aaae.png[/IMG]
[IMG]http://i1369.photobucket.com/albums/ag202/magnolium1/Untitled_zps920a0815.png[/IMG]
The working directory when debugging is not "Box2d_SFM1/debug/" it's "Box2d_SFM1/Box2d_SFM1/"
It's like that so you don't have to place a copy in both /release/ and /debug/
[QUOTE=WinCat;44523537]The working directory when debugging is not "Box2d_SFM1/debug/" it's "Box2d_SFM1/Box2d_SFM1/"
It's like that so you don't have to place a copy in both /release/ and /debug/[/QUOTE]
Thank you so much, I had no idea. It worked after putting my res folder in Box2d_SFM1/Box2d_SFM1/ :smile:
[QUOTE=ExtReMLapin;44515695]Greetings,
Is there a cross-compiler to compile something to Linux-ARM from Windows ?
And, does it really works ?
Thanks.[/QUOTE]
I'm not sure if there are any binaries available but you should be able to build a cross compiler in Cygwin or maybe Mingw.
[QUOTE=sloppy_joes;44521194]You're probably not writing to the array right. If I try to read it without splitting the input correctly then I get the same result as you. But if you try to read what's at $array[0] in my example then you get garbage output.[/QUOTE]
My original code was similar to what you did except instead of using push all I did was use split on the text file and put it in an array.
Instead of
[code]push(@array,[split(" ")]);[/code]
I was doing
[code]@array = split(' ');[/code]
and then manipulating the array like that. I know what push does (puts the value you want to push at the end of the array) but what was wrong with what I was doing before?
My initial assumption was that it would be a one dimensional array so:
[quote]one two three
four five six[/quote]
Would be put into an array that looked like (one, two, three, four, five, six) but apparently not? Why does using push put the text file in a proper two dimensional array but directly putting it into an array give you a fucking mess?
Nonetheless, thank you for the response.
[quote]Would be put into an array that looked like (one, two, three, four, five, six) but apparently not? Why does using push put the text file in a proper two dimensional array but directly putting it into an array give you a fucking mess?[/quote]
because push and split basically splits each line up into n columns and 1 new row. afaik you essentially get
pseudo code:
[code]
for(<eachline>)
push ($array,"one","two","three")
[/code]
if that makes sense
so that makes it a proper 2D array as each line is then pushed onto a new row. the way you did it most likely just kept adding elements onto the 1D array, so you couldn't random access each element as if it were a 2D array.
Not sure what I'm doing wrong, trying to get the alpha on the screen but I get 1 every time. Using this to get the pixel values:
[cpp]double mouseX, mouseY;
glfwGetCursorPos(window, &mouseX, &mouseY);
float pixi[4];
glReadPixels(mouseX, WINDOW_HEIGHT-mouseY, 1,1,GL_RGBA, GL_FLOAT, &pixi);[/cpp]
pixi[3] is always 1 while the rest change as they should. I do have GL_BLEND enabled, my blend func is glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). I am clearing the color with an alpha of 1, however changing it has had no effect. I am writing to the default framebuffer with an alpha of 0.3.
Alright I figured out the issue. GLFW doesn't necessarily initiate the OpenGL context with an alpha buffer, so I had to set it myself.
[QUOTE=sloppy_joes;44535426]because push and split basically splits each line up into n columns and 1 new row. afaik you essentially get
pseudo code:
[code]
for(<eachline>)
push ($array,"one","two","three")
[/code]
if that makes sense
so that makes it a proper 2D array as each line is then pushed onto a new row. the way you did it most likely just kept adding elements onto the 1D array, so you couldn't random access each element as if it were a 2D array.[/QUOTE]
I see, thanks.
[QUOTE=bootv2;44542281]I'm playing with shader effects, and have a shader that I want to draw to a 120*100 pixel area.
The code(works on glsl sandbox)
[code]uniform vec2 resolution;
uniform float time;
#define PI 3.1414159265359
#define M 0.9
#define D 0.6
#define fmod 0.1
void main()
{
vec2 p = (gl_FragCoord.xy - 0.5* resolution) / min(resolution.x, resolution.y);
vec2 t = vec2(gl_FragCoord.xy / resolution);
vec3 c = vec3(0);
float y=0.;
float x=0.;
for(int i = 0; i < 35; i++) {
float t = float(i) * time * 0.8;
x = 1. * cos(0.005*t);
y = 1. * sin(t * 0.007);
vec2 o = 0.05 * vec2(x, y);
float r = fract(y+x);
float g = 1. - r;
c += 0.001 / (length(p-o)) * vec3(r, g, x+y);
}
gl_FragColor = vec4(c, 1);
}[/code]
The problem is that if I adjust the resolution to a #define resolution vec2(120, 100) to test it out. Nothing is drawn on the screen anymore, even when I make the effect fill the screen with vec2 o = 0.5 * vec2(x, y);
How can I restrict this effect to the 120*100 area I want it to be drawn in?[/QUOTE]
Vertex shader:
[CODE]#version 400
void main () {
//you might want to specify a specific region here... this is a fullscreen quad
const vec4 verts[4] = vec4[4](vec4(-1.0, -1.0, 0.5, 1.0),
vec4( 1.0, -1.0, 0.5, 1.0),
vec4(-1.0, 1.0, 0.5, 1.0),
vec4( 1.0, 1.0, 0.5, 1.0));
gl_Position = verts[gl_VertexID];
}[/CODE]
Fragment shader:
[CODE]#version 400
uniform sampler2D c_tex;
uniform vec3 ambient;
//the window size as input... you might want to use the same for the vertex shader
uniform vec2 win_size;
layout( location = 0 ) out vec4 frag_color;
void main () {
vec2 st;
st.s = gl_FragCoord.x / win_size.x;
st.t = gl_FragCoord.y / win_size.y;
vec4 c_texel = texture (c_tex, st);
frag_color.rgb = c_texel.rgb * ambient;
frag_color.a = 1.0;
}[/CODE]
For some reason this sometimes randomly skips an index, e.g. I can click on index 0 and it shows it, but when I click on index 1 it doesn't. Then I click on index 2 and it shows it again.
[code]
private void dgvTeams_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
txtPrizePool.Clear();
int selectedRow, selectedRowIndex;
selectedRowIndex = dgvTeams.CurrentCell.RowIndex;
txtPrizePool.Text = selectedRowIndex.ToString();
}
[/code]
[editline]14th April 2014[/editline]
And when I click on index 1 again it does show it.
[B][U]EDIT:[/U][/B]
I don't need a solution anymore since I just use 2 datatables to copy info from one view to another.
That shader code is so simple to read yet so fucking hard to write, it is like opposite of normal programming, where writing code is simple but hard to read.
Is there a list of really good general purpose C++ libraries somewhere? I just moved over from Java to C++ and just started using boost and have been very impressed so far.
QT :)
[CODE]
package yoloswag;
import java.util.Scanner;
/**
*
* @author cranberrysauce
*/
public class yoloswag {
/**
* @param args the command line arguments
*/
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Enter a phrase");
String phrase = keyboard.nextLine();
System.out.println("Enter a word in the phrase");
String word = keyboard.nextLine();
boolean found = find(phrase, word);
System.out.println(found);
}
public static boolean find(String phrase, String word) {
int i = 0;
String forward = "";
String backward = "";
try {
if (phrase.substring(0, phrase.length()).equals(word.substring(0, word.length()))) {
System.out.println("Phrase: \"" + phrase + "\"");
return true;
} else if (phrase.substring(i, word.length()).equals(word) && word.length() < phrase.length()) {
backward = phrase.substring(i);
System.out.println("Backwards: " + backward);
return find(phrase.substring(0, phrase.length() - 1), word);
} else {
i++;
forward = phrase.substring(i);
System.out.println("Forwards: " + forward);
return find(phrase.substring(i), word);
}
} catch (StringIndexOutOfBoundsException e) {
System.out.println(word + " could not be found");
return false;
}
}
}
[/CODE]
Testing recursion and wanted to know if this a good way to catch letters/words/whatever that don't work in the original phrase to be searched for. It goes through the recursive method searching for the phrase, then once it's finished disposing the phrase, it returns false. Is this alright?
I need some help with my graphics programming assignment. I thought I was cruising along fine until I found out that it doesn't draw some triangles due to an issue with either my drawing algorithm or my sorting algorithm.
The program starts with 3 defined points [B]a[/B],[B] b[/B] and [B]c[/B]. These points are of a triangle. They are sorted clockwise so that [B]a[/B] is the top, leftmost point, [B]b[/B] is the next point and [B]c[/B] is the last. The code for this function is this:
[code]void Core::sortTriVertices(Point &a, Point &b, Point &c)
{
// Flat Top
if (a.y == b.y && a.x < b.x) {
Point temp_b = b;
b = a;
a = temp_b;
}
// If point A has a higher Y value than point C, swap point A with point C
if(a.y > c.y) {
Point temp_a = a;
a = c;
c = temp_a;
}
// If point A has a higher Y value than point B, swap point A with point B
if(a.y > b.y) {
Point temp_a = a;
a = b;
b = temp_a;
}
// Sort
if(c.x > b.x) {
Point temp_c = c;
c = b;
b = temp_c;
}
if (a.y == c.y && a.x > c.x) {
Point temp_c = c;
c = a;
a = temp_c;
}
// Flat Bottom
if (b.y == c.y && b.x > c.x) {
Point temp_b = b;
b = c;
c = temp_b;
}
// Sort
if(c.x > b.x) {
Point temp_c = c;
c = b;
b = temp_c;
}
}[/code]
I believe the issue lies here as I haven't coded it as I was told to because I couldn't figure out how to do it properly (I've never worked much with angles and relating mathematics) but the sorting algorithm described was:
[quote]But if we pick the top point P1, and then compute the angle of line segments p1-p3 and p1-p2 with respect to the x-axis, then we can sort the vertices according to the angle, i.e. angle of segment p1-p3 will be less than that of segment p1-p2 if p3 is on the right and p2 on the left [/quote]
For the cases where the triangles sort correctly they will draw.
The full program is here, made in visual studio 2013, you can click around to change the locations of the points.
[url]https://www.dropbox.com/s/9wnc6j8iuxqtm5y/VS%202013.zip[/url]
The program is to draw a smooth shaded triangle in 2D (I'm supposed to end up transforming it into a 3D space, but I haven't gotten that far yet). The class has been given a 2 week extension on the assignment which is good because it was supposed to be due on Thursday this week and with what I have done it would be worth about 10% of the total marks.
[QUOTE=bootv2;44550701]I'm running into a very weird issue managing a players lives. This small snippet of code changes the address availableLives points to while I'm definitely calling *availableLives--. I'm not using multithreading so I'm positive it's this snippet that does this.
[code]if (*availableLives > 0)
{
std::cout << "availableLives before: " << availableLives << std::endl;
*availableLives--;
std::cout << "availableLives after: " << availableLives << std::endl;
ballContainer.at(i).velocity.y = -ballContainer.at(i).ballVelocity;
}[/code]
This is the result:
[img]http://i.gyazo.com/c5466c3b3fd67709b54ec18107c16cee.png[/img][/QUOTE]
Operator precedence. -- is applied before *. Add parenthesis.
I've put my first github repo up because someone wanted to use a bot I have set up on reddit. I cleaned up the code a lot, but i'm still a novice programmer.
Would anyone be willing to go through my code and see if there's anything wrong with it? I tried to make it clean and easy to understand.
[url]https://github.com/Andygmb/twitchy_the_bot/blob/master/twitchy.py[/url]
Could anyone tell me how you make something like this in C#. Just the flowchart.
[IMG]http://puu.sh/8b4hP.png[/IMG]
[QUOTE=rider695;44561723]Could anyone tell me how you make something like this in C#. Just the flowchart.
[IMG]http://puu.sh/8b4hP.png[/IMG][/QUOTE]
For logic:
Look at 'Graph theory'
[url]http://en.wikipedia.org/wiki/Graph_theory[/url]
And 'Trees':
[url]http://en.wikipedia.org/wiki/Tree_(graph_theory)[/url]
What's a good way to do text animation with java's swing components?
Not strictly something I need help with right now, but something that could help with something I had planned that would make things easier in the long run.
Would it be possible to generate a map of a network that a computer is connected to? For instance, could I see which devices are connected to a router, and if so how much information could I get about said devices in this way (such as device type, or any other information really). On top of this, if this was used on a large LAN with multiple routers (I think this is how large LANs function, can't say I know a whole lot about networking unfortunately), could I see how these are connected?
The idea is to create a node map of a network showing a parent node (router) and all of its connected children (devices), and any devices connected to those children, and any other routers that parent is connected to. I hope that makes sense, having trouble exactly putting what I'm thinking into words.Have a badly drawn example of what I wanted to be able to generate:
[IMG]http://i.imgur.com/zK8bd3M.png[/IMG]
[QUOTE=fylth;44569789]Not strictly something I need help with right now, but something that could help with something I had planned that would make things easier in the long run.
Would it be possible to generate a map of a network that a computer is connected to? For instance, could I see which devices are connected to a router, and if so how much information could I get about said devices in this way (such as device type, or any other information really). On top of this, if this was used on a large LAN with multiple routers (I think this is how large LANs function, can't say I know a whole lot about networking unfortunately), could I see how these are connected?
The idea is to create a node map of a network showing a parent node (router) and all of its connected children (devices), and any devices connected to those children, and any other routers that parent is connected to. I hope that makes sense, having trouble exactly putting what I'm thinking into words.Have a badly drawn example of what I wanted to be able to generate:
[IMG]http://i.imgur.com/zK8bd3M.png[/IMG][/QUOTE]
if you sniff wlan packets you can find out the device name, it's mac address, and if it is connected via lan or via wlan to the router.
If you are connected to the network you could simply trace the hops ?
on windows its tracert cmd.
But this will only give one route from your computer to the target.
Using junit and getting a very strange problem.
When the execution of the test suite hits a event dispatch instruction I make to a JFrame (the on closing event), the test suite simply quits without running any of the other tests or listing any errors or failures. And it definitely stops; it's not stuck in a loop or something, the thread says it's been terminated. On the junit results window the test in question simply displays a blue arrow (in eclipse), which I believe means the test is still going (but again, it's not, it even closes all the open windows under test).
Im trying to make a Minecraft Server with a functioning status ping in C#. Everything has been going fine-ish so far except I cant figure out how to send the IP of the server in the packets byte array and I have absolutely no idea how VarInts work and what their purpose is (I have read on the protocol wiki and its something to do with the length of the byte? Something to do with it being a prefix? If so, where would I put the VarInts?) and so far have only come across 2 examples of how a VarInt is generated which, because im clinically stupid, I still struggling to get the concept of.
First of all though, Im still very confused about the whole thing (im very stupid so bare with me). So far, for the packet structure I have this:
[code]byte[] sayThis = new byte[8054]; // Not the correct length, was unsure what to set it to, so I just set it really high just to be safe for now
sayThis[0] = (byte)0x00; // Packet ID, is that right?
sayThis[1] = (int) 4; // Protocol Version, is this correct?
sayThis[2] = myIP; // I still havent figured out how to convert an IP address into a byte. I know your supposed to have an array of bytes with segments of an IP but Im still stuck with that one some how
sayThis[3] = (ushort) 25565; // The port, this doesnt work though but I think I know how I can fix that, so this one isnt a problem
sayThis[4] = (int) 1; // Next state, for the status JSON on the next packet iirc
[/code]
Is that the correct structure for a status request packet? I put that together by reading this:
[url]http://wiki.vg/Server_List_Ping[/url]
Where would the VarInt go? Whats the point in VarInt? I really have no clue where they would go. Isnt their purpose to output the length of a byte? If so, where would the VarInt go?
Thanks!
[QUOTE=blacksam;44566097]What's a good way to do text animation with java's swing components?[/QUOTE]
Can't really say I know a "good" way, but you could manually do it with a loop, moving the coordinates of the button and use something like sleep to decide the speed of it
Sorry, you need to Log In to post a reply to this thread.