those aren't typos
[editline]20th April 2013[/editline]
but i put my shaders in my build folder, and here's what i get...
[code]Compiling shader textshader.vs...
Compiling shader textshader.fs...
0:5(19): error: syntax error, unexpected NEW_IDENTIFIER, expecting '{'
[/code]
textshader.fs is the same as the one i pasted above
sampler2D with upper-case D.
I'm slerping two quaternions and I'm noticing some contribution to the roll, even though both quaternions don't have any roll, is this to be expected?
[QUOTE=laylay;40360780]I'm slerping two quaternions and I'm noticing some contribution to the roll, even though both quaternions don't have any roll, is this to be expected?[/QUOTE]
I understood none of these words.
[QUOTE=laylay;40360780]I'm slerping two quaternions and I'm noticing some contribution to the roll, even though both quaternions don't have any roll, is this to be expected?[/QUOTE]
yes
Been trying to get started on a 2D topdowny game. I know that making a game is not just something that happens over night, but my issues is that I can't even get started! I've mocked about with SFML and looked at some general code for collision detection, but what I really need is a guy with as much experience as me(or more preferably!) to bounce ideas off of.
I know this isn't a Personals ad, but check my profile on here for my steam. Alternately my skype is corewarp.
Experience with SFML is not a must, experience with general game coding is not a must either!
So I was trying to start working on a simple app that uses a REST api but for some reason it doesnt let me make a URL objet
First attempt
[code]
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) {
String country = "ca";
String apikey = "";
String url = "http://api.rottentomatoes.com/api/public/v1.0/lists/movies/in_theaters.json?apikey=%s&country=%s";
url = String.format(url,apikey,country);
URL test = new URL(url); //Unhandled exception type MalformedURLException
}
}
[/code]
[code]
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) {
String country = "ca";
String apikey = "";
String url = "http://api.rottentomatoes.com/api/public/v1.0/lists/movies/in_theaters.json?apikey=%s&country=%s";
url = String.format(url,apikey,country);
try{ //Allright lets try to catch it so it shuts up
URL test = new URL(url);
}
catch (MalformedURLException e1) { // MalformedURLException cannot be resolved to a type
e1.printStackTrace();
}
}
}
[/code]
It forces me into try catching the URL constructor, but when I actually try catch it it tells me that the error does not exists
What am I doing wrong?
You need to import java.net.MalformedURLException for that to compile.
[QUOTE=superstepa;40365723]So I was trying to start working on a simple app that uses a REST api but for some reason it doesnt let me make a URL objet
First attempt
[code]
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) {
String country = "ca";
String apikey = "";
String url = "http://api.rottentomatoes.com/api/public/v1.0/lists/movies/in_theaters.json?apikey=%s&country=%s";
url = String.format(url,apikey,country);
URL test = new URL(url); //Unhandled exception type MalformedURLException
}
}
[/code]
[code]
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) {
String country = "ca";
String apikey = "";
String url = "http://api.rottentomatoes.com/api/public/v1.0/lists/movies/in_theaters.json?apikey=%s&country=%s";
url = String.format(url,apikey,country);
try{ //Allright lets try to catch it so it shuts up
URL test = new URL(url);
}
catch (MalformedURLException e1) { // MalformedURLException cannot be resolved to a type
e1.printStackTrace();
}
}
}
[/code]
It forces me into try catching the URL constructor, but when I actually try catch it it tells me that the error does not exists
What am I doing wrong?[/QUOTE]
You have no import for the exception.
[editline]21st April 2013[/editline]
goddammit
[QUOTE=ZeekyHBomb;40359871]Imma start with giving you a few pointers, so you might be able to figure it out by yourself.
Using a StringBuilder will make it easier to modify the current brute-forced word, so use that.
To generate the hash, do wordBuilder.toString().getBytes() and pass the result to the MessageDigest instance.
Create the StringBuilder with the [url=http://docs.oracle.com/javase/7/docs/api/java/lang/StringBuilder.html#StringBuilder(int)]StringBuilder(int capacity)[/url] constructor and pass in the length of the original word.
Loop wordBuilder.capacity() times and append 0's.
For the increment-logic, create a function taking the StringBuilder and an index. When calling it non-recursively the index should be 0, so it starts at the first character.
There you just get the char at the index, increment it, check if it's greater than '9', if so jump to 'a'.
If it's greater than 'z' you set the character to '0' and let the function call itself with index + 1, so it takes care of the next character. You're done then, so return.
If the character was not greater than 'z' you'll want to set the char at the index to your incremented value and return.
You might want to check if the index is greater than the length of the word (at the start of the function, before trying to access a char out of bounds); in that case, you've already tried all possible combinations.
To compare the hash values, use [url=http://docs.oracle.com/javase/7/docs/api/java/security/MessageDigest.html#isEqual(byte[%5D, byte[%5D)]MessageDigest.isEqual(a,b);[/url].[/QUOTE]
I think i'm on to something, but how would i convert string in to byte []
Can someone check this out?
[url]http://stackoverflow.com/questions/16125860/text-not-rendering-at-all-with-freetype[/url]
[QUOTE=ZeekyHBomb;40367206][url=http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#getBytes()]String.getBytes()[/url][/QUOTE]
Okay, i tried a little different approach. Yet my code does not work(it compiles thou). I' m running a program with an argument(331524e2951fc39b8cb187fa0752836aa70396df67- first number 3 is type of coding(SHA-1), second number is length of the word and the rest is coded word). Where am i wrong?
[code]
import java.util.*;
import java.io.UnsupportedEncodingException;
import javax.xml.bind.DatatypeConverter;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class dn07{
static char validChars[] = {'a','b','c','d','e','f','g','h','i','j','k','l',
'm','n','o','p','q','r','s','t','u','v','w','x','y','z',
'0','1','2','3','4','5','6','7','8','9'};
public static void main(String[] args) {
try{
String code = args[0];
String codecore = code.substring(2);
int type = code.charAt(0) - '0';
int maxlength = code.charAt(1) - '0';
if(type == 0 || type == 1){
MD5digest("", 1, maxlength, codecore);
}
if(type == 2 || type == 3){
SHA1digest("", 1, maxlength, codecore);
}
} catch(Exception exc){
System.out.print("Error");
}
}
static void MD5digest(String prefix, int level, int maxlength, String givenword) throws NoSuchAlgorithmException
{
for(char c : validChars){
if(level == maxlength){
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] hash = md.digest((prefix + c).getBytes());
Formatter formatter = new Formatter();
for (byte b : hash) {
formatter.format("%02x", b);
}
formatter.close();
System.out.println(formatter.toString());
byte[] hash2 = DatatypeConverter.parseHexBinary("1524e295");
try{
String decoded = new String(hash2, "UTF-8");
//if(MessageDigest.isEqual(hash2, givenword)){
if(decoded.equals(givenword)){
System.out.println(prefix + c);
break;
}
}
catch (UnsupportedEncodingException e) {
throw new AssertionError("Encoding error");
}
}
if(level < maxlength){
MD5digest(prefix + c, level+1, maxlength, givenword);
}
}
}
static void SHA1digest(String prefix, int level, int maxlength, String givenword) throws NoSuchAlgorithmException{
for(char c : validChars){
if(level == maxlength){
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] hash = md.digest((prefix + c).getBytes());
Formatter formatter = new Formatter();
for (byte b : hash) {
formatter.format("%02x", b);
}
formatter.close();
System.out.println(formatter.toString());
byte[] hash2 = DatatypeConverter.parseHexBinary("1524e295");
try{
String decoded = new String(hash2, "UTF-8");
//if(MessageDigest.isEqual(hash2, givenword)){
if(decoded.equals(givenword)){
System.out.println(prefix + c);
break;
}
}
catch (UnsupportedEncodingException e) {
throw new AssertionError("Encoding error");
}
}
if(level < maxlength){
SHA1digest(prefix + c, level+1, maxlength, givenword);
}
}
}
}
[/code]
How can i achieve a light effect like in this video using XNA? I wish to create a flashlight type lighting, so that you can only see what the flashlight lights up, everything else is black. The light does not have to be smooth. I prefer it to be very sharp.
[url]http://www.youtube.com/watch?v=SSRMerSOcTM[/url]
snip - got it
I have this simple idea of coding a lobby system, something very simple, tho I need some directions on where to find docs/what good libs are for:
TCP/IP Comm (receive .xml file for parsing, basic chatting, etc.)
DNS-SD (Find lobbies on local area network)
Any docs, examples, etc are welcome.
[QUOTE=RandomDexter;40368348][code] static char validChars[] = {'a','b','c','d','e','f','g','h','i','j','k','l',
'm','n','o','p','q','r','s','t','u','v','w','x','y','z',
'0','1','2','3','4','5','6','7','8','9'};[/code][/QUOTE]
Just to nitpick, I suggest you use [URL="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#toCharArray()"]String.toCharArray()[/URL] in the future as a slightly less tedious way of doing this.
[QUOTE=RandomDexter;40368348]Okay, i tried a little different approach. Yet my code does not work(it compiles thou). I' m running a program with an argument(331524e2951fc39b8cb187fa0752836aa70396df67- first number 3 is type of coding(SHA-1), second number is length of the word and the rest is coded word). Where am i wrong?
[code]//block of code[/code][/QUOTE]
In your *digest functions you compare against hash2 instead of hash.
You could make the code (and program input) easier if you just use multiple arguments.
This suggestion won't help fix your program though.
[code] public static void main(String[] args) {
if(args.length != 3){
printUsage();
System.exit(1);
}
try{
String hashAlgorithm = args[0];
int maxlength;
try {
maxlength = Integer.parseInt(args[1]);
}
catch (NumberFormatException e) {
printUsage();
System.exit(1);
}
String hashcode = args[2];
bruteForce(hashcode, MessageDigest.getInstance(hashAlgorithm), maxlength, 0, "");
} catch(Exception exc){
System.out.print("Error");
}
}[/code]
printUsage() should give the user instructions on how to invoke the program ("program-name MD5|SHA-1 word-length hash").
bruteForce is the "new" *digest - less code duplication.
In the original program description you said that you know the (exact) length of the word you're trying to brute force, however here you use it as the maximum length, allowing for the possibility of a shorter word. Which one is it?
Using a StringBuilder instead of String + char is a lot faster afaik.
[editline]21st April 2013[/editline]
[QUOTE=JohnnyOnFlame;40368849]I have this simple idea of coding a lobby system, something very simple, tho I need some directions on where to find docs/what good libs are for:
TCP/IP Comm (receive .xml file for parsing, basic chatting, etc.)
DNS-SD (Find lobbies on local area network)
Any docs, examples, etc are welcome.[/QUOTE]
What language and platform?
[QUOTE=RandomDexter;40355059]i have to make a program that takes MD5 or SHA1 coded word as an argument and then finds the right word with brute force attack, meaning that it tries all combinations of letters codes them and compares them to the given one. I also know the length of the word and the type of the coding. Can somebody help me[/QUOTE]
I actually decided to do a shitty implementation of this in Python:
[code]import hashlib, string, itertools
def hot_hollywood_hax(encrypted,
strlen,
algorithm,
chars=string.ascii_lowercase + string.digits):
algs = {hashlib.sha1: 'hashlib.sha1',
hashlib.md5: 'hashlib.md5'}
if algorithm not in algs.keys():
raise Exception('Algorithm must be one of: '
+ ', '.join(algs.values()))
for comb in itertools.product([c for c in chars], repeat=strlen):
if encrypted == algorithm(''.join(comb)).digest():
return ''.join(comb)
return None[/code]
Example usage with sha1 and md5:
[code]In [1]: import hollywoodhax as hh
In [2]: import hashlib as hl
In [3]: print hh.hot_hollywood_hax(hl.sha1('haxes').digest(), len('haxes'), hl.sha1)
haxes
In [4]: print hh.hot_hollywood_hax(hl.md5('haxes').digest(), len('haxes'), hl.md5)
haxes
[/code]
Took about 10 seconds with a length of 5, and too long for me to bother with a length of 6 -- just brute force being shit as always.
[editline]21st April 2013[/editline]
The complexity here is O(x^y) where x is length of valid characters and y is the length of the word.
That means a worst case of 60466176 iterations for length 5 and 2176782336 iterations for length 6. Yeah fuck that.
Python, how would you go about getting the sum of elements in different lists?
Assume lines = [[]]
lines[i] is [1, 2, 3, 4] and lines[j] is [5, 6, 7, 8]
How would you do this
[code]for i, j in zip(range(linecount-2, -1, -1), range(linecount-1, -1, -1)):
print max(sum(x, y for x in lines[i], y in lines[j]))
[/code]
(prints the max of the sums of elements)
[QUOTE=Meatpuppet;40370310]Python, how would you go about getting the sum of elements in different lists?
Assume lines = [[]]
lines[i] is [1, 2, 3, 4] and lines[j] is [5, 6, 7, 8]
How would you do this
[code]for i, j in zip(range(linecount-2, -1, -1), range(linecount-1, -1, -1)):
print max(sum(x, y for x in lines[i], y in lines[j]))
[/code]
(prints the max of the sums of elements)[/QUOTE]
Don't really know Python but couldn't you simply declare a variable, let's call it *s*, and then iterate through each sub-list, doing the same code you have there, adding it to s?
It would test
1+5
1+6
2+6
2+7
3+7
3+8
4+8
and see which one is the greatest.
[editline]21st April 2013[/editline]
automeeeerge
I'm not sure I get what you want to do here. Let's say you have two lists:
a = [1, 2, 3, 4]
b = [5, 6, 7, 8]
Do you want:
Max of all permutations? I.e. max([1+5, 1+6, 1+7, 1+8, 2+5, 2+6, 2+7, 2+8, 3+5, 3+6, 3+7, 3+8, 4+5, 4+6, 4+7, 4+8])
Or max of the zip? I.e. max([1+5, 2+6, 3+7, 4+8])?
If it's the former, it's very simple. You can simply do max(a) + max(b) and due to the magic of mathematics, you don't even need permutations.
If it's the latter, it's just max(x+y for x,y in zip(a, b)).
If it's neither, then I dunno.
I'm trying to get the max of all permutations such that that the numbers being added are down and to the right.
1+5 and 1+6
2+6 and 2+7
3+7 and 3+8
4+8
My attempt:
[code]a = [1, 2, 3, 4]
b = [5, 6, 7, 8]
def makeadder(x): return lambda y: x + y
def listadd(lx, y): return map(makeadder(y), lx)
def cons(a, b): return [a, b]
# create a list [[first, second], [second, third], ..., [last, None]]
addendlist = map(cons, b, b[1:])
# pop None from the last element
addendlist[len(addendlist) - 1].pop()
#add each of a to the corresponding pair in addlist and get the max
result = map(max, map(listadd, addendlist, a))[/code]
I couldn't find out how to chain function in Python, if that is possible. You could join max and listadd so you don't need two map's for the result.
[QUOTE=Meatpuppet;40370755]I'm trying to get the max of all permutations such that that the numbers being added are down and to the right.
1+5 and 1+6
2+6 and 2+7
3+7 and 3+8
4+8[/QUOTE]
You can do this with a one-liner. This assumes len(xs) == len(ys) >= 1:
[code]def maxperm(xs, ys):
return max(x + y for x, y in zip(xs, ys) + zip(xs[:-1], ys[1:]))[/code]
[QUOTE=Anonim;40371496]You can do this with a one-liner. This assumes len(xs) == len(ys) >= 1:
[code]def maxperm(xs, ys):
return max(x + y for x, y in zip(xs, ys) + zip(xs[:-1], ys[1:]))[/code][/QUOTE]
What if len(ys) is always going to be 1 more than len(xs)?
[QUOTE=Meatpuppet;40372281]What if len(ys) is always going to be 1 more than len(xs)?[/QUOTE]
Then you need to define your desired behaviour.
What happens with [1,2], [3,4,5]? I'm assuming max([1+3, 1+4, 2+4, 2+5]). In that case, still pretty simple:
[code]def maxperm(xs, ys):
return max(x + y for x, y in zip(xs, ys[:-1]) + zip(xs, ys[1:]))[/code]
[code]>>> xs, ys = range(1,5), range(5,10)
>>> xs, ys
([1, 2, 3, 4], [5, 6, 7, 8, 9])
>>> zip(xs, ys[:-1]) + zip(xs, ys[1:])
[(1, 5), (2, 6), (3, 7), (4, 8), (1, 6), (2, 7), (3, 8), (4, 9)]
>>> maxperm(xs, ys)
13[/code]
-snip- I'm tired :v: figured it out
[QUOTE=Killervalon;40376059]If we have a number - like 20
For each 5 it does X...
How? =P[/QUOTE]
Not sure what language but here, javascript:
[code]
var number = 20;
var times = number/5;
for(var i = 1; i <= times; i++) {
x(i);
}
function x(i) {
console.log("I did this " + i + " times!");
}
[/code]
[editline]22nd April 2013[/editline]
Too late to snip now!
Sorry, you need to Log In to post a reply to this thread.