Services, Tools, Tutorials

Twitter streaming APIs returning unauthorized message to cURL

Twitter recently published the new 1.1  Streaming APIs discontinuing the previous one, with this new APIs the authentication method changed and the user:pass pair is no more enough, now you need to:

  1. Create your app at https://dev.twitter.com/apps
  2. Create the access token from your app’s details page (refresh after a while, it takes few seconds and the page doesn’t autorefresh)
  3. Go to the OAuth tool tab and insert the URI you want to query, the query parameters and the request type, then click the button to generate the OAuth signature for your request.
  4. The page is now showing the cURL command, copy and paste on your terminal and you’re done

 

Advertisements
Mac, Tools, Tutorials

How to put an ISO image on a USB drive on OSX

DiskUtility doesn’t let you restore a volume using an ISO image, only DMGs are accepted, otherwise it prompts you an error.

diskutility

Here’s a workaround using osx hdiutil and unix dd command :

  1. open your terminal and cd to the directory where your .iso file is
  2. convert your iso to a dmg by typing “hdiutil convert -format UDRW -o myoutput.img mysource.iso”, depending on how large is your file it may take different amounts of time and print out the path to the created dmg (in this case “/path/to/myoutput.img.dmg”)
  3. once done you’ve to list your mounted disks with “diskutil list” and unmount the usb volume (not the device!!!) with “diskutil unmountDisk /dev/disk1”
    NOTE: change disk1 with whatever disk number your destination drive is
  4. now restore the dmg image to your usb drive with the dd command by typing “sudo dd if=myoutput.img.dmg of=/dev/rdisk1 bs=8m”
    NOTE: change rdisk1 with whatever disk number your destination drive is, if it was disk2 use rdisk2 and so on…
    NOTE2: 8m means “8Megabites per second”, feel free to edit this param according to your needs
  5. when the command ends it prints out a stats report including total bytes transferred and time elapsed.

Hope this helps

C\C++, Mac, Tools

Resolving symbols conflict between libraries on OSX with objcopy

Recently I had to deal with symbols conflict between C\C++ libraries and found this solution on stackoverflow:

In order to solve the issue on a mac it’s a bit you’ll need to run objcopy… but there’s no objcopy available on osx!!!

I worked around it and installed homebrew, a package manager for osx that reminds me ubuntu’s apt.

Homebrew is VERY easy to install, just copy\paste the ruby script on your terminal and it’ll download and install everything you need. Moreover it’s the cleanest solution I found so far on a mac because it’s installing ONLY on its directory (and you can choose the directory where you want it set up).

Actually there is no brewed formula to install objcopy and objdump (“brew search objcopy” returns nothing) but there’s a formula named “crosstool-ng” which is installing “gobjcopy” and “gobjdump” which are actually the same programs!

So just type

brew install crosstool-ng

on your shell and, when you’re done, edit your ~/.profile adding the following

alias objcopy="gobjcopy"
alias objdump="gobjdump"

to create aliases to those programs.

Now you’ve objcopy and objdump on your mac 😉

Flash, Tools, Tutorials

Install Flash Switcher extension on unsupported versions of Firefox

Today I had to install the must-have flash switcher extension for firefox (by Alessandro Crugnola) and I found that it’s not compatible with firefox versions after 3.0 …

I trust in sephiroth’s extension going to work properly even in unsupported firefox versions, and however it’s worth the attempt, so, how to install it anyway?

First of all, download the flash switcher extension from the mozilla addons site ( https://addons.mozilla.org/en-US/firefox/addon/5044/ ) and save it on your hard drive.

Now that you have the .xpi file rename it to .zip and decompress it, you’re getting a plugin and content folders, chrome.manifest and install.rdf files.

Open install.rdf with a text editor and examine this tag


here min and max versions are defined for the extension, so just change em:maxVersion from 3.0pre to 3.8 (or whatever) and save the file.

Now select all files and folders (not the parent folder!!!) (plugin, content, chrome.manifest, install.rdf) and zip all together, then change the extension from .zip to .xpi.

Open firefox, File>Open, browse to the .xpi file, install… done and working!! w00t! 🙂

My unsupported (but properly working) version of firefox is 3.6.8, the flash switcher extension version is 2.0.2.

enjoy 🙂

ActionScript 3, Tools, Tutorials

Check a Class type with describeType and getQualifiedClassName

Recently I faced this problem: how to get if a Class is extending another one or implementing an interface?

this is the specific case:

function checkType(toCheck:Class,typeClass:Class=null,typeInterface:Class=null):Boolean
{
// if an instance of toCheck is a typeClass or a typeInterface
// return true
// else
// return false
}

The task is quite simple, the first solution would be get an instance of toCheck and use the is operator to actually check the type…but this would mean both a waste of resources and an “unwanted behaviour generator” (just think about a parser class instantiated without a real need or something like that).

Nope, that solution sucks.

Let’s try something better, let’s make the player inform us which is the toCheck class structure, let’s use describeType.

describeType is a wonderful function you can find in flash.utils package, it examines an untyped object and returns an xml document containing the description of that type (more details at adobe livedocs)…something like this:

NOTE: click on “view code” to see the real xml document, my wp is escaping tags chars <> …:

<type name="flash.events::EventDispatcher" base="Class" isDynamic="true" isFinal="true" isStatic="true">
  <extendsClass type="Class"/>
  <extendsClass type="Object"/>
  <accessor name="prototype" access="readonly" type="*" declaredBy="Class"/>
  <factory type="flash.events::EventDispatcher">
    <metadata name="Event">
      <arg key="name" value="deactivate"/>
      <arg key="type" value="flash.events.Event"/>
    </metadata>
    <metadata name="Event">
      <arg key="name" value="activate"/>
      <arg key="type" value="flash.events.Event"/>
    </metadata>
    <extendsClass type="Object"/>
    <implementsInterface type="flash.events::IEventDispatcher"/>
    <constructor>
      <parameter index="1" type="*" optional="true"/>
    </constructor>
    <method name="willTrigger" declaredBy="flash.events::EventDispatcher" returnType="Boolean">
      <parameter index="1" type="String" optional="false"/>
    </method>
    <method name="hasEventListener" declaredBy="flash.events::EventDispatcher" returnType="Boolean">
      <parameter index="1" type="String" optional="false"/>
    </method>
    <method name="removeEventListener" declaredBy="flash.events::EventDispatcher" returnType="void">
      <parameter index="1" type="String" optional="false"/>
      <parameter index="2" type="Function" optional="false"/>
      <parameter index="3" type="Boolean" optional="true"/>
    </method>
    <method name="dispatchEvent" declaredBy="flash.events::EventDispatcher" returnType="Boolean">
      <parameter index="1" type="flash.events::Event" optional="false"/>
    </method>
    <method name="addEventListener" declaredBy="flash.events::EventDispatcher" returnType="void">
      <parameter index="1" type="String" optional="false"/>
      <parameter index="2" type="Function" optional="false"/>
      <parameter index="3" type="Boolean" optional="true"/>
      <parameter index="4" type="int" optional="true"/>
      <parameter index="5" type="Boolean" optional="true"/>
    </method>
    <method name="toString" declaredBy="flash.events::EventDispatcher" returnType="String"/>
  </factory>
</type>

As you can see in this EventDispatcher type description there are two nodes witch are fitting the task’s purposes:

<extendsClass> and <implementsInterface>

Those nodes are repeated for each class or interface in the given class (toCheck) chain of inheritance and they contain the qualified class name string of the extendedimplemented classinterface.

In this case EventDispatcher extendsClass type=’Object’ and implementsInterface type=’flash.events::IEventDispatcher’ …quite clear right?:) Now, back to the implementation:

function checkType(toCheck:Class,typeClass:Class=null,typeInterface:Class=null):Boolean
{
	//gets the toCheck class type xml description
	var _typeXML:XML=describeType(toCheck);
	//gets the typeClass and typeInterface qualified class names
	var _result:Boolean=false;
	if (typeClass) {
		// if toCheck is a typeClass
		for each (var _extClass:XML in _typeXML.factory.elements('extendsClass')) {
			if (_extClass.@type==getQualifiedClassName(typeClass)) {
				_result=true;
				break;
			}
		}
	}
	// do the same for typeInterface but checking 'implementsInterface' node
	if (typeInterface) {
		for each (var _impInterface:XML in _typeXML.factory.elements('extendsClass')) {
			if (_impInterface.@type==getQualifiedClassName(typeInterface)) {
				_result=true;
				break;
			}
		}
	}

	return _result;
}

…and the task got done 🙂

stay tuned 🙂

Flex, Javascript, Tools

Auto generate getters setters and custom code in Flex builder

Recently I’ve been searching for a plugin for eclipse, a tool, *something*, able to generate code snippets on the fly. This lack of eclipse IDE is filled by a project called Eclipse Monkey, a dead (yes…dead..-.-‘) component of  Project Dash which enables Eclipse to execute javascript functions on demand.

Eclipse Monkey will put a “scripts” menu on your Eclipse menu bar which is populated by the list of scripts (.js) inside the specified folder.

Here’s my Scripts>Actionscript dropdown menu

Installation:

1) Add project dash site ( http://download.eclipse.org/technology/dash/update )  to your eclipse’s update sites,
2) Restart eclipse,
3) Run create test project by selecting scripts menu,
4) Download actionscript snippets lib from here

…great deal 🙂

Here’s a video showing Eclipse Monkey at work

[flash http://www.youtube.com/v/z9aL_OZzRJk&hl=en&fs=1 w=400 h=310 mode=1]

UPDATE:

take a look to “Pimp my Eclipse” post from Lee Brimelow (part 1 and 2) for further customizing your eclipse installation 🙂

Flash Player, Tools, Tutorials

Trace on a shell

Since it has been created i’ve been a fan of flash tracer extension, i really fell in love with that tool, but i noticed it slow down the browser and can even make it crash.

So, let’s open a trace logger on our terminal…

To do that the right command is “tail” which actually “[…]Print  the  last 10 lines of each FILE to standard output[…]” and the file to open is located in /Users/[your username]/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt

Then, let’s do something good and useful with that:

open your TextEdit, cmd+shift+T to switch to plain text, write down this one line command:

tail -f /Users/[your username]/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt

save the file as “flashtracer.sh” and use sh as file extension instead of txt.

then right click on the file, reach the “open with” menu and choose “terminal” application located inside utility folder. Note: it would be great if you set terminal as default application to open that file 🙂

ok, now everything’s ready; double click on flashtracer.sh and start tracing 🙂

Note: remember you’re in a shell now, so you can clear up the lines with cmd+K…

I hope it can be useful,

byez 🙂