Showing posts with label how to. Show all posts
Showing posts with label how to. Show all posts

Thursday, October 9, 2014

Python and Google Apps Provisioning with the Admin SDK Directory API

After wading through documentation, blog posts, and StackOverflow answers I've finally figured out a way to authenticate using OAuth 2.0. Since we didn't want to have to interactively grant "user consent" for each of our domains, this is acting as a "web server" for computer-computer interactions.

I assume that you have Python 2.7 installed (three shalt thou not use), but I'd recommend installing Anaconda to make your life easier for all of this. You'll also need to install the Google APIs Client Library for Python.

EDIT: I was finally able to get it to work with the default SignedJwtAssertionCredentials.
 as well as PyCryptoSignedJWT. To install PyCryptoSignedJWT, download and unzip, then from the command line (in the directory you unziped to) type python setup.py install in order to install.

The next step is to set up your project. Here's the documentation from here to "Set up your API":
  • Enable the API access from the Admin console in order to make requests to the Directory API. To enable the API, log in to your admin account and select Security. If you do not see Security listed, select More controls and then Security from the options shown in the gray box. Select API reference, and then select the checkbox to Enable API access. Save your changes.
  • Set up a new project in the Google APIs Console and activate Admin SDK service for this project. See the Google APIs Console Help in the upper right corner of the Console page for more information about creating your API project.




Still in the Developers Console, you'll need to create credentials for your project. Click on Credentials (under APIs) and click the button Create new Client ID and then select Service account.


Download the key file, and make a note of the private key password (which is always "notasecret"). Then click the Okay, got it button.

You'll need to make a note of the Service Account EMAIL ADDRESS that is displayed (a long string of characters ending in @developer.gserviceaccount.com) and the CLIENT ID (the same string ending with .apps.googleusercontent.com).

The next step requires you to authorize your API client to access your admin console. Assuming your're still logged in to your Super Admin account, go to Manage API client access (or go to Security, Advanced Settings, Authentication, Manage third party OAuth Client access). For the Client Name, paste in the CLIENT ID that you noted previously. In the One or More API Scopes, put in a comma-separated list of the scopes that you'll be using. For our example I'd suggest https://www.googleapis.com/auth/admin.directory.user, https://www.googleapis.com/auth/admin.directory.orgunit (you can always change this later). Then click the Authorize button.



The file you downloaded previously will be something like APIProject.p12 but we'll need to convert it to a PEM file. On a Mac or Linux machine this can be done from the command line ( openssl pkcs12 -passin pass:notasecret -in APIProject.p12 -nocerts -out APIProject.pem ), but on Windows other software is required (try Win32OpenSSL that can be downloaded from here). As a last resort for those who don't worry about security, you can convert it using this site.

So you now have a p12 key file, a Service Account Email Address, and of course your Super Admin account. You're set to start writing some code. I like the Spyder development environment that is installed with Anaconda, but feel free to just use Notepad (or Notepad++) if you're so inclined.

Here's the minimum Python code that works for me, fill in the appropriate values for yourself.


superAdmin = 'you@example.com'
serviceAccount = 'somethingorother@developer.gserviceaccount.com'
pemFile = 'APIProject.p12'
scope = 'https://www.googleapis.com/auth/admin.directory.user'

import httplib2
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials

keyFile = file(p12File, 'rb')
key = keyFile.read()
keyFile.close()
credentials = SignedJwtAssertionCredentials(serviceAccount,
  key,
  scope,
  prn=superAdmin)

http = httplib2.Http()
httplib2.debuglevel = False #change this to True if you want to see the output
http = credentials.authorize(http=http)
directoryService = build(serviceName='admin', version='directory_v1', http=http)

# You are now authenticated, so you can say something like this:
user = directoryService.users().get(userKey = 'me@example.com')
print user.execute()



Hopefully that's enough to get you started. The documentation about what you can do with the Admin Directory API is here. just remember that some of them will require you to declare other scopes.

Friday, June 10, 2011

setting up Moodle Language Lab

Moodle Language Lab is an activity module developed (and being developed) by Campus Saint-Jean and Oohoo.biz that:
replaces the traditional cassette tape language lab. There is a module for students to record themselves and teachers to review and grade the work. This version also includes a class monitor. So, if a teacher uses it inside the classroom, he/she can monitor student progress the same way they used the traditional language lab by listening to live streams of the students, responding live to students, giving a thumbs up and so on.
It also offers an integration with the Moodle WYSIWYG, allowing recordings to be done virtually in any activity or resource wihtin Moodle. This feature has been used in our classes throughout the past year. For example, we had an oral forum instead of a written forum. Professors would leave spoken messages in the grade book.
It requires three programs running on a server (on the same server or separate ones):
  1. Moodle 2.0.x
  2. Red5 Media Server (version .8)
  3. Palabre XML Socket Server edit: Palabre is no longer needed
Here's how you can set up the three parts of Moodle Language Lab on a Windows server. The process will be similar for other operating systems.

Red5
  1. Download version .8 from code.google.com/p/red5/ (I recommend the ZIP file, and 1.0 RC1 worked for me)
  2. Unzip the files into some folder (not publicly accessible)
  3. Install Java, if it's not already installed, and make sure your JAVA_HOME variable is defined
  4. Run Red5.bat
  5. Go to http://localhost:5080/ to test that Red5 is running, and click "Install a ready-made application"
  6. Install the oflaDemo
  7. Make a note of the server's Internet-accessible IP address (or FQDM)
Palabre
  1. Download the source files (Windows installer didn't work for me), untar into some folder (again not a publicly accessible folder)
  2. Install Python (2.7 or so)
  3. Edit the Palabre\etc\palabre.conf file, these are the two lines that I changed
    • ip = 
    • alloweddomains = 127.0.0.1 moodle.______.ca #put your own value(s) on this line
  4. Run Palabre.py
  5. Test by running one of the Palabre clients
  6. Make a note of the server's Internet-accessible IP address (or FQDM)
Moodle (this is just pasted from the Developer's readme file)
  1. copy all folders (filter, mod, lib ) into the appropriate moodle(root) folder.
  2. Login to Moodle with admin rights.
  3. In the Site Administration block, click on Notifications. This will setup the database tables for the languagelab module
  4. In the settings block, select Site administration -> Plugins -> Activities Modules -> Manage activities -> Language lab -> settings
  5. Enter the IP address or the FQDN that you noted previously in the appropriate fields and save changes.
  6. You're done. Go into a course, turn editing on and add a language lab activity.

Tuesday, April 26, 2011

Xbox 360 tool control mat

Inspired by a blog post about making tool control mats with a CNC router, I made a "tool" control mat for a video game club's shelf.

Using Inkscape I imported a vector drawing of the 360 gamepad by grumbel on the Open Clip Art Library as the basis for the outline of the controller, resized it to the dimensions on the Wikipedia page, and made 12 copies of it (since that's how many controllers the club owns).


The slots for the games were just rectangles using the dimensions from another Wikipedia article. I discovered that I had to convert these objects to paths (under the Path menu in Inkscape) before I saved the file as a DXF file (or PDF file, depending on which CAM program you're using).

I converted the drawing to G-code for a 1/2 inch end mill as a roughing pass, thinking that I'd then do a finishing pass with a smaller bit, but decided that it was good enough after the first pass. I milled it from two inch thick extruded polystyrene foam (Styrofoam), then cut it down to size on a radial arm saw (which explains the mistake you see on the side in this last photo).

Not bad for my first successful CNC project, if I do say so myself.

Tuesday, April 19, 2011

CAD CAM CNC routing workflow

After experimenting with many different programs for CAD (3D design) and CAM (turning that design into code for a CNC router), I've come up with a good workflow using easy and free tools:


The process that works for me is
  1. design a 3D model in Sketchup
  2. export the model to an STL file using the guitar-list.com plugin
  3. load that STL file into FreeMill
  4. generate the toolpath and post it to a G-code text file
  5. import the G-code into Mach3 and run it on the CNC machine
Hopefully this will be simple enough for students to start designing and cutting things.

Friday, April 8, 2011

disabling user input

For example, if you are running Xibo for digital signage and don't want anyone to be able to close the program (or do anything on the computer).

Using AutoIT, the following script (which can be compiled to an .exe file) will block user input until a Notepad window is detected, which is just my way of saying BlockInput forever.

BlockInput(1)
WinWaitActive("Untitled - Notepad")


Unfortunately this does not block the "three finger salute" (Alt Ctrl Delete). Using AutoHotkey, which I am somewhat more familiar with, you can disable the task manager. Again this can be compiled into an executable.

; This script disables the task manager, and re-enables it with the key combination Windows + 1

Regwrite, REG_SZ, HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\taskmgr.exe, Debugger, Hotkey Disabled
return

#1::
gosub Enable
return

Enable:
RegDelete,HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\taskmgr.exe
return

ExitSub:
RegDelete,HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\taskmgr.exe
ExitApp
return


And to call this compiled script from the AutoIt script that we first talked about:

BlockInput(1)
RunAs(username, @ComputerName, password, 2, DisableTaskManager.exe)
WinWaitActive("Untitled - Notepad")



Edit:
It seems that AutoIT has RegWrite and RegDelete functions, of course. I rewrite the script(s) accordingly.

Friday, March 11, 2011

iPad Guitar version 3

On episode 1422 of Buzz Out Loud, JC from San Diego suggested an iPad guitar with iPhones as frets. I only had one iPhone lying around, so I had to use my Android phone and my old iPod Touch. I used Lego for the neck, since Mega Bloks are a little bit big.




I think the next step will be to carve something like this out of a 2x4.

Monday, March 7, 2011

iPad Guitar from Mega Bloks version 2

I built a better version of my original iPad Guitar with Mega Bloks.


(Dis)Assembly video

I'm learning how to drive a CNC router, so a wooden version may be forthcoming.

Friday, March 4, 2011

iPad Guitar with Mega Bloks

Playing with Mega Bloks tonight with my kids, I remembered Brian Tong mentioned on Buzz Out Loud about iPad GarageBand needing a guitar-shaped case. So we built something.




(Dis)Assembly video

Maybe I'll build something out of wood after GarageBand comes out. With pegs for a guitar strap.

---
Update I've built a better version.

Wednesday, February 25, 2009

email reminders with Google calendar

Whether you have recurring events, or just events that you don't want to miss, it's possible to set up reminders for yourself using your Google calendar. These reminders can email, pop-ups on your computer (if you have your calendar open), or even text messages (SMS) to your mobile phone.

If you have your calendar open, perhaps from calendar.google.com, click Settings at the top right, then the Calendars tab near the top middle. You'll see a link for Notifications for each of your calendars. This allows you to change the default notifications, I'd recommend setting it to Email 3 hours before each event, but you can also change the notification types for individual events.

You'll also see options for setting up your mobile phone, calendar sharing/publishing, and many other things. Have fun.

Wednesday, January 21, 2009

making a password protected website with Google sites

If you find that you need to have information available on the Internet to a limited number of people, perhaps your students, you can create a website using Google Sites. Google Sites can be used with a regular Google (Gmail) account, or with a Google Apps account (as I've discussed before.

When creating your site, you can specify if you want it viewable by the whole world, anyone from your domain, or specific users. You can also invite users to be collaborators, meaning that they can edit the pages on the site.

One thing to be careful of, however, is that it seems the option "Anyone at may this site." is not the default option. If you don't want your students to edit your site, you'll want to change that.

Wednesday, January 7, 2009

digital marking

There are a few different ways I have students hand in digital assignments. For larger projects (video and audio files mostly) the students can just save them in their profile folders or on our school media server. However if you don't have this set up, or if you want to be able to do marking at home, there are a few other ways.

USB flash drives: either student or school provided, students can save their work to individual flash drives, or have multiple students save their files on a single flash drive.

Email: I usually have students email their completed assignments to me, since we have gmail accounts set up for students and teachers with about 7 GB of storage space each. I can then mark the assignments on any computer with Internet access.

TurnItIn.com: our district subscribes to this website which provides originality checking and online marking, as well as opportunities for peer review.

Learning Management Systems: online systems can be set up for assignment submission as well as peer interaction et ceteras using something like Moodle or Ning.

I'm sure there are other ways that teachers are marking digital assignments, but these are just a few I've experimented with. Feel free to comment on some of the systems you've used or seen in use.

Wednesday, December 17, 2008

creating your own blog

Chances are, if you're reading this you know what a blog is. If you're not blogging already yourself, I wanted to recommend Google's free blogger.com. Creating a new blog is very easy, especially if you already have a gmail address, and it's very easy to create new posts on your blog.

As well, you may have noticed that there is a "listen now" button for each of my blog posts here, that's a free service from odiogo.com. That's also relatively easy to set up, and then you can say that you are also a podcaster, since your blog posts are automatically converted into audio files that can be subscribed to.

Friday, December 12, 2008

Sunday, December 7, 2008

Make a lighted button out of an LED puck lamp

I've made a few of these for some classes at my school.



In case you're curious, here's the Instructable.

Thursday, December 4, 2008

converting midi files to mp3s

A somewhat more obscure topic, but hopefully of interest to some. You may have some (musical instrument digital interface) midi files recorded on a synthesizer or downloaded from the Internet; these are music files that the computer (or synthesizer) plays and are essentially like sheet music. In order to play these on a CD player or mp3 player, they need to be converted to sound files (mp3, wav, or others).

There is software for doing this, but an online one that I've used is on hamienet.com. Unfortunately the site launches some "pop-up" advertising, but you can just close those windows. The process for creating an mp3 from a midi file should be fairly evident from the instructions on the page. It basically involves uploading the midi file by clicking the Browse button, then setting the options (or leaving the options as they are), and clicking Convert File. After it converts the file, it gives you the option to download it as an mp3, which can then be put on your music player or burned to an audio CD.

clearing calculators

Since most of the calculators students are using these days, particularly in High School, can store notes and programs, we need to be able to ensure that there is nothing stored in them during exams.



At many schools this is accomplished by clearing the memory and having the supervisors look for the "Memory Cleared" screen:




The keys that you press in order to clear the most common calculators (TI-83+, TI-84+, and the TI-Nspire) are:

Wednesday, November 5, 2008

classroom projector and speaker connections

Since most of us aren't using TVs in the classroom anymore, the question seems to be coming up often about how to connect speakers to play videos. Usually the teacher wants to be able to play videos from a DVD/VCR as well as from the computer, and perhaps from an iPod.

You could, of course, have a separate set of speakers for each of these purposes, but it's easier and cheaper to have one set. To do this, you can connect the DVD/VCR audio output to the speakers and the computer audio output to the audio input of the DVD/VCR.

To connect the computer audio output to the DVD/VCR, use a 3.5mm Stereo Plug to 2 RCA Plug cable connected to the speaker (or headphone) output of the computer.

To connect the DVD/VCR to computer speakers, you need another 3.5mm Stereo Plug to 2 RCA Plug cable connected to the audio output and a headphone "gender changer" for connecting the male end of that cable to the male end of the speaker cable. Instead of a "gender changer", however, you can use a headphone splitter which also allows you to plug in your iPod without unplugging anything.

Of course if you use speakers with RCA inputs, such as the Behringer MS16s, you can just connect the DVD/VCR audio output with the RCA cable that came with the DVD/VCR.

If you want to show videos from your iPod and your DVD/VCR has a second "line in" connection (other than the one you are using for your computer), you can use an iPod video cable that connects to the headphone jack or to the dock connector. Of course if you have a newer iPod these cables won't work, you'll need to buy an expensive one from Apple. Or plug your iPod into your computer with a USB cable and show the videos using iTunes.

As to video to the projector, computer video goes over a VGA cable and the DVD/VCR video goes over an S-Video cable, composite cable, or component cable.

That ended up being a longer post that intended, and a bit of a commercial for monoprice.com (one of my favourite online retailers), but hopefully there was enough information there to get you set up.

Wednesday, October 29, 2008

InteGrade Pro

In our district we use the marks program "InteGrade Pro". While there are user manuals and help files available, a colleague and I have prepared a document that summarizes some of the common tasks and questions.

Wednesday, October 8, 2008

online storage

Last week's post was about cloud computing, so on a related note let's explore free online storage options.

There are a number of companies that allow you to store files online for free ("file hosting services") for personal use, public sharing, or a combination of the two. These are sometime ad-supported and sometimes supported by a premium tier. Or else the company is just offering the service for good will and to build their brand.

Some that I've used and liked are:
Box.net - 1 GB, ad-supported, many features
SkyDrive - 5 GB, pretty easy to use, by Microsoft
DropBox - easiest to use once set up, automatic syncronization
YouSendIt - mostly for emailing large files (upload the file then email a link to the recipient)
Mozy - 2 GB, designed for data backup

There are, of course, others available.

I should also point out that your data are not necessarily secure as soon as you upload it somewhere else, such as to one of these sites. As well, there may not be any guarantees of availablility of your files, particularly with free services. That being said, I find these very useful.

Edit: SmashingDownloads has a more comprehensive list of free online storage options.

Wednesday, October 1, 2008

Google Apps Education Edition

I've talked before about Google Apps Education Edition with respect to student email addresses, but I wanted to revisit the other things that are included with this. Hopefully without sounding too much like a commercial.

Create, Edit, and Share Documents
Google Docs is like an online Office Suite. It includes a word processor, as well as spreadsheet and presentation programs. I've used it for student assignments (both that I assign and that they submit) and for sharing lab data amoung the students. Not quite as many features as Microsoft Office, but available from any computer with an Internet connection.

Calendar
The interface of Google calendar is, imho, better than any other calendar software I've used. It also allows for private, public, and shared calendars. I've used it for class test schedule reminders (embedded in my website) as well as for staff supervision scheduling. You can even integrate your calendar with out district's mandated school site. And it syncronizes with my iPod Touch.

Sites
Quick and easy way to create feature-rich websites for your domain, of which my website is an example. Teams, clubs, and even individual students can create "sites" if it is enabled.

All of these features, and a few that I haven't mentioned, can be enabled or disabled as you see fit. Google Apps Education Edition is not without its shortcomings, as I've mentioned, but I do have to say that I'm a big fan.