Search Results

Search found 188 results on 8 pages for 'eamonn fox'.

Page 2/8 | < Previous Page | 1 2 3 4 5 6 7 8  | Next Page >

  • C# HashSet<T>

    - by Ben Griswold
    I hadn’t done much (read: anything) with the C# generic HashSet until I recently needed to produce a distinct collection.  As it turns out, HashSet<T> was the perfect tool. As the following snippet demonstrates, this collection type offers a lot: // Using HashSet<T>: // http://www.albahari.com/nutshell/ch07.aspx var letters = new HashSet<char>("the quick brown fox");   Console.WriteLine(letters.Contains('t')); // true Console.WriteLine(letters.Contains('j')); // false   foreach (char c in letters) Console.Write(c); // the quickbrownfx Console.WriteLine();   letters = new HashSet<char>("the quick brown fox"); letters.IntersectWith("aeiou"); foreach (char c in letters) Console.Write(c); // euio Console.WriteLine();   letters = new HashSet<char>("the quick brown fox"); letters.ExceptWith("aeiou"); foreach (char c in letters) Console.Write(c); // th qckbrwnfx Console.WriteLine();   letters = new HashSet<char>("the quick brown fox"); letters.SymmetricExceptWith("the lazy brown fox"); foreach (char c in letters) Console.Write(c); // quicklazy Console.WriteLine(); The MSDN documentation is a bit light on HashSet<T> documentation but if you search hard enough you can find some interesting information and benchmarks. But back to that distinct list I needed… // MSDN Add // http://msdn.microsoft.com/en-us/library/bb353005.aspx var employeeA = new Employee {Id = 1, Name = "Employee A"}; var employeeB = new Employee {Id = 2, Name = "Employee B"}; var employeeC = new Employee {Id = 3, Name = "Employee C"}; var employeeD = new Employee {Id = 4, Name = "Employee D"};   var naughty = new List<Employee> {employeeA}; var nice = new List<Employee> {employeeB, employeeC};   var employees = new HashSet<Employee>(); naughty.ForEach(x => employees.Add(x)); nice.ForEach(x => employees.Add(x));   foreach (Employee e in employees) Console.WriteLine(e); // Returns Employee A Employee B Employee C The Add Method returns true on success and, you guessed it, false if the item couldn’t be added to the collection.  I’m using the Linq ForEach syntax to add all valid items to the employees HashSet.  It works really great.  This is just a rough sample, but you may have noticed I’m using Employee, a reference type.  Most samples demonstrate the power of the HashSet with a collection of integers which is kind of cheating.  With value types you don’t have to worry about defining your own equality members.  With reference types, you do. internal class Employee {     public int Id { get; set; }     public string Name { get; set; }       public override string ToString()     {         return Name;     }          public bool Equals(Employee other)     {         if (ReferenceEquals(null, other)) return false;         if (ReferenceEquals(this, other)) return true;         return other.Id == Id;     }       public override bool Equals(object obj)     {         if (ReferenceEquals(null, obj)) return false;         if (ReferenceEquals(this, obj)) return true;         if (obj.GetType() != typeof (Employee)) return false;         return Equals((Employee) obj);     }       public override int GetHashCode()     {         return Id;     }       public static bool operator ==(Employee left, Employee right)     {         return Equals(left, right);     }       public static bool operator !=(Employee left, Employee right)     {         return !Equals(left, right);     } } Fortunately, with Resharper, it’s a snap. Click on the class name, ALT+INS and then follow with the handy dialogues. That’s it. Try out the HashSet<T>. It’s good stuff.

    Read the article

  • Optimizing Haskell code

    - by Masse
    I'm trying to learn Haskell and after an article in reddit about Markov text chains, I decided to implement Markov text generation first in Python and now in Haskell. However I noticed that my python implementation is way faster than the Haskell version, even Haskell is compiled to native code. I am wondering what I should do to make the Haskell code run faster and for now I believe it's so much slower because of using Data.Map instead of hashmaps, but I'm not sure I'll post the Python code and Haskell as well. With the same data, Python takes around 3 seconds and Haskell is closer to 16 seconds. It comes without saying that I'll take any constructive criticism :). import random import re import cPickle class Markov: def __init__(self, filenames): self.filenames = filenames self.cache = self.train(self.readfiles()) picklefd = open("dump", "w") cPickle.dump(self.cache, picklefd) picklefd.close() def train(self, text): splitted = re.findall(r"(\w+|[.!?',])", text) print "Total of %d splitted words" % (len(splitted)) cache = {} for i in xrange(len(splitted)-2): pair = (splitted[i], splitted[i+1]) followup = splitted[i+2] if pair in cache: if followup not in cache[pair]: cache[pair][followup] = 1 else: cache[pair][followup] += 1 else: cache[pair] = {followup: 1} return cache def readfiles(self): data = "" for filename in self.filenames: fd = open(filename) data += fd.read() fd.close() return data def concat(self, words): sentence = "" for word in words: if word in "'\",?!:;.": sentence = sentence[0:-1] + word + " " else: sentence += word + " " return sentence def pickword(self, words): temp = [(k, words[k]) for k in words] results = [] for (word, n) in temp: results.append(word) if n > 1: for i in xrange(n-1): results.append(word) return random.choice(results) def gentext(self, words): allwords = [k for k in self.cache] (first, second) = random.choice(filter(lambda (a,b): a.istitle(), [k for k in self.cache])) sentence = [first, second] while len(sentence) < words or sentence[-1] is not ".": current = (sentence[-2], sentence[-1]) if current in self.cache: followup = self.pickword(self.cache[current]) sentence.append(followup) else: print "Wasn't able to. Breaking" break print self.concat(sentence) Markov(["76.txt"]) -- module Markov ( train , fox ) where import Debug.Trace import qualified Data.Map as M import qualified System.Random as R import qualified Data.ByteString.Char8 as B type Database = M.Map (B.ByteString, B.ByteString) (M.Map B.ByteString Int) train :: [B.ByteString] -> Database train (x:y:[]) = M.empty train (x:y:z:xs) = let l = train (y:z:xs) in M.insertWith' (\new old -> M.insertWith' (+) z 1 old) (x, y) (M.singleton z 1) `seq` l main = do contents <- B.readFile "76.txt" print $ train $ B.words contents fox="The quick brown fox jumps over the brown fox who is slow jumps over the brown fox who is dead."

    Read the article

  • What is a practical way to debug Rails?

    - by Joshua Fox
    I get the impression that in practice, debuggers are rarely used for Rails applications. (Likewise for other Ruby apps, as well as Python.) We can compare this to the usual practice for Java or VisualStudio programmers--they use an interactive debugger in a graphical IDE. How do people debug Rails applications in practice? I am aware of the variety of debuggers, so no need to mention those, but do serious Rails programmers work without them? If so, why do you choose to do it this way? It seems to me that console printing has its limits when debugging complex logic.

    Read the article

  • How do I stop Gimp from autolaunching on startup?

    - by Joshua Fox
    Gimp launches every time I log into Xubuntu (v. 13.10). Gimp is not shown under Settings Manager- Sessions and startup. It does not appear in ~/.config/autostart. I immediately close Gimp in these cases, so it is not running when I shut down the session. How do I stop Gimp from autolaunching on startup? Diagnostic Info: Note that cd / find . -name gimp.desktop Only produces ./usr/share/applications/gimp.desktop and nothing else Here is the output of grep -lIr 'gimp' ~/ ~/Gimp-search-results.txt sbin/vgimportclone home/joshua/.gimp-2.8/controllerrc home/joshua/.gimp-2.8/tags.xml home/joshua/.gimp-2.8/dockrc home/joshua/.gimp-2.8/gimprc home/joshua/.gimp-2.8/themerc home/joshua/.gimp-2.8/templaterc home/joshua/.gimp-2.8/gtkrc home/joshua/.gimp-2.8/sessionrc home/joshua/.gimp-2.8/toolrc home/joshua/.gimp-2.8/pluginrc home/joshua/.gimp-2.8/menurc home/joshua/Gimp-search-results.txt home/joshua/.local/share/ristretto/mime.db home/joshua/.wine/drive_c/windows/system32/gecko/1.4/wine_gecko/dictionaries/en-US.dic home/joshua/.wine/drive_c/windows/syswow64/gecko/1.4/wine_gecko/dictionaries/en-US.dic home/joshua/.cache/software-center/piston-helper/rec.ubuntu.com,api,1.0,recommend_app,skype,,0495938f41334883bd3a67d3b164c1d1 home/joshua/.cache/software-center/piston-helper/rec.ubuntu.com,api,1.0,recommend_app,gnome-utils,,91bba9b826fb21dbfc3aad6d3bd771cb home/joshua/.cache/software-center/piston-helper/rec.ubuntu.com,api,1.0,recommend_app,icedtea-plugin,,7bb5e4ad0469ef8277032c048b9d7328 home/joshua/.cache/software-center/piston-helper/reviews.ubuntu.com,reviews,api,1.0,review-stats,any,any,,1c66e24123164bb80c4253965e29eed7 home/joshua/.cache/software-center/piston-helper/rec.ubuntu.com,api,1.0,recommend_app,wine1.4,,2bac05a75dcec604ee91e58027eb4165 home/joshua/.cache/software-center/piston-helper/software-center.ubuntu.com,api,2.0,applications,en,ubuntu,saucy,amd64,,32b432ef7e12661055c87e3ea0f3b5d5 home/joshua/.cache/software-center/apthistory.p home/joshua/.cache/software-center/reviews.ubuntu.com_reviews_api_1.0_review-stats-pkgnames.p home/joshua/.cache/oneconf/861c4e30b916e750f16fab5652ed5937/package_list_861c4e30b916e750f16fab5652ed5937 home/joshua/.cache/sessions/xfwm4-23e853443-fb4b-42fd-aa61-33fa99fdc12c.state home/joshua/.cache/sessions/xfce4-session-athena:0 home/joshua/.config/abiword/profile

    Read the article

  • Successful technical communities except for open-source?

    - by Joshua Fox
    Have you ever seen a successful technical community -- e.g. user group, industry organization? Am I asking about a group of software engineers who get together F2F (or maybe online) and discuss technical and industry issues with deep zeal and interest -- a place where meaningful connections are made. Here are the only examples I have ever seen: Open source Maybe the Silicon Valley Java Users' Group Homebrew Computing Club in the '70's This sort of thing does exist in academia. Of course, there are lots of conferences and attempts at user's groups. However, almost all committed, serious software engineers, when asked about this, say "I don't have the time", which means that the organizations are not worthwhile to the best in our profession. Has anyone seen any organizations with an ongoing spirit of enthusiasm from top software engineers?

    Read the article

  • What are the IEEE and ACM good for?

    - by Joshua Fox
    Membership in the IEEE and ACM is sometimes portrayed as a sign of professionalism. But all that is involved, as far as I can tell, is sending them your money. In return, besides the potential resume line, these organizations sponsor conferences and journals. I can always attend a conference or subscribe to or submit a paper to a journal, whether I am a member or not. If being a member makes some of that cheaper, or is a prerequisite for admission then OK, but I still don't see the purpose of these organizations. The answer, as far as I can gather, is that their most important value is to provide some reading material. I'd suggest that this is not worth the money given the wide availability of other valuable reading materials.

    Read the article

  • Moving player in direciton camera is facing

    - by Samurai Fox
    I have a 3rd person camera which can rotate around the player. My problem is that wherever camera is facing, players forward is always the same direction. For example when camera is facing the right side of the player, when I press button to move forward, I want player to turn to the left and make that the "new forward". My camera script so far: using UnityEngine; using System.Collections; public class PlayerScript : MonoBehaviour { public float RotateSpeed = 150, MoveSpeed = 50; float DeltaTime; void Update() { DeltaTime = Time.deltaTime; transform.Rotate(0, Input.GetAxis("LeftX") * RotateSpeed * DeltaTime, 0); transform.Translate(0, 0, -Input.GetAxis("LeftY") * MoveSpeed * DeltaTime); } } public class CameraScript : MonoBehaviour { public GameObject Target; public float RotateSpeed = 170, FollowDistance = 20, FollowHeight = 10; float RotateSpeedPerTime, DesiredRotationAngle, DesiredHeight, CurrentRotationAngle, CurrentHeight, Yaw, Pitch; Quaternion CurrentRotation; void LateUpdate() { RotateSpeedPerTime = RotateSpeed * Time.deltaTime; DesiredRotationAngle = Target.transform.eulerAngles.y; DesiredHeight = Target.transform.position.y + FollowHeight; CurrentRotationAngle = transform.eulerAngles.y; CurrentHeight = transform.position.y; CurrentRotationAngle = Mathf.LerpAngle(CurrentRotationAngle, DesiredRotationAngle, 0); CurrentHeight = Mathf.Lerp(CurrentHeight, DesiredHeight, 0); CurrentRotation = Quaternion.Euler(0, CurrentRotationAngle, 0); transform.position = Target.transform.position; transform.position -= CurrentRotation * Vector3.forward * FollowDistance; transform.position = new Vector3(transform.position.x, CurrentHeight, transform.position.z); Yaw = Input.GetAxis("Right Horizontal") * RotateSpeedPerTime; Pitch = Input.GetAxis("Right Vertical") * RotateSpeedPerTime; transform.Translate(new Vector3(Yaw, -Pitch, 0)); transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z); transform.LookAt(Target.transform); } }

    Read the article

  • Change players state and controls in-game

    - by Samurai Fox
    I'm using Unity 3D Let's say the player is an ice cube. You control it like a normal player. On press of a button, ice transforms (with animation) into water. You control it completely different than the ice cube. Another great example would be: Player is human being and has normal FPS controls. On press of a button human transforms into birds and now has completely different controls. Now, my question is, what would be easier and better: make one object with animation transition and to stay in that state of anim. until button is pressed again make two object: ice and water. Ice has an animation of turning into water. So replace ice (with animation) with water object And if anyone knows this one too: how to switch between 2 different types of player controls.

    Read the article

  • Zenoss Setup for Windows Servers

    - by Jay Fox
    Recently I was saddled with standing up Zenoss for our enterprise.  We're running about 1200 servers, so manually touching each box was not an option.  We use LANDesk for a lot of automated installs and patching - more about that later.The steps below may not necessarily have to be completed in this order - it's just the way I did it.STEP ONE:Setup a standard AD user.  We want to do this so there's minimal security exposure.  Call the account what ever you want "domain/zenoss" for our examples.***********************************************************STEP TWO:Make the following local groups accessible by your zenoss account.Distributed COM UsersPerformance Monitor UsersEvent Log Readers (which doesn't exist on pre-2008 machines)Here's the Powershell script I used to setup access to these local groups:# Created to add Active Directory account to local groups# Must be run from elevated prompt, with permissions on the remote machine(s).# Create txt file should contain the names of the machines that need the account added, one per line.# Script will process machines line by line.foreach($i in (gc c:\tmp\computers.txt)){# Add the user to the first group$objUser=[ADSI]("WinNT://domain/zenoss")$objGroup=[ADSI]("WinNT://$i/Distributed COM Users")$objGroup.PSBase.Invoke("Add",$objUser.PSBase.Path)# Add the user to the second group$objUser=[ADSI]("WinNT://domain/zenoss")$objGroup=[ADSI]("WinNT://$i/Performance Monitor Users")$objGroup.PSBase.Invoke("Add",$objUser.PSBase.Path)# Add the user to the third group - Group doesn't exist on < Server 2008#$objUser=[ADSI]("WinNT://domain/zenoss")#$objGroup=[ADSI]("WinNT://$i/Event Log Readers")#$objGroup.PSBase.Invoke("Add",$objUser.PSBase.Path)}**********************************************************STEP THREE:Setup security on the machines namespace so our domain/zenoss account can access itThe default namespace for zenoss is:  root/cimv2Here's the Powershell script:#Grant account defined below (line 11) access to WMI Namespace#Has to be run as account with permissions on remote machinefunction get-sid{Param ($DSIdentity)$ID = new-object System.Security.Principal.NTAccount($DSIdentity)return $ID.Translate( [System.Security.Principal.SecurityIdentifier] ).toString()}$sid = get-sid "domain\zenoss"$SDDL = "A;;CCWP;;;$sid" $DCOMSDDL = "A;;CCDCRP;;;$sid"$computers = Get-Content "c:\tmp\computers.txt"foreach ($strcomputer in $computers){    $Reg = [WMIClass]"\\$strcomputer\root\default:StdRegProv"    $DCOM = $Reg.GetBinaryValue(2147483650,"software\microsoft\ole","MachineLaunchRestriction").uValue    $security = Get-WmiObject -ComputerName $strcomputer -Namespace root/cimv2 -Class __SystemSecurity    $converter = new-object system.management.ManagementClass Win32_SecurityDescriptorHelper    $binarySD = @($null)    $result = $security.PsBase.InvokeMethod("GetSD",$binarySD)    $outsddl = $converter.BinarySDToSDDL($binarySD[0])    $outDCOMSDDL = $converter.BinarySDToSDDL($DCOM)    $newSDDL = $outsddl.SDDL += "(" + $SDDL + ")"    $newDCOMSDDL = $outDCOMSDDL.SDDL += "(" + $DCOMSDDL + ")"    $WMIbinarySD = $converter.SDDLToBinarySD($newSDDL)    $WMIconvertedPermissions = ,$WMIbinarySD.BinarySD    $DCOMbinarySD = $converter.SDDLToBinarySD($newDCOMSDDL)    $DCOMconvertedPermissions = ,$DCOMbinarySD.BinarySD    $result = $security.PsBase.InvokeMethod("SetSD",$WMIconvertedPermissions)     $result = $Reg.SetBinaryValue(2147483650,"software\microsoft\ole","MachineLaunchRestriction", $DCOMbinarySD.binarySD)}***********************************************************STEP FOUR:Get the SID for our zenoss account.Powershell#Provide AD User get SID$objUser = New-Object System.Security.Principal.NTAccount("domain", "zenoss") $strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier]) $strSID.Value******************************************************************STEP FIVE:Modify the Service Control Manager to allow access to the zenoss AD account.This command can be run from an elevated command line, or through Powershellsc sdset scmanager "D:(A;;CC;;;AU)(A;;CCLCRPRC;;;IU)(A;;CCLCRPRC;;;SU)(A;;CCLCRPWPRC;;;SY)(A;;KA;;;BA)(A;;CCLCRPRC;;;PUT_YOUR_SID_HERE_FROM STEP_FOUR)S:(AU;FA;KA;;;WD)(AU;OIIOFA;GA;;;WD)"******************************************************************In step two the script plows through a txt file that processes each computer listed on each line.  For the other scripts I ran them on each machine using LANDesk.  You can probably edit those scripts to process a text file as well.That's what got me off the ground monitoring the machines using Zenoss.  Hopefully this is helpful for you.  Watch the line breaks when copy the scripts.

    Read the article

  • Rotate camera around player and set new forward directions

    - by Samurai Fox
    I have a 3rd person camera which can rotate around the player. When I look at the back of the player and press forward, player goes forward. Then I rotate 360 around the player and "forward direction" is tilted for 90 degrees. So every 360 turn there is 90 degrees of direction change. For example when camera is facing the right side of the player, when I press button to move forward, I want player to turn to the left and make that the "new forward". I have Player object with Camera as child object. Camera object has Camera script. Inside Camera script there are Player and Camera classes. Player object itself, has Input Controller. Also I'm making this script for joystick/ controller primarily. My camera script so far: using UnityEngine; using System.Collections; public class CameraScript : MonoBehaviour { public GameObject Target; public float RotateSpeed = 10, FollowDistance = 20, FollowHeight = 10; float RotateSpeedPerTime, DesiredRotationAngle, DesiredHeight, CurrentRotationAngle, CurrentHeight, Yaw, Pitch; Quaternion CurrentRotation; void LateUpdate() { RotateSpeedPerTime = RotateSpeed * Time.deltaTime; DesiredRotationAngle = Target.transform.eulerAngles.y; DesiredHeight = Target.transform.position.y + FollowHeight; CurrentRotationAngle = transform.eulerAngles.y; CurrentHeight = transform.position.y; CurrentRotationAngle = Mathf.LerpAngle(CurrentRotationAngle, DesiredRotationAngle, 0); CurrentHeight = Mathf.Lerp(CurrentHeight, DesiredHeight, 0); CurrentRotation = Quaternion.Euler(0, CurrentRotationAngle, 0); transform.position = Target.transform.position; transform.position -= CurrentRotation * Vector3.forward * FollowDistance; transform.position = new Vector3(transform.position.x, CurrentHeight, transform.position.z); Yaw = Input.GetAxis("Right Horizontal") * RotateSpeedPerTime; Pitch = Input.GetAxis("Right Vertical") * RotateSpeedPerTime; transform.Translate(new Vector3(Yaw, -Pitch, 0)); transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z); transform.LookAt(Target.transform); } }

    Read the article

  • Multi subnet in ubuntu with dnsmasq

    - by Fox Mulder
    I have a multi lan port box that install ubuntu server 11.10. I am setup network in /etc/network/interfaces file as follow: auto lo iface lo inet loopback auto eth0 iface eth0 inet static      address 192.168.128.254      netmask 255.255.255.0      network 192.168.128.0      broadcast 192.168.128.255      gateway 192.168.128.1      dns-nameservers xxxxxx auto eth1 iface eth1 inet static      address 192.168.11.1      netmask 255.255.255.0      network 192.168.11.0      broadcast 192.168.11.255 auto eth2 iface eth2 inet static      address 192.168.21.1      netmask 255.255.255.0      network 192.168.21.0      broadcast 192.168.21.255 auto eth3 iface eth3 inet static      address 192.168.31.1      netmask 255.255.255.0      network 192.168.31.0      broadcast 192.168.31.255 I am also enable the ip forward by echo 1 /proc/sys/net/ipv4/if_forward in rc.local. my dnsmasq config as follow except-interface=eth0 dhcp-range=interface:eth1,set:wifi,192.168.11.101,192.168.11.200,255.255.255.0 dhcp-range=interface:eth2,set:kids,192.168.21.101,192.168.21.200,255.255.255.0 dhcp-range=interface:eth3,set:game,192.168.31.101,192.168.31.200,255.255.255.0 the dhcp was working fine in eth1,eth2,eth3, any machine plug in the subnet can get correct subnet's ip. My problem was, each subnet machine can't ping each other. for example. 192.168.11.101 can't ping 192.168.21.101 but can ping 192.168.128.1 192.168.31.101 can't ping 192.168.21.101 but can ping 192.168.128.1 I am also try to using route add -net 192.168.11.0 netmask 255.255.255.0 gw 192.168.11.1 (and also 192.168.21.0/192.168.31.0) at this multi-lan-port machine. But still won't work. Does anyone can help ? Thanks.

    Read the article

  • php - regex- preg_replace - space after line-break!

    - by aSeptik
    Hi all guys! still on regex! i want learn it but i'm still crashing the head into my keybord! ;-) ok very trivial for you, i'm sure! Assuming i have this sting, the \s is where the space actualy is... \n where linebreak is.. DESCRIPTION: The quick brown fox jum`\s\n` `\s`ps over the lazy dog now, what i need to do is remove All the space after the A-Z: that i have achieved by this regex: /\s+(?![A-Z:])/m that produce this result DESCRIPTION: The quick brown fox jum ps over the lazy dog as you can see it leave the space between jum and ps how to have a result like this? DESCRIPTION: The quick brown fox jumps over the lazy dog thank's for the time!

    Read the article

  • MySQL, how can I SELECT WHERE one field value doesn't occurs in another?

    - by Jules
    I'm trying to do a search on my test server, speed isn't so important. I want to find if a phrase, the whole contents of one field, occurs in any part (as a whole) doesn't occur in another field. Heres my current query which finds if the phrase does occur SELECT pads.padid, pads.programname, keywords.word FROM Pads JOIN keywords ON Pads.Padid = keywords.Padid WHERE pads.Programname = keywords.word AND RemoveMeDate = '2001-01-01 00:00:00' My problem is that the field word contains other words too. I need to produce a count of where there isn't a keywords record with keywords.word equal to pads.programname ? EDIT: So if I have these records Pads: PadID=3 ProgramName=my prog PadID=4 ProgramName=Bad prog PadID=5 ProgramName=Good prog PadID=6 ProgramName=other prog Keywords: PadID=3 word=fox prog PadID=3 word=pig prog PadID=4 word=big prog PadID=4 word=nice prog PadID=5 word=fox prog PadID=6 word=bad prog PadID=6 word=fox prog The query I want would retun a count of 3 and record 6 has bad prog

    Read the article

  • Problem dispatching with google mobile analytics for iphone

    - by Eamonn
    I have integrated Google mobile analytics into my iphone app, but for some reason the page views and events are not dispatching. I put this into my app delegate applicationDidFinishLaunching method (i've x'd out the UA string): [[GANTracker sharedTracker] startTrackerWithAccountID:@"UA-xxxxxx-x" dispatchPeriod:10 delegate:self]; NSError *error; [[GANTracker sharedTracker] trackPageview:@"/home" withError:&error]; This is the delegate method: - (void)trackerDispatchDidComplete:(GANTracker *)tracker eventsDispatched:(NSUInteger)eventsDispatched eventsFailedDispatch:(NSUInteger)eventsFailedDispatch { NSLog(@"Google Analytics Dispatch: succeeded:%i, failed:%i",eventsDispatched,eventsFailedDispatch); } which prints out the message: Google Analytics Dispatch: succeeded:0, failed:190 Did anyone else run into this problem?

    Read the article

  • PHP JQuery: Where to specify uploadify destination folder

    - by Eamonn
    I have an uploadify script running, basic setup. Works fine when I hard code the destination folder for the images into uploadify.php - now I want to make that folder dynamic. How do I do this? I have a PHP variable $uploadify_path which contains the path to the folder I want. I have switched out my hard coded $targetPath = path/to/directory for $targetPath = $uploadify_path in both uploadify.php and check_exists.php, but it does not work. The file upload animation runs, says it is complete, yet the directory remains empty. The file is not hiding out somewhere else either. I see there is an option in the Javascript to specify a folder. I tried this also, but to no avail. If anyone could educate me on how to pass this variable destination to uploadify, I'd be very grateful. I include my current code for checking (basically default): The Javascript <script type="text/javascript"> $(function() { $('#file_upload').uploadify({ 'swf' : 'uploadify/uploadify.swf', 'uploader' : 'uploadify/uploadify.php', // Put your options here }); }); </script> uploadify.php $targetPath = $_SERVER['DOCUMENT_ROOT'] . $uploadify_path; // Relative to the root if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetFile = $targetPath . $_FILES['Filedata']['name']; // Validate the file type $fileTypes = array('jpg','jpeg','gif','png'); // File extensions $fileParts = pathinfo($_FILES['Filedata']['name']); if (in_array($fileParts['extension'],$fileTypes)) { move_uploaded_file($tempFile,$targetFile); echo '1'; } else { echo 'Invalid file type.'; } }

    Read the article

  • Basic HTML Internal Link not working in IE8

    - by Eamonn
    This one has me scratching my head. I have a page with several internal links bringing the user down the page to further content. Beneath various sections there are further internal links bringing the user back to the top. This works fine in all browsers apart from IE8 (actual IE8 - not IE9 in IE8 mode) where they work go down, but not coming back up! Examples: <a href="page.php?v=35&amp;u=admin-videos#a">A &ndash; General</a> .... //travelling DOWN the page <h3><strong>A &ndash; General<a name="a"></a></strong></h3> <a name="top"></a> .... //travelling back up <a href="page.php?v=35&amp;u=admin-videos#top">Back to top.</a> I've tried filling the 'top' anchor with &nbsp; but that hasn't changed it. Any ideas? Actual use case: http://databizsolutions.ie/contents/page.php?v=35&u=admin-videos

    Read the article

  • JQuery: How to apply css to a .wrap element?

    - by Eamonn
    My code thus far: $(".lorem img:not(.full-img)").each(function() { $(this).addClass("inline-img"); var imgWidth = $(this).prop('width'); var imgHeight = $(this).prop('height'); var imgFloat = $(this).prop('float'); $(this).wrap('<div class="inline-img-wrap" />'); if ($(this).prop("title")!='') { $('<p class="inline-img-caption">').text($(this).prop('title')).insertAfter($(this)); } }); I am searching for images within a body of text, appending their title values as captions underneath, and wrapping both img and p in a div.inline-img-wrap. That works fine. What I need help with is applying the styling of the img to the new wrapping div instead. You can see I have created vars for just this, but cannot get applying them to work. $this will always apply to the image, and <div class="inline-img-wrap" style="width:'+imgWidth+'"> doesn't work. All advice appreciated!

    Read the article

  • Flex: replace all spaces with comma

    - by Treby
    im new with regexp, so can i ask for some assistance Using string.replace function what code that can replace spaces with comma Input:The quick brown fox jumps over the lazy dog. Output:The,quick,brown,fox,jumps,over,the,lazy dog. Thanks

    Read the article

  • In Objective C, what's the best way to extract multiple substrings of text around multiple patterns?

    - by Matt
    For one NSString, I have N pattern strings. I'd like to extract substrings "around" the pattern matches. So, if i have "the quick brown fox jumped over the lazy dog" and my patterns are "brown" and "lazy" i would like to get "quick brown fox" and "the lazy dog." However, the substrings don't necessarily need to be delimited by whitespace. I have a hunch that there's a very easy solution to this, but I admit a disturbing lack of knowledge of Objective C string functions.

    Read the article

  • The dynamic Type in C# Simplifies COM Member Access from Visual FoxPro

    - by Rick Strahl
    I’ve written quite a bit about Visual FoxPro interoperating with .NET in the past both for ASP.NET interacting with Visual FoxPro COM objects as well as Visual FoxPro calling into .NET code via COM Interop. COM Interop with Visual FoxPro has a number of problems but one of them at least got a lot easier with the introduction of dynamic type support in .NET. One of the biggest problems with COM interop has been that it’s been really difficult to pass dynamic objects from FoxPro to .NET and get them properly typed. The only way that any strong typing can occur in .NET for FoxPro components is via COM type library exports of Visual FoxPro components. Due to limitations in Visual FoxPro’s type library support as well as the dynamic nature of the Visual FoxPro language where few things are or can be described in the form of a COM type library, a lot of useful interaction between FoxPro and .NET required the use of messy Reflection code in .NET. Reflection is .NET’s base interface to runtime type discovery and dynamic execution of code without requiring strong typing. In FoxPro terms it’s similar to EVALUATE() functionality albeit with a much more complex API and corresponiding syntax. The Reflection APIs are fairly powerful, but they are rather awkward to use and require a lot of code. Even with the creation of wrapper utility classes for common EVAL() style Reflection functionality dynamically access COM objects passed to .NET often is pretty tedious and ugly. Let’s look at a simple example. In the following code I use some FoxPro code to dynamically create an object in code and then pass this object to .NET. An alternative to this might also be to create a new object on the fly by using SCATTER NAME on a database record. How the object is created is inconsequential, other than the fact that it’s not defined as a COM object – it’s a pure FoxPro object that is passed to .NET. Here’s the code: *** Create .NET COM InstanceloNet = CREATEOBJECT('DotNetCom.DotNetComPublisher') *** Create a Customer Object Instance (factory method) loCustomer = GetCustomer() loCustomer.Name = "Rick Strahl" loCustomer.Company = "West Wind Technologies" loCustomer.creditLimit = 9999999999.99 loCustomer.Address.StreetAddress = "32 Kaiea Place" loCustomer.Address.Phone = "808 579-8342" loCustomer.Address.Email = "[email protected]" *** Pass Fox Object and echo back values ? loNet.PassRecordObject(loObject) RETURN FUNCTION GetCustomer LOCAL loCustomer, loAddress loCustomer = CREATEOBJECT("EMPTY") ADDPROPERTY(loCustomer,"Name","") ADDPROPERTY(loCustomer,"Company","") ADDPROPERTY(loCUstomer,"CreditLimit",0.00) ADDPROPERTY(loCustomer,"Entered",DATETIME()) loAddress = CREATEOBJECT("Empty") ADDPROPERTY(loAddress,"StreetAddress","") ADDPROPERTY(loAddress,"Phone","") ADDPROPERTY(loAddress,"Email","") ADDPROPERTY(loCustomer,"Address",loAddress) RETURN loCustomer ENDFUNC Now prior to .NET 4.0 you’d have to access this object passed to .NET via Reflection and the method code to do this would looks something like this in the .NET component: public string PassRecordObject(object FoxObject) { // *** using raw Reflection string Company = (string) FoxObject.GetType().InvokeMember( "Company", BindingFlags.GetProperty,null, FoxObject,null); // using the easier ComUtils wrappers string Name = (string) ComUtils.GetProperty(FoxObject,"Name"); // Getting Address object – then getting child properties object Address = ComUtils.GetProperty(FoxObject,"Address");    string Street = (string) ComUtils.GetProperty(FoxObject,"StreetAddress"); // using ComUtils 'Ex' functions you can use . Syntax     string StreetAddress = (string) ComUtils.GetPropertyEx(FoxObject,"AddressStreetAddress"); return Name + Environment.NewLine + Company + Environment.NewLine + StreetAddress + Environment.NewLine + " FOX"; } Note that the FoxObject is passed in as type object which has no specific type. Since the object doesn’t exist in .NET as a type signature the object is passed without any specific type information as plain non-descript object. To retrieve a property the Reflection APIs like Type.InvokeMember or Type.GetProperty().GetValue() etc. need to be used. I made this code a little simpler by using the Reflection Wrappers I mentioned earlier but even with those ComUtils calls the code is pretty ugly requiring passing the objects for each call and casting each element. Using .NET 4.0 Dynamic Typing makes this Code a lot cleaner Enter .NET 4.0 and the dynamic type. Replacing the input parameter to the .NET method from type object to dynamic makes the code to access the FoxPro component inside of .NET much more natural: public string PassRecordObjectDynamic(dynamic FoxObject) { // *** using raw Reflection string Company = FoxObject.Company; // *** using the easier ComUtils class string Name = FoxObject.Name; // *** using ComUtils 'ex' functions to use . Syntax string Address = FoxObject.Address.StreetAddress; return Name + Environment.NewLine + Company + Environment.NewLine + Address + Environment.NewLine + " FOX"; } As you can see the parameter is of type dynamic which as the name implies performs Reflection lookups and evaluation on the fly so all the Reflection code in the last example goes away. The code can use regular object ‘.’ syntax to reference each of the members of the object. You can access properties and call methods this way using natural object language. Also note that all the type casts that were required in the Reflection code go away – dynamic types like var can infer the type to cast to based on the target assignment. As long as the type can be inferred by the compiler at compile time (ie. the left side of the expression is strongly typed) no explicit casts are required. Note that although you get to use plain object syntax in the code above you don’t get Intellisense in Visual Studio because the type is dynamic and thus has no hard type definition in .NET . The above example calls a .NET Component from VFP, but it also works the other way around. Another frequent scenario is an .NET code calling into a FoxPro COM object that returns a dynamic result. Assume you have a FoxPro COM object returns a FoxPro Cursor Record as an object: DEFINE CLASS FoxData AS SESSION OlePublic cAppStartPath = "" FUNCTION INIT THIS.cAppStartPath = ADDBS( JustPath(Application.ServerName) ) SET PATH TO ( THIS.cAppStartpath ) ENDFUNC FUNCTION GetRecord(lnPk) LOCAL loCustomer SELECT * FROM tt_Cust WHERE pk = lnPk ; INTO CURSOR TCustomer IF _TALLY < 1 RETURN NULL ENDIF SCATTER NAME loCustomer MEMO RETURN loCustomer ENDFUNC ENDDEFINE If you call this from a .NET application you can now retrieve this data via COM Interop and cast the result as dynamic to simplify the data access of the dynamic FoxPro type that was created on the fly: int pk = 0; int.TryParse(Request.QueryString["id"],out pk); // Create Fox COM Object with Com Callable Wrapper FoxData foxData = new FoxData(); dynamic foxRecord = foxData.GetRecord(pk); string company = foxRecord.Company; DateTime entered = foxRecord.Entered; This code looks simple and natural as it should be – heck you could write code like this in days long gone by in scripting languages like ASP classic for example. Compared to the Reflection code that previously was necessary to run similar code this is much easier to write, understand and maintain. For COM interop and Visual FoxPro operation dynamic type support in .NET 4.0 is a huge improvement and certainly makes it much easier to deal with FoxPro code that calls into .NET. Regardless of whether you’re using COM for calling Visual FoxPro objects from .NET (ASP.NET calling a COM component and getting a dynamic result returned) or whether FoxPro code is calling into a .NET COM component from a FoxPro desktop application. At one point or another FoxPro likely ends up passing complex dynamic data to .NET and for this the dynamic typing makes coding much cleaner and more readable without having to create custom Reflection wrappers. As a bonus the dynamic runtime that underlies the dynamic type is fairly efficient in terms of making Reflection calls especially if members are repeatedly accessed. © Rick Strahl, West Wind Technologies, 2005-2010Posted in COM  FoxPro  .NET  CSharp  

    Read the article

  • .NET Framework 4 updates breaking MMC.exe and other CLR.dll Exceptions

    - by Fox
    I've seen this issue floating around the net the last few weeks and I'm facing exactly the same issue. My servers are set to auto install updates using Windows update (not clever, I know), and since about 2 months ago, I've been getting strange Exceptions. The first thing that happens is that MMC.exe just crashes randomly and sometimes on startup of the console. The exception in the Windows Application log is as follow: Faulting application name: mmc.exe, version: 6.1.7600.16385, time stamp: 0x4a5bc808 Faulting module name: mscorwks.dll, version: 2.0.50727.5448, time stamp: 0x4e153960 Secondly, on the same server, I have some custom Windows services which constantly crash with exceptions : Faulting application name: Myservice.exe, version: 1.0.0.0, time stamp: 0x4f44cb11 Faulting module name: clr.dll, version: 4.0.30319.239, time stamp: 0x4e181a6d Exception code: 0xc0000005 Fault offset: 0x000378aa The exception is not in my code. I've tested and retested it. My server has the following .NET Framework updates installed: Does anyone have any idea?

    Read the article

  • Windows 7 : Any way to disable "show caracter" in WIFI network properties?!

    - by Fox
    Hi everyone, Here's my issue. I'm working in a school as IT Tech and I'm currently planning to roll out Windows 7 on students laptop. The issue is : When you go to the properties of a WIFI network, you have the fields to input the WIFI key, WPA2 key here in my case, and you also have a checkbox that allow you to "unmask" the caracters of the wifi key. This is actually the problem. Anyone who can access the WIFI network properties, will be able to see the WIFI key, which is really an issue in a school envrironnement where student are all eager to get the key for their precious IPod Touch, what I don't want to happen for obvious reasons... So, is there a way to disable that checkbox or else, make the field cleared out when the checkbox is checked, just like it was on Windows XP or Vista? Thanks all for your answer.

    Read the article

  • Windows 8.1 unable to play Music or the Audio from videos through Optical Out

    - by Zion Fox
    I am having an issue with my audio output, where any music file, and the audio side of videos are not being played through my optical audio output. I am running a Realtek HD Audio device built on Revision 1.0 on a GA-P55A-UD6 Gigabyte Board, which runs through it's optical output to an Astro A40 Mixamp, which does some upscaling before sending it to the headset. Now, notification sounds, and sounds/videos/music played through the browser or programs like Skype or games are working fine. This seems to specifically effect Foobar2000 and Media Player Classic. I have updated these two programs to their latest revisions, in addition to the soundcard drivers to no avail, and searching the error code thrown by Foobar2000: Unrecoverable playback error: The parameter is incorrect. (0x80070057) through Google returns not very helpful results, other than the one potentially mentioning DRM. This issue I am having a very hard time resolving, and am wondering if anyone here has experienced similar issues after updating.

    Read the article

  • Laptop battery: is voltage really important to respect?

    - by Fox
    I got an Acer Aspire 5100 and I just bought a new battery (after the stock battery just died yesterday). But I saw something after buying and I'm wondering whether it's really important or not. My stock battery was a 6-cell 4000mah 11.1v and the new battery is an 8-cell 4800mah 14.8v . I know that 8-cell and 4800mah is okay, but what about the 14.8v instead of 11.1v? The battery description says it's compatible with my laptop model (AS5100, model BL51), but the voltage difference makes me wonder. Will the laptop only take what it needs? Or will it be getting 14.8v straight in the brain? I know that my wall plug claims to output 19v, so logically I'm thinking a higher voltage battery shouldn't be a problem. Am I correct in thinking this? Thanks in advance for your answers!

    Read the article

  • Setup 2003 R2 Radius server to work on vista/seven

    - by Fox
    Hi All, I'm currently trying to configure my 2003 R2 server RADIUS module to enable WIFI client to authenticate throught my Active Directory. The RADIUS server use MS-CHAP V2 as encryption method. I got several Access Point running DD-WRT, configured to use WPA2-Enterprise security that use Radius Server. Everything is setup, and almost working. When I say almost working, I mean, I can login using my AD Credential on my IPod or even on a MacBook running OS X, Windows XP also work with some little tweak in connection properties. The problem is Windows Vista or Windows Seven clients computers that are not inside domain. It doesn't work at all, it doesn't even prompt for user/password/domain. I already install the patch for IAS to make the certsrv compatible with Vista and Seven, but still doesn't work. Anyone ever encounter the same issue I have right now? I'm searching for a solution to this for several already and still not find anything. Looks like many people have the same issue too. Thanks all for you eventual answers.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8  | Next Page >