Search Results

Search found 1226 results on 50 pages for 'jack flynn'.

Page 5/50 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Hosts file in Apache keep changing for OS Linux Redhat [on hold]

    - by jack f
    I have installed Apache server. Two clients ex client_1 and client_2. The operation that we are performing on client_1 reflecting to client_2. We have etc/hosts file in our software install location which is keep on changing for client_2 with client_1 IP address. If I correct the entries in hosts file to client_2 also in the next few minuets it is changing automatically to the client_1(if we start the client_1 service). Please explain the use of hosts file and where and when it will change by Apache service. The hosts file in the location /etc/hosts/ for the both clients are same ============================================= Do not remove the following line, or various programs that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost Local LAN 190.0.0.1 client_1.Example.com client_1 190.0.0.2 client_2.Example.com client_2 HR LAN 10.1.74.2 client_1hr peer 10.1.74.3 client_2hr ESP LAN 10.69.69.1 client_1esp 10.69.69.2 client_2esp Any help will be appreciated. Thanks in advance, Jack F

    Read the article

  • How to rewrite using htaccess if the file exists in another folder?

    - by Jack
    We are trying to rewrite to another folder if the file does not exist in the document root, but does exist in the other folder. The other folder is in a completely different location, which is located using "Alias" in the vhosts. So, what we have so far (from this post How to rewrite URI from root if file exists in folder?) is: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !^/legacy/ RewriteRule ^(.*)$ legacy/$1 [QSA,L] This works to an extent, but seems to direct everything to the legacy folder, not just when the file doesn't exist in the first location and does exist in legacy. Thanks in advance for any help, Jack.

    Read the article

  • Problems when loop over a series of ssh-ed commands

    - by Jack Medley
    I have a series of server machines which I want to run the same command on. Each command takes hours and (even though I am running the commands using nohup and setting them to run in the background) I have to wait for each to finish before the next starts. Here is roughly how I have set it up: On the host machines: for i in {1..9}; do ssh RemoteMachine${i} ./RunJobs.sh; done Where RunJobs.sh on each remote machine is: source ~/.bash_profile cd AriadneMatching for file in FileDirectory/Input_*; do nohup ./Executable ${file} & done exit Does anyone know of a way such that I dont have to wait for each job to finish before the next starts? Or alternatively a better way of doing this, I have a feeling what I am do is fairly sub-optimal. Cheers, Jack

    Read the article

  • Catch headset pause/play keypresses in Windows

    - by akshay2000
    I have a new Ultrabook which has single audio jack for input and output instead for separate 3.5 mm jacks we used to have on older machines. The jack is probably similar to American Audio Jack specification or like the one found on Macbook Pro. I have tried to use it with the Apple, HTC, Nokia earphones which ship with most of the smartphones. Microphone on the headset works the way it should. Thing is that the headsets also come with remote controls to control volume and playback. I am sure that those key presses are sent to the Windows. I was hoping to catch those events and bind those to actual media keys so that I can control music playback. I guess this happens on Macs. I want to do the similar thing on the Windows. I'm just not sure where I can catch the events. Driver level? Application level?

    Read the article

  • Limit WebClient DownloadFile maximum file size

    - by Jack Juiceson
    Hi everyone, In my asp .net project, my main page receives URL as a parameter I need to download internally and then process it. I know that I can use WebClient's DownloadFile method however I want to avoid malicious user from giving a url to a huge file, which will unnecessary traffic from my server. In order to avoid this, I'm looking for a solution to set maximum file size that DownloadFile will download. Thank you in advance, Jack

    Read the article

  • iPhone text editor syntax highlight

    - by Jack
    Hi, As the title suggests, I am trying to add a text editor with syntax highlighting to a project. I have asked a similar question before and got pointed in the direction of either: a) a UITextView and NSAttributedStrings Or b) a web view Can anyone shed some light on using either of These methods or suggest an alternative? I have searched around for a few hours now and have found nothing. Jack

    Read the article

  • Python. How to iterate through a list of lists looking for a partial match

    - by Becca Millard
    I'm completely stuck on this, without even an idea about how to wrap my head around the logic of this. In the first half of the code, I have successfully generation a list of (thousands of) lists of players names and efficiency scores: eg name_order_list = [["Bob", "Farley", 12.345], ["Jack", "Donalds", 14.567], ["Jack", "Donalds", 13.421], ["Jack", "Donalds", 15.232],["Mike", "Patricks", 10.543]] What I'm trying to do, is come up with a way to make a list of lists of the average efficiency of each player. So in that example, Jack Donalds appears multiple times, so I'd want to recognize his name somehow and average out the efficiency scores. Then sort that new list by efficiency, rather than name. So then the outcome would be like: average_eff_list = [[12.345, "Bob", "Farley"], [14.407, "Jack", "Donalds"], [10.543, "Mike", "Patricks"]] Here's what I tried (it's kind of a mess, but should be readable): total_list = [] odd_lines = [name_order_list[i] for i in range(len(name_order_list)) if i % 2 == 0] even_lines = [name_order_list[i] for i in range(len(name_order_list)) if i % 2 == 1] i = 0 j = i-1 while i <= 10650: iteration = 2 total_eff = 0 while odd_lines[i][0:2] == even_lines[i][0:2]: if odd_lines[i][0:2] == even_lines[j][0:2]: if odd_lines[j][0:2] != even_lines[j][0:2]: total_eff = even_lines[j][2]/(iteration-1) iteration -= 1 #account fr the single (rather than dual) additional entry else: total_eff = total_eff if iteration == 2: total_eff = (odd_lines[i][2] + even_lines[i][2]) / iteration else: total_eff = ((total_eff * (iteration - 2)) + (odd_lines[i][2] + even_lines[i][2])) / iteration iteration += 2 i += 1 j += 1 if i > 10650: break else: if odd_lines[i][0:2] == even_lines[j][0:2]: if odd_lines[j][0:2] != even_lines[j][0:2]: total_eff = (odd_lines[i][2] + even_lines[j][2]) / iteration else: total_eff = ((total_eff * (iteration -2)) + odd_lines[i][2]) / (iteration - 1) if total_eff == 0: #there's no match at all total_odd = [odd_lines[i][2], odd_lines[i][0], odd_lines[i][1]] total_list.append(total_odd) if even_lines[i][0:2] != odd_lines[i+1][0:2]: total_even = [even_lines[i][2], even_lines[i][0], even_lines[i][1]] else: total = [total_eff, odd_lines[i][0], odd_lines[i][1]] total_list.append(total) i += 1 if i > 10650: break else: print(total_list) Now, this runs well enough (doesn't get stuck or print someone's name multiple times) but the efficiency values are off by a large amount, so I know that scores are getting missed somewhere. This is a problem with my logic, I think, so any help would be greatly appreciated. As would any advice about how to loop through that massive list in a smarter way, since I'm sure there is one... EIDT: for this exercise, I need to keep it all in a list format. I can make new lists, but no using dictionaries, classes, etc.

    Read the article

  • iPhone app distribution: What name will appear on the AppStore?

    - by Jack Griffiths
    Hi there, Is there a way to change the name that displays on the AppStore, rather than the name associated with the credit card/apple ID associated with the developer programme? For example, if my name on my credit card was foo, and the name on the apple ID was foo, but I actually want the name displayed on the AppStore (i.e. next to my App's name and details) to be bar. BTW: The programme is individual. Many thanks, Jack

    Read the article

  • Excel VBA Text To Column

    - by Pat
    This is what I currently have: H101 John Doe Jane Doe Jack Doe H102 John Smith Jane Smith Katie Smith Jack Smith And here is what I want: H101 John Doe H101 Jane Doe H101 Jack Doe H102 John Smith H102 Jane Smith H102 Katie Smith H102 Jack Smith Obviously I want to do this on a bigger scale. The number of columns is between 1 & 6, so I cant limit it that way. I was able to get a script that allows me to put each individual on one row. However, I am having a hard time getting the first column to copy over to each row. Sub ToOneColumn() Dim i As Long, k As Long, j As Integer Application.ScreenUpdating = False Columns(2).Insert i = 0 k = 1 While Not IsEmpty(Cells(k, 3)) j = 3 While Not IsEmpty(Cells(k, j)) i = i + 1 Cells(i, 1) = Cells(k, 1) //CODE IN QUESTION Cells(i, 2) = Cells(k, j) Cells(k, j).Clear j = j + 1 Wend k = k + 1 Wend Application.ScreenUpdating = True End Sub Like I said, it was working fine to get everyone each on their own row, but can't figure out how to get that first column. It seems like it should be so simple, but it's bugging me. Any help is greatly appreciated.

    Read the article

  • save xml object so that elements are in sorted order in saved xml file

    - by scot
    Hi , I am saving a xml document object and it is saved in a xml file as shown below . <author name="tom" book="Fun-II"/> <author name="jack" book="Live-I"/> <author name="pete" book="Code-I"/> <author name="jack" book="Live-II"/> <author name="pete" book="Code-II"/> <author name="tom" book="Fun-I"/> instead i want to sort the content in document object so that when i persist the object it is saved by grouping authors then book name as below: <author name="jack" book="Live-I"/> <author name="jack" book="Live-II"/> <author name="pete" book="Code-I"/> <author name="pete" book="Code-II"/> <author name="tom" book="Fun-I"/> <author name="tom" book="Fun-II"/> I use apache xml beans..any ideas on how to achieve this? thanks.

    Read the article

  • PHP - post data ends when '&' is in data.

    - by Phil Jackson
    Hi all, im posting data using jquery/ajax and PHP at the backend. Problem being, when I input something like 'Jack & Jill went up the hill' im only recieving 'Jack' when it gets to the backend. I have thrown an error at the frontend before that data is sent which alerts 'Jack & Jill went up the hill'. When I put die(print_r($_POST)); at the very top of my index page im only getting [key] => Jack how can I be loosing the data? I thought It may have been my filter; <?php function filter( $data ) { $data = trim( htmlentities( strip_tags( mb_convert_encoding( $data, 'HTML-ENTITIES', "UTF-8") ) ) ); if ( get_magic_quotes_gpc() ) { $data = stripslashes( $data ); } //$data = mysql_real_escape_string( $data ); return $data; } echo "<xmp>" . filter("you & me") . "</xmp>"; ?> but that returns fine in the test above you &amp; me which is in place after I added die(print_r($_POST));. Can anyone think of how and why this is happening? Any help much appreciated. Regards, Phil.

    Read the article

  • Troubleshoot dropped wireless connections

    - by Jack
    I was recently hired in the IT department of a small company (~180 users) and one of the issues that people have been complaining about is having their wi-fi connections drop during meetings. The company is using an HP ProCurve Wireless LAN with 10 APs and a controller unit located in the server room. I don't have any experience troubleshooting WLAN in a multi-AP environment, so I'm trying to at least gather information using free or cheap tools. I did a basic site survey using the free version of Ekahau HeatMapper and discovered the following in one of the conference rooms that has been a problem. The program picked up three access points (plus a bunch of others with much lower signals that were out of range): AP 1: SSID: "Unknown SSID" - Signal strength: -48 dBm - -40 dBm. Channel: 2 AP 2: SSID "CompanyMain" - Signal strength: -35 dBm or greater. Channel: 2. Security: WEP (This is the main SSID for the company's WLAN.) AP 3: SSID: "CompanyGuest" - Signal strength: -40 dBm - -35 dBm. Channel: 2. Security: WPA2 (This SSID is the company's "guest" WLAN, which was setup to allow Internet access, but prevent network access.) Is there anything that you see that is clearly a problem from the above? I'm assuming that the unknown SSID might be a big problem, and that it is an AP from a neighboring office that is causing interference. Does that seem likely? Also, regarding channel, should we try changing the channels of our APs to avoid interference with that unknown SSID? (Since everything seems to be on Channel 2?) Should our APs be on different channels? In other words, should the CompanyMain and CompanyGuest APs be on different channels? Finally, any recommendations for free/cheap tools to help me figure this out, and/or a good methodology to follow? Thanks in advance for any help. Jack

    Read the article

  • Parallels Plesk returning strange numbers

    - by Jack W-H
    Hi everyone, As a relatively new Server Admin I've become a bit confused by some statistics Parallels Plesk Panel 10.0.1 is returning to me. I have a domain ('subscription') set up, mysite.com. Mysite.com only hosts files, mostly images Its file contents use up about 390MB of disk space Here's a screenshot: this is what Plesk is reporting mysite.com to use: And some more info: Now this is pretty confusing... I thought at first my site might have been hacked and had contents written to disk, but I checked and all is in order, nothing has been hacked into as far as I can tell. So I had a look in the site's CP for some more in-depth statistics, and this is what's returned... Now - sod's law - when I go to check my disk space statistics in more depth via the control panel, this morning it says "The data were not collected yet." - not too sure what that means, but, last night when I checked it was reporting something odd. It said Files were using up 390MB, but 1.80GB or so were being used up by 'Mail Accounts'. This is really strange, as there are no mail accounts set up for the domain. The only hint of 'mail' there is, is the catchall set up to forward *@mysite.com to a separate, ISP-hosted email account. Any ideas anybody? I can post more details if you need it. Sorry to be a bit vague but I'm not sure what else I can post. Thanks, Jack

    Read the article

  • Why Does Private Access Remain Non-Private in .NET Within a Class?

    - by AMissico
    While cleaning some code today written by someone else, I changed the access modifier from Public to Private on a class variable/member/field. I expected a long list of compiler errors that I use to "refactor/rework/review" the code that used this variable. Imagine my surprise when I didn't get any errors. After reviewing, it turns out that another instance of the Class can access the private members of another instance declared within the Class. Totally unexcepted. Is this normal? I been coding in .NET since the beginning and never ran into this issue, nor read about it. I may have stumbled onto it before, but only "vaguely noticed" and move on. Can anyone explain this behavoir to me? Am I doing something wrong? I found this behavior in both C# and VB.NET. The code seems to take advantage of the ability to access private variables. Sincerely, Totally Confused Class Foo Private _int As Integer Private _foo As Foo Private _jack As Jack Private _fred As Fred Public Sub SetPrivate() _foo = New Foo _foo._int = 3 'TOTALLY UNEXPECTED _jack = New Jack '_jack._int = 3 'expected compile error because Foo doesn't know Jack _fred = New Fred '_fred._int = 3 'expected compile error because Fred hides from Foo End Sub Private Class Fred Private _int As Integer End Class End Class Class Jack Private _int As Integer End Class

    Read the article

  • Android Signal analysis + some filters.

    - by Profete162
    Hello, as the world cup is the main sport event and the Vuvuzelas are the most annoying sound in the world, I had an idea to remove them definitively by reading this new ( http://www.popsci.com/diy/article/2010-06/simple-software-can-filter-out-vuvuzela-whine) that told us that the sound has some frequencies at 233Hz + 466,932,1864Hz. I have already made a lot of Android application by myself but never touching the signal analysis and filtering part, so here are a few questions, I do not ask for precise answer but maybe links and tutorial to find something to work on. I guess that a new Android phone has the CPU and power to make real-time filtering. 1) How can I intercept the sound coming from the Jack microphone - Line-IN plug- ( I plan to link my TV to my phone with Jack to Jack plug). My question is totally software and coding, I have all the wires and adapters to plug a jack into my android phone Line IN. 2) Are there some Fourier analysis librairies, may I have a look to Java libraries on the web and import them to my Android project? I really apologize because my question seem not precise, but I think that would be something great. Thank you for your answers.

    Read the article

  • Make a radio-streaming PC pretend to be a mass-storage USB device

    - by monov
    I'm listening to a net radio on my PC I want the sound to go through my boombox cause it has nice speakers/amp The boombox has no "incoming" audio jack that just plays what comes over the wire However the boombox has a USB jack where you can put a thumbdrive with music. The question: How do I make the PC pretend to be a mass-storage device, and dynamically send all received audiodata to the boombox over a symmetric male USB cable? Failing that, at least tell me how to do it for local files (rather than streams). OS: Vista

    Read the article

  • Front panel audio replacement

    - by develroot
    I have experienced some problems with my headphones and it turned out the front 3.5mm audio jack is defective..and it doesn't make a good contact. I can't replace the jack because it's built-in. I am wondering if there are such things as "modular" Front panels to be inserted into the available external 3.5" bay and, of course, to support (natively, internal connector) Realtek HD Audio. (my case is Asus TA-K5, but I guess it doesn't make any difference)

    Read the article

  • Eliminate horizontal scrolling in div in favor of horizontal scrolling in browser window

    - by Casey Flynn
    I have a div, set to 800px wide, that will automatically scroll horizontally if the browser window is resized to < 800px. The behavior I would like, is to have the browser window scroll instead of the div. It would seem simple but for some reason I'm getting hung up on it. Any ideas? The page in question: http://www.caseyflynn.com/game/ The div CSS: div#main_container { border: 1px solid #FFF; width:800px; margin-left:auto; margin-right:auto; padding:0px; background-color:#FFF; overflow:hidden; } The BODY CSS: html, body { background-color:#000; border:0px; margin:0px; padding:0px; font-family : Arial, Helvetica, sans-serif; font-size : 62.5%; overflow:auto; } I'm assuming anyone looking at this will have the ability to see the HTML and the CSS. Thanks!

    Read the article

  • add a from to backup routine

    - by Gerard Flynn
    hi how do you put a process bar and button onto this code i have class and want to add a gui on to the code using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; using System.IO; using System.Threading; using Tamir.SharpSsh; using System.Security.Cryptography; using ICSharpCode.SharpZipLib.Checksums; using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.GZip; namespace backup { public partial class Form1 : Form { public Form1() { InitializeComponent(); } /// <summary> /// Summary description for Class1. /// </summary> public class Backup { private string dbName; private string dbUsername; private string dbPassword; private static string baseDir; private string backupName; private static bool isBackup; private string keyString; private string ivString; private string[] backupDirs = new string[0]; private string[] excludeDirs = new string[0]; private ZipOutputStream zipOutputStream; private string backupFile; private string zipFile; private string encryptedFile; static void Main() { Backup.Log("BackupUtility loaded"); try { new Backup(); if (!isBackup) MessageBox.Show("Restore complete"); } catch (Exception e) { Backup.Log(e.ToString()); if (!isBackup) MessageBox.Show("Error restoring!\r\n" + e.Message); } } private void LoadAppSettings() { this.backupName = System.Configuration.ConfigurationSettings.AppSettings["BackupName"].ToString(); this.dbName = System.Configuration.ConfigurationSettings.AppSettings["DBName"].ToString(); this.dbUsername = System.Configuration.ConfigurationSettings.AppSettings["DBUsername"].ToString(); this.dbPassword = System.Configuration.ConfigurationSettings.AppSettings["DBPassword"].ToString(); //default to using where we are executing this assembly from Backup.baseDir = System.Reflection.Assembly.GetExecutingAssembly().Location.Substring(0, System.Reflection.Assembly.GetExecutingAssembly().Location.LastIndexOf("\\")) + "\\"; Backup.isBackup = bool.Parse(System.Configuration.ConfigurationSettings.AppSettings["IsBackup"].ToString()); this.keyString = System.Configuration.ConfigurationSettings.AppSettings["KeyString"].ToString(); this.ivString = System.Configuration.ConfigurationSettings.AppSettings["IVString"].ToString(); this.backupDirs = GetSetting("BackupDirs", ','); this.excludeDirs = GetSetting("ExcludeDirs", ','); } private string[] GetSetting(string settingName, char delimiter) { if (System.Configuration.ConfigurationSettings.AppSettings[settingName] != null) { string settingVal = System.Configuration.ConfigurationSettings.AppSettings[settingName].ToString(); if (settingVal.Length > 0) return settingVal.Split(delimiter); } return new string[0]; } public Backup() { this.LoadAppSettings(); if (isBackup) this.DoBackup(); else this.DoRestore(); Log("Finished"); } private void DoRestore() { System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog(); fileDialog.Title = "Choose .encrypted file"; fileDialog.Filter = "Encrypted files (*.encrypted)|*.encrypted|All files (*.*)|*.*"; fileDialog.InitialDirectory = Backup.baseDir; if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //string encryptedFile = GetFileName("encrypted"); string encryptedFile = fileDialog.FileName; string decryptedFile = this.GetDecryptedFilename(encryptedFile); //string originalFile = GetFileName("original"); this.Decrypt(encryptedFile, decryptedFile); //this.UnzipFile(decryptedFile, originalFile); } } //use the same filename as the backup except replace ".encrypted" with ".decrypted.zip" private string GetDecryptedFilename(string encryptedFile) { string name = encryptedFile.Substring(0, encryptedFile.LastIndexOf(".")); name += ".decrypted.zip"; return name; } private void DoBackup() { this.backupFile = GetFileName("bak"); this.zipFile = GetFileName("zip"); this.encryptedFile = GetFileName("encrypted"); this.DeleteFiles(); this.zipOutputStream = new ZipOutputStream(File.Create(zipFile)); try { //backup database first if (this.dbName.Length > 0) { this.BackupDB(backupFile); this.ZipFile(backupFile, this.GetName(backupFile)); } //zip any directories specified in config file this.ZipUserSpecifiedFilesAndDirectories(this.backupDirs); } finally { this.zipOutputStream.Finish(); this.zipOutputStream.Close(); } this.Encrypt(zipFile, encryptedFile); this.SCPFile(encryptedFile); this.DeleteFiles(); } /// <summary> /// Deletes any files created by the backup process, namely the DB backup file, /// the zip of all files backuped up, and the encrypred zip file /// </summary> private void DeleteFiles() { File.Delete(this.backupFile); File.Delete(this.zipFile); ///File.Delete(this.encryptedFile); } private void ZipUserSpecifiedFilesAndDirectories(string[] fileNames) { foreach (string fileName in fileNames) { string name = fileName.Trim(); if (name.Length > 0) { Log("Zipping " + name); this.ZipFile(name, this.GetNameFromDir(name)); } } } private void SCPFile(string inputPath) { string sshServer = System.Configuration.ConfigurationSettings.AppSettings["SSHServer"].ToString(); string sshUsername = System.Configuration.ConfigurationSettings.AppSettings["SSHUsername"].ToString(); string sshPassword = System.Configuration.ConfigurationSettings.AppSettings["SSHPassword"].ToString(); if (sshServer.Length > 0 && sshUsername.Length > 0 && sshPassword.Length > 0) { Scp scp = new Scp(sshServer, sshUsername, sshPassword); //Copy a file from local machine to remote SSH server scp.Connect(); Log("Connected to " + sshServer); //scp.Put(inputPath, "/home/wal/temp.txt"); scp.Put(inputPath, GetName(inputPath)); scp.Close(); } else { Log("Not SCP as missing login details"); } } private string GetName(string inputPath) { FileInfo info = new FileInfo(inputPath); return info.Name; } private string GetNameFromDir(string inputPath) { DirectoryInfo info = new DirectoryInfo(inputPath); return info.Name; } private static void Log(string msg) { try { string toLog = DateTime.Now.ToString() + ": " + msg; System.Diagnostics.Debug.WriteLine(toLog); System.IO.FileStream fs = new System.IO.FileStream(baseDir + "app.log", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite); System.IO.StreamWriter m_streamWriter = new System.IO.StreamWriter(fs); m_streamWriter.BaseStream.Seek(0, System.IO.SeekOrigin.End); m_streamWriter.WriteLine(toLog); m_streamWriter.Flush(); m_streamWriter.Close(); fs.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); } } private byte[] GetFileBytes(string path) { FileStream stream = new FileStream(path, FileMode.Open); byte[] bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); stream.Close(); return bytes; } private void WriteFileBytes(byte[] bytes, string path) { FileStream stream = new FileStream(path, FileMode.Create); stream.Write(bytes, 0, bytes.Length); stream.Close(); } private void UnzipFile(string inputPath, string outputPath) { ZipInputStream zis = new ZipInputStream(File.OpenRead(inputPath)); ZipEntry theEntry = zis.GetNextEntry(); FileStream streamWriter = File.Create(outputPath); int size = 2048; byte[] data = new byte[2048]; while (true) { size = zis.Read(data, 0, data.Length); if (size > 0) { streamWriter.Write(data, 0, size); } else { break; } } streamWriter.Close(); zis.Close(); } private bool ExcludeDir(string dirName) { foreach (string excludeDir in this.excludeDirs) { if (dirName == excludeDir) return true; } return false; } private void ZipFile(string inputPath, string zipName) { FileAttributes fa = File.GetAttributes(inputPath); if ((fa & FileAttributes.Directory) != 0) { string dirName = zipName + "/"; ZipEntry entry1 = new ZipEntry(dirName); this.zipOutputStream.PutNextEntry(entry1); string[] subDirs = Directory.GetDirectories(inputPath); //create directories first foreach (string subDir in subDirs) { DirectoryInfo info = new DirectoryInfo(subDir); string name = info.Name; if (this.ExcludeDir(name)) Log("Excluding " + dirName + name); else this.ZipFile(subDir, dirName + name); } //then store files string[] fileNames = Directory.GetFiles(inputPath); foreach (string fileName in fileNames) { FileInfo info = new FileInfo(fileName); string name = info.Name; this.ZipFile(fileName, dirName + name); } } else { Crc32 crc = new Crc32(); this.zipOutputStream.SetLevel(6); // 0 - store only to 9 - means best compression FileStream fs = null; try { fs = File.OpenRead(inputPath); } catch (IOException ioEx) { Log("WARNING! " + ioEx.Message);//might be in use, skip file in this case } if (fs != null) { byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); ZipEntry entry = new ZipEntry(zipName); entry.DateTime = DateTime.Now; // set Size and the crc, because the information // about the size and crc should be stored in the header // if it is not set it is automatically written in the footer. // (in this case size == crc == -1 in the header) // Some ZIP programs have problems with zip files that don't store // the size and crc in the header. entry.Size = fs.Length; fs.Close(); crc.Reset(); crc.Update(buffer); entry.Crc = crc.Value; this.zipOutputStream.PutNextEntry(entry); this.zipOutputStream.Write(buffer, 0, buffer.Length); } } } private void Encrypt(string inputPath, string outputPath) { RijndaelManaged rijndaelManaged = new RijndaelManaged(); byte[] encrypted; byte[] toEncrypt; //Create a new key and initialization vector. //myRijndael.GenerateKey(); //myRijndael.GenerateIV(); /*des.GenerateKey(); des.GenerateIV(); string temp1 = Convert.ToBase64String(des.Key); string temp2 = Convert.ToBase64String(des.IV);*/ //Get the key and IV. byte[] key = Convert.FromBase64String(keyString); byte[] IV = Convert.FromBase64String(ivString); //Get an encryptor. ICryptoTransform encryptor = rijndaelManaged.CreateEncryptor(key, IV); //Encrypt the data. MemoryStream msEncrypt = new MemoryStream(); CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write); //Convert the data to a byte array. toEncrypt = this.GetFileBytes(inputPath); //Write all data to the crypto stream and flush it. csEncrypt.Write(toEncrypt, 0, toEncrypt.Length); csEncrypt.FlushFinalBlock(); //Get encrypted array of bytes. encrypted = msEncrypt.ToArray(); WriteFileBytes(encrypted, outputPath); } private void Decrypt(string inputPath, string outputPath) { RijndaelManaged myRijndael = new RijndaelManaged(); //DES des = new DESCryptoServiceProvider(); byte[] key = Convert.FromBase64String(keyString); byte[] IV = Convert.FromBase64String(ivString); byte[] encrypted = this.GetFileBytes(inputPath); byte[] fromEncrypt; //Get a decryptor that uses the same key and IV as the encryptor. ICryptoTransform decryptor = myRijndael.CreateDecryptor(key, IV); //Now decrypt the previously encrypted message using the decryptor // obtained in the above step. MemoryStream msDecrypt = new MemoryStream(encrypted); CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read); fromEncrypt = new byte[encrypted.Length]; //Read the data out of the crypto stream. int bytesRead = csDecrypt.Read(fromEncrypt, 0, fromEncrypt.Length); byte[] readBytes = new byte[bytesRead]; Array.Copy(fromEncrypt, 0, readBytes, 0, bytesRead); this.WriteFileBytes(readBytes, outputPath); } private string GetFileName(string extension) { return baseDir + backupName + "_" + DateTime.Now.ToString("yyyyMMdd") + "." + extension; } private void BackupDB(string backupPath) { string sql = @"DECLARE @Date VARCHAR(300), @Dir VARCHAR(4000) --Get today date SET @Date = CONVERT(VARCHAR, GETDATE(), 112) --Set the directory where the back up file is stored SET @Dir = '"; sql += backupPath; sql += @"' --create a 'device' to write to first EXEC sp_addumpdevice 'disk', 'temp_device', @Dir --now do the backup BACKUP DATABASE " + this.dbName; sql += @" TO temp_device WITH FORMAT --Drop the device EXEC sp_dropdevice 'temp_device' "; //Console.WriteLine("sql="+sql); Backup.Log("Starting backup of " + this.dbName); ExecuteSQL(sql); } /// <summary> /// Executes the specified SQL /// Returns true if no errors were encountered during execution /// </summary> /// <param name="procedureName"></param> private void ExecuteSQL(string sql) { SqlConnection conn = new SqlConnection(this.GetDBConnectString()); try { SqlCommand comm = new SqlCommand(sql, conn); conn.Open(); comm.ExecuteNonQuery(); } finally { conn.Close(); } } private string GetDBConnectString() { StringBuilder builder = new StringBuilder(); builder.Append("Data Source=127.0.0.1; User ID="); builder.Append(this.dbUsername); builder.Append("; Password="); builder.Append(this.dbPassword); builder.Append("; Initial Catalog="); builder.Append(this.dbName); builder.Append(";Connect Timeout=30"); return builder.ToString(); } } } }

    Read the article

  • Wrapping a C# service in a console app to debug it.

    - by Jack Smit
    I want to debug a service written in C# and the old fashioned way is just too long. I have to stop the service, start my application that uses the service in debug mode (Visual studio 2008), start the service, attach to the service process and then navigate in my Asp.Net application to trigger the service. I basically have the service running in the background, waiting for a task. The web application will trigger a task to be picked up by the service. What I would like to do is to have a console application that fires the service in an effort for me to debug. Is there any simple demo that anybody knows about? Thank you Jack

    Read the article

  • How will a search engine read data from my Ajax-based webapp?

    - by Jack W-H
    OK, not entirely related to programming, so I'm sorry. But I'd like to know about this: So I've got a webapp. There's one column where a list of results are fetched from the database. When you click one, jQuery fetches the information associated with that result and puts it into the second column - all without a refresh and using Ajax. Is it possible for Google to still read it etc.? I understand it can follow links... but presumably not Javascript actions etc.? If this is the case, what do other Ajax-heavy websites do about search engine optimisation? Jack

    Read the article

  • MySQL problem: How to get desired rows.

    - by Joonas Köppä
    I have been trying to solve this problem for 2 hours now but I cant understand the solutions others have given people with a similar problem. Ive seen some answers but can't apply it to my own needs. I have a table of users and their times in different sports events. I need to make a scoretable that shows the user with the best time, second best etc. The table before sorting and retrieving looks as follows: | Name | Time | Date | '''''''''''''''''''''''''''''''''''''''''''''' | Jack | 03:07:13 | 2010-12-01 | | Peter | 05:03:12 | 2010-12-03 | | Jack | 03:53:19 | 2010-12-04 | | Simon | 03:22:59 | 2010-12-02 | | Simon | 04:01:11 | 2010-12-09 | | Peter | 03:19:17 | 2010-12-06 | '''''''''''''''''''''''''''''''''''''''''''''' | Name | Time | Date | '''''''''''''''''''''''''''''''''''''''''' | Jack | 03:07:13 | 2010-12-01 | | Peter | 03:19:17 | 2010-12-06 | | Simon | 03:22:59 | 2010-12-02 | '''''''''''''''''''''''''''''''''''''''''' I know answers to this problem lie in another question asked on this very site: CLICK HERE I just have no idea how to apply it to fullfill my needs. Help is highly appreciated. Thank you -Joonas

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >