Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


musafir2007

Member Since 23 Feb 2007
Offline Last Active Feb 23 2015 02:18 PM

Topics I've Started

Programmatically search .fla Flash file for imported component

17 February 2015 - 03:37 PM

Hi,

I have about 500 flash files that I need to search for various imported components.

There is a program called "Windows Grep", which is able to search through the fla and find the name of the component I am looking for, but searching is tedious since I have to do each one manually.

 

I am trying to do a simple search in C#, using

string fileContent = File.ReadAllText(@"C:\MyFile.fla");
richTextBox1.Text = fileContent;
 
but this just prints: ࡱ
 
I feel like this has to do something with encoding, but I am not sure how. Can someone help me with this.
 
Thanks,
Shivam

Is it possible to automatically download music in python

22 December 2014 - 02:32 PM

Hi, just curious what would it take to write a script in python to download music from say http://mp3skull.com/

I would just provide a list of [Song, Artist] and it would download them for me.

 

(ps. I am not trying to illegally download music, just curious ;)


Simple pictures organizer in C#

17 September 2014 - 10:20 PM

Hi all,

 

I have way too many pictures on my PC and they are everywhere. I am sure many of you have same problem.

I am attempting to create a simple program to organize them a bit and minimizing manual work, but unfortunately there will still be some.

 

Please take a look through this code and let me know if you have any suggestions. I am not very happy with how different pictures with same name is handled. How can I improve this code?

 

Thanks!

//Start Execution here...
private void startBtn_Click(object sender, EventArgs e)
{
	DirectoryInfo di = new DirectoryInfo("C:\\srcPictures");
	WalkDirectoryTree(di);
}

private void WalkDirectoryTree(System.IO.DirectoryInfo root)
{
	FileInfo[] files = null;
	DirectoryInfo[] subDirs = null;

	// First process files under root folder
	files = root.GetFiles("*.*");
	
	Logger("Processing Files under: " + root.FullName);

	if (files != null)
	{
		foreach (FileInfo fi in files)
		{
			string picTakenOn = getDateTaken(fi, false);
			string targetDir = "";

			if (picTakenOn.Contains("DATETAKEN"))
			{
				picTakenOn = picTakenOn.Replace("DATETAKEN", "");
				targetDir = "C:\\organizedPictures\\" + picTakenOn + "\\";
				if (!Directory.Exists(targetDir))
				{
					Directory.CreateDirectory(targetDir);
				}
				copyFileToDestination(fi, fi.FullName, targetDir + fi.Name);
			}
			else if (picTakenOn.Contains("DATEMODIFIED"))
			{
				picTakenOn = picTakenOn.Replace("DATEMODIFIED", "");
				targetDir = destDirectory.Text + "\\Sorted_DateModified\\" + picTakenOn + "\\";
				if (!Directory.Exists(targetDir))
				{
					Directory.CreateDirectory(targetDir);
				}
				Logger("DATEMODIFIED used instead of DATETAKEN for: " + fi.FullName);
				copyFileToDestination(fi, fi.FullName, targetDir + fi.Name);
			}
			else if (picTakenOn.Contains("INVALID"))
			{
				Logger("Not an image (Skipped): " + fi.FullName);
			}
		}

		// Resursion for all subdirectories
		subDirs = root.GetDirectories();
		foreach (System.IO.DirectoryInfo dirInfo in subDirs)
		{
			WalkDirectoryTree(dirInfo);
		}
	}
}

private void copyFileToDestination(FileInfo srcInfo, string sourcePath, string destPath)
{
	if (File.Exists(destPath)) //Same file name already exists
	{
		FileInfo destInfo = new FileInfo(destPath);
		if (srcInfo.Length != destInfo.Length) //If different images (check by filesize)
		{
			Logger("FILENAME conflict for: " + sourcePath);
			copyFileToDestination(srcInfo, sourcePath, destPath + "_dup" + srcInfo.Extension);
		}
		else
		{
			Logger("SKIPPED copy (Dup found) for: " + sourcePath);
		}
	}
	else
	{
		File.Copy(sourcePath, destPath);
	}
}

private string getDateTaken(FileInfo fi, bool includeDate)
{
	if (fi.Extension != ".jpeg" && fi.Extension != ".jpg" && fi.Extension != ".JPEG" && fi.Extension != ".JPG")
		return "INVALID";

	Regex r = new Regex(":");

	FileStream fs = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read);
	Image myImage = Image.FromStream(fs, false, false);

	try
	{
		PropertyItem propItem = myImage.GetPropertyItem(36867); //36867 is for Date taken
		string dateTaken = r.Replace(Encoding.UTF8.GetString(propItem.Value), "-", 2).Split(' ')[0];
		return ("DATETAKEN" + dateTaken.Split('-')[0] + "-" + dateTaken.Split('-')[1]);
	}
	catch
	{
		string dateModified = fi.LastWriteTime.ToString();
		return ("DATEMODIFIED" + dateModified.Split(' ')[0].Split('/')[2] + "-" + dateModified.Split(' ')[0].Split('/')[1]);
	}
}

public void Logger(String lines)
{
	//Set the log file
	string logFile = "C:\\organizedPictures\\log.txt";

	System.IO.StreamWriter file = new System.IO.StreamWriter(logFile, true);
	file.WriteLine(lines);

	file.Close();
}

got an interview with EA

10 March 2014 - 09:32 PM

Hi,

I have got a phone interview with EA in couple days. For this job

http://careersearch.ea.com/ca/burnaby/software-development/jobid4940612-software-engineer-i-ui-actionscript-ea-sports-fifa-jobs

 

My issue is that I have 2 years experience in Software testing and some development. But I have never worked on Games.. I did a openGL project in school but that's it.

I really want to this job and have always dreamed about working at EA.

Can someone give me any hints by looking at the description what I should concentrate on to prepare? thanks!


help with python - write class similar to defaultdict

31 October 2013 - 02:17 PM

http://docs.python.org/2/library/collections.html#collections.defaultdict

 

Hi, I am new to python and trying to write a class similar to to the defaultdict class.

I am little stuck on the constructor. On the python website example they first create a the defaultdict object with type as parameter, and then fill it. Example d = defaultdict(list) and then input "key,value"

 

If I directly pass "s" when creating object, it seems to be fine, but how can I make it similar to how it's really implemented. Thanks for help!

class MyDictionary(dict): #Parent class is "dict"
    'This is a derived class from python dict'
 
    def __init__(self, default_factory=None): # implement the parameters correctly
        dict.__init__(self, default_factory)
        #self.default_factory = default_factory
 
    #def anotherMethod-ToDo-forexmaple-d[10],handle if key doesn't exist
        
s = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)]
d = MyDictionary(list)
 
for k, v in s:
    d[k].append(v)
    
print (d.items())

PARTNERS