text stringlengths 454 608k | url stringlengths 17 896 | dump stringclasses 91
values | source stringclasses 1
value | word_count int64 101 114k | flesch_reading_ease float64 50 104 |
|---|---|---|---|---|---|
i.frame
What is i.frame?
i.frame is a platform for events in the information space developed for “iamas open_house: 2021“, an online event held by the Institute of Advanced Media Arts and Sciences [IAMAS]. We derived the name i.frame from “iframe” (inline frame), which is one of the basic HTML elements in web technology and is used to embed another page on a page. Using this technology, instead of gathering all the various installations and sessions distributed on the Internet in one place, you can provide cohesion and coherence for a limited period during an event. In addition, by providing chat using two media, voice and text, we aimed to make people from different places feel as if all participants gathered in the same place.
Features of i.frame
The key things you can do with i.frame:
- Provide cohesion and coherence temporarily to a group of Web sites distributed across the Internet and compose an event
- Provide voice and text chat for participants to talk to each other
- Mix different forms of programs such as installation and session
- Provide ways for both anonymous and registered users to participate
- Provide both the website URL and the individual event URLs as participation routes
- Send notifications to all participants
- Support both desktops and smartphones
- Provide UI and various information in both English and Japanese
- Easily update with Google Sheets as a database front end
Terminology
Key terms
- Event: a whole consisting of a group of programs (e.g., iamas open_house: 2021)
- Program: the unit that composes an event
- Installation: a program that participants can view at any time during the event
- Session: a program that participants can join only during a specific period
- Chat: a function that allows communication by voice or text; the unit is a channel
- Initially set to mute when a participant joins a chat, the participant can unmute
- Participants who do not wish to or cannot speak by voice can also participate by text chat
- Notification: messages from the operator that appear at the top of the website
- Tag: text strings that relate between programs (tags can also contain their explanatory text)
Differences between installation and session
Differences between anonymous users and registered users
Setup
Tested local environment
- Node v14.17.5
- npm 6.14.14
- yarn v1.22.17
GitHub settings
- Fork this repository.
- Create a clone of the repository on your local computer.
Vercel settings
- Log in or sign up with your GitHub account at. (When you sign up, you will be asked to allow access from Vercel.)
- Click the [New Project] button in the upper right corner.
- In [Import Git Repository], select the repository you just forked and import it.
- If you don’t see the GitHub account you want, add the GitHub account you wish to install Vercel from the list of namespaces.
- If you see the GitHub account but not the repository you want, click Adjust GitHub App Permissions to grant permissions to Vercel.
- In the Build and Output Settings, enable OVERRIDE for BUILD COMMAND, and enter
CI='' npm run build.
- Click the Deploy button to start the deployment, and wait for a few minutes until the deployment finishes.
- The screen will switch to another one when the deployment is finished, so click the Go to Dashboard button to return to the dashboard.
- Note: Every time the main GitHub branch is updated, it will be deployed automatically.
- The first time you deploy, the domain will be automatically set based on the project name (e.g.,
iamas-open-house-2021.vercel.appif PROJECT NAME is
iamas-open-house-2021). Click on the View Domains button and set it if you want to change it (note: this button may not be displayed if the screen’s width is too narrow). Keep the finalized origin of your public website (e.g.,) (note that since it is an origin, it does not contain a trailing slash). Agora settings
- Go to and register for an account.
- After registering an account, the first project you create will be for testing and demonstration purposes. Once the project is created, complete the necessary settings, including credit card registration.
- Click on Project Management on the left side of the screen and click on the Create button to create a new project. In this step, specify Secured mode as the Authentication Mechanism.
- Click on Action of the project you created in the Project Management screen, and copy the App ID in the App Configuration and the Primary certificate in the App certificate, and keep them in a safe place. - Mouse over the account name in the upper right corner of the screen, and select RESTful API from the list that appears. On the screen that appears, click Add a secret, and then click the Download button that appears in the Customer Secret field to download the key and secret information. Firebase settings
Things to do in the Firebase Console (Part 1)
- Go to and sign in with your Google account.
- Click Go to console in the upper right corner of the screen.
- Click Add project and enter a project name to create it (configure Google Analytics if necessary).
- Select Build > Functions from the list on the left of the screen, and click Upgrade project. Make sure the Selected plan is set to Blaze and click the Purchase button to purchase the plan (set the Budget alert if necessary).
- Click on the cog to the right of Project Summary and select Project settings from the list that appears, and keep the Project ID in the screen that appears. - Click Build > Firestore Database from the list on the left of the screen, click the Create database button on the screen that appears, select Start in test mode, and click the Next button. Under Cloud Firestore Location, select a location close to where the application will be used and click the Enable button to enable it.
Things to do on your local computer
Create
firebase/.envby copying
firebase/.env.samplefrom the cloned repository, and enter your Agora credentials and the origin of the website you want to publish.
Replace
projects.defaultin
firebase/.firebasercwith the Firebase Project ID.
Execute the following command in the directory of the cloned repository to set up Firebase.
yarn setup:firebase
Run the following command to reflect the source code to Firebase.
yarn deploy:firebase
Google Apps Script settings
Things to do on Google Cloud Console
To update Firestore from a spreadsheet, refer to the Google Workspace Admin Help article “Create a Service Account” to create a service.
- Step 1: Create a project
- Follow the instructions up to the second item.
- Do not proceed to the third item. But instead, select the project you created in Firebase in the Manage Resources screen.
- Step 2: Turn on the APIs for the service account
- Follow the instructions up to the second item. (If the project displayed at the top of the screen is not the one you selected in “Step 1”, select it from the list view.)
- In the third item, enable Admin SDK API and Google Cloud Firestore API.
- Step 3: Set up the OAuth consent screen
- Follow the instructions to the end.
- Step 4: Create the service account
- Follow the instructions up to the second item.
- In the third item, Service account name can be any name. In the next section, “Grant this service account access to project,” add two roles: Basic (or Project) > Editor and Cloud Firestore > Cloud Firestore Editor.
- Regarding the seventh item, click the one whose e-mail address is
*@*.iam.gserviceaccount.comin the list displayed in the Service accounts screen and then click the KEYS button displayed at the top of the screen.
Things to do on Google Sheets
- Make a copy from the Template of Google Sheets.
- Navigate to Extensions > Apps Script and replace
{client_email},
{private_key}, and
{project_id}in
_getCertData()defined at the end of
api.gswith values in the private key JSON file you downloaded, respectively.
- Click the Execution log button to enable the execution log, and execute
installation.gs,
session.gs,
registered.gs,
tag.gs, and
notification.gsone after another. If they are executed without any problems, “
Execution completed” will be displayed at the end of the log, confirming that you have proceeded to the end.
- Note: These scripts can also be executed by clicking the Reflect this sheet button in the upper right corner of each sheet in the spreadsheet Installation, Session, User, Tag, and Notification.
- Visit the Firebase console and navigate to Build > Firestore Database > Data to confirm that the contents have been registered in the database.
Deploy
Things to do in the Firebase Console (Part 2)
- Navigate to Project Overview > Project settings > Your apps, click the
</>button, enter the nickname of your app, and keep a note of the contents of
firebaseConfigfrom the code displayed in SDK setup and configuration. - Keep a note of the URL listed in Build > Functions > Dashboard > Trigger column (note: if you can’t see the Dashboard, reload the page). Things to do on Vercel
From Project Settings, open the Environment Variables tab and add the necessary environment variables.
In the Deployments tab, display the list of deployments, click the
⁝button on the right side of the deployment you just performed, select Redeploy from the menu that appears, and deploy it again.
Customize
Customization by modifying the source code
- I want to change the event name
- Rewrite the content of the
<title>tag in
src/components/Head.js.
- Rewrite the values corresponding to the key
welcome_notesin
src/configs/i18n.js(
enand
ja).
- Rewrite the content of the
<StepContainer isShow={step === 0}>block in
src/components/Splash.js.
- Rewrite the content of the
<Heading2>tag in
src/components/Typography.js.
- I want to change the description of the screen displayed when people visit the site
- Rewrite the relevant parts of
src/configs/i18n.js(
enand
ja).
- I want to change the content of the page displayed by clicking/tapping About this event in the upper left corner of the screen
- Rewrite
src/pages/About.js(
enand
ja).
- I want to change the date(s) of the Session schedule displayed by clicking/tapping Session list.
- Rewrite the content of the
<Wrapper>tag in
src/pages/Timetable.js.
- Rewrite the date specified in
useState()in the same file to set the date to be selected in the initial state.
Customization by modifying the spreadsheet
- Registered user
- Tag
- Installation
- ID
- Title: the title of the installation (in English and Japanese)
- Representative user: the ID of the corresponding registered user
- Details: the description of the installation (in English and Japanese)
- Path: the path of the dedicated web page (
{origin}/installation/{path}) - iframe: the URL of the web page to be displayed in an iframe
- Thumbnail: the URL of the thumbnail image
- Tag 1 to 3: the IDs of the corresponding tags
- Public status: whether or not to show the installation in the Active installations section of the home screen (value:
TRUE= public,
FALSE= not public).
- Session
- ID
- Title: the title of the session (in English and Japanese)
- Representative user: the ID of the corresponding registered user
- Details: the description of the session (in English and Japanese)
- Path: the path of the dedicated web page (
{origin}/session/{path}) - iframe: the URL of the web page to be displayed in an iframe
- Thumbnail: the URL of the thumbnail image
- Tag 1 to 3: the IDs of the corresponding tags
- Date: the date to be displayed in the Session Schedule of the session list (format:
yyyy/mm/dd)
- Start time: the start time of the session (format:
yyyy/mm/dd HH:MM:SS)
- End time: the end time of the session (format:
yyyy/mm/dd HH:MM:SS)
- Public status: whether or not to display the session on the Session schedule page displayed by clicking the Session list buttons on the home screen and in the Active sessions section of the home screen (value:
TRUE= public,
FALSE= not public)
- Chat display status: whether to display the chat associated with the session or not (value:
TRUE= display,
FALSE= not display)
- Channel ID: the channel ID of the chat associated with the session
- Notification
- ID - Title: the title of the notification (in English and Japanese)
- Representative user: the ID of the corresponding registered user
- Details: the description of the notification (in English and Japanese)
- Deadline for showing: the deadline for showing the notification (format:
yyyy/mm/dd HH:MM:SS)
- Publication status: whether to display the notification or not (value:
TRUE= display,
FALSE= not display)
Notes on Sheets
- The column with in each sheet is a key in the database, so it must be a unique string.
- You can add or update the values corresponding to the specified keys using the Reflect this sheet button, but you cannot delete them. Therefore, if you want to delete keys once they are created, you must delete them on the Firebase console.
Operation
How to log in as a registered user
- Check the spreadsheet and keep your ID and password.
- Visit the link for registered user entry (
{website origin}/login).
- Enter your ID and PASS (password) to log in.
- Make sure that the name displayed is correct, and click/tap the Goto Home button to enter.
- To log out, visit the same URL and click/tap the Logout button.
Create a chat associated with a session
- Log in to the website as a registered user.
- Click the Session List button to display the list of sessions, and select the session to which you want to associate a chat.
- Click the button in the lower-left corner of the screen, confirm the message in the dialog box that appears, and click the OK button to create a channel.
- Keep a note of the channel ID (32-digit alphanumeric character) displayed in the dialog. Click the OK button.
- Open the spreadsheet and enter the channel ID in the Channel ID field of the session you want to associate the chat.
Note that if a chat is associated with a session, participants who visit the session will automatically join the chat.
License
MIT License
GitHub
View Github | https://news.priviw.com/tech-examples/an-open-source-platform-for-decentralized-online-events/ | CC-MAIN-2022-05 | refinedweb | 2,346 | 58.42 |
Pandas Data Series: Check the equality of two given series
Pandas: Data Series Exercise-38 with Solution
Write a Pandas program to check the equality of two given series.
Sample Solution :
Python Code :
import pandas as pd nums1 = pd.Series([1, 8, 7, 5, 6, 5, 3, 4, 7, 1]) nums2 = pd.Series([1, 8, 7, 5, 6, 5, 3, 4, 7, 1]) print("Original Series:") print(nums1) print(nums2) print("Check 2 series are equal or not?") print(nums1 == nums2)
Sample Output:
Original Series: 0 1 1 8 2 7 3 5 4 6 5 5 6 3 7 4 8 7 9 1 dtype: int64 0 1 1 8 2 7 3 5 4 6 5 5 6 3 7 4 8 7 9 1 dtype: int64 Check 2 series are equal or not? 0 True 1 True 2 True 3 True 4 True 5 True 6 True 7 True 8 True 9 True dtype: bool
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Pandas program to stack two given series vertically and horizontally.
Next: Write a Pandas program to find the index of the first occurrence of the smallest and largest value | https://www.w3resource.com/python-exercises/pandas/python-pandas-data-series-exercise-38.php | CC-MAIN-2021-21 | refinedweb | 207 | 66.17 |
Most content (feature services, maps) can be copied using ArcGIS Online Assistant. The Python method described below is required for more complex content. You can use it for dashboards, web apps, surveys, and configurable apps. It will not work for ArcGIS StoryMaps or ArcGIS Experience Builder.
1. Go to ArcGIS Online and sign in with your source ArcGIS account—the one that contains your content.
2. Click the Content tab and locate the item you want to copy. Click the item name to open the item details page.
3. Copy the id from the address bar in your browser. This is the long string of numbers and lower-case letters that appear at the very end of the URL. Do not include id=.
4. Paste the id into a note or other temporary document.
5. Find any other items you want to move. Copy the id for each.
Some items contain other items as dependencies. For example, a dashboard probably references a map, and that map probably references a feature layer. The dashboard, map, and feature layer are three different items, but you only need to copy the dashboard. The dependent items will move with it automatically.
Note: This document will first demonstrate how to copy a few items. At the end, it will explain how to adapt the process to copy many items at once.
Jupyter Notebooks are an environment that you will use to write the Python code to transfer your content.
6. Open ArcGIS Pro. It does not matter which account you sign in with.
7. Click Start without a template.
8. On the ribbon, click the Insert tab and click the New Notebook
The first thing you'll do in your new notebook is to connect to your source account—the one where the content is currently stored.
9. In the first cell, paste this text:
username = input("Enter username of origin organization: ")
from arcgis.gis import GIS
gis1 = GIS("", username)
10. Click Run.
11. In the textbox that appears, type your username and press Enter.
12. In the Enter password textbox, type your password and press Enter.
Next, you'll connect to your target ArcGIS account—the one you want to move your content into.
13. In the next cell, paste the following text:
username_2 = input("Enter username of target organization: ")
gis2 = GIS("", username_2)
14. Click Run.
15. Enter the username and password of your target account.
16. In the next cell, type the following text, but do not run the code yet.
items = gis1.content.search(query="id:")
print(str(len(items)) + " item will be cloned:")
items
17. Position your curser after the text query="id: and paste the id string that you copied earlier.
18. If you have multiple items, you can reference them like this:
items = gis1.content.search(query= "id:(5f3b5c9325314fc3a11c1d649d37461e OR fc1b539234f44ee89845ea926e5e393f)")
19. Click Run.
20. The name of the item(s) to be cloned is printed. Confirm that it is correct.
Finally, you will clone your content into your target account.
21. In the next cell, paste the following text:
def deep_copy_content(input_list):
for item in input_list:
try:
print("Cloning " + item.title)
copy_list = []
copy_list.append(item)
gis2.content.clone_items(copy_list, copy_data=True, search_existing_items=True)
print("Successfully cloned " + item.title)
except Exception as e:
print(e)
print("The function has completed")
deep_copy_content(items)
22. Click Run. Wait until the text The function has completed has printed.
24. Go to ArcGIS Online and sign in with your target account.
25. Click the Content tab and verify that the item has been copied. If you were already on the Content page, refresh your browser to see changes.
If you are copying an item that is dependent on other items, you should see all items copied over. In the example below, I only moved TestDashboard. Test Map and Test_Data were also copied.
If you don't want this to happen, set copy_data=False in the code above.
You can read more about the clone_items function here:...
1. If you want to copy more than a few items at a time, return to the cell you wrote in step 16. Replace the text there with this:
items = gis1.content.search(query="owner: {}".format(username), max_items=num_items, sort_field='id', sort_order='desc')
items
2. Re-run the cell. It will ask you how many items you want to copy.
3. Re-run the last cell to copy the content.
You can find more ways to search for items in the Search reference document.
This method will not work with ArcGIS StoryMaps. Only Classic Story Maps.
1. Use the instructions above to copy both the story and any web maps that are used in the story.
2. Open the new story in edit mode (Configure App). You'll see that the maps and images are blank.
3. Click the Edit button and Change Media to reconnect maps and image.
Alternatively, you can use the item_mapping parameter in the python script. See an example and instructions here: The Cloning Process.
Hello @HeatherSmith,
great and well explained article. You mentioned "It will not work for ArcGIS StoryMaps or ArcGIS Experience Builder". Where in the Python API or REST API documentation are these limitations listed and updated ?
Regards, Bernard
Thank you @BernardRIXEN
The documentation for cloning content is here: which lists the items that are possible to clone. Future changes should be reflected there.
There is also now an article which presents a workaround method for copying new StoryMap stories:
Has someone made this into a notebook that can just be shared directly already as opposed to copying from here?
Also, I got this error trying to clone a hosted feature service with related tables... any insight?
Cloning XXXXX ('Failed to create Feature Service XXXXX: list index out of range', <Item title:"XXXXX" type:Feature Layer Collection owner:XXXXX>) The function has completed
@NikolasHawley that issue is normally related to data not being able to be copied to/from a destination. If you have a `field` with HTML in it or generic text, make sure it's sanitized before the clone operation.
Here is a list of supported HTML tags:
Has anyone had the issue "failed to create feature service name of item : 'available', None
I am trying to transfer a web map
Update: I realized the issue was because I was trying to transfer a web map with a feature layer that was hosted on my original account. The account I was trying to transfer to is a public account and they can't host feature layers.
HI guys,
im runnig the script in jupyter and im getting this error in several items, any idea??
('Failed to create Feature Service Departamentos: Your request has timed out.\n(Error Code: 504)', <Item title:"Departamentos" type:Feature Layer Collection owner:NicolasM>)
thanks!!! | https://community.esri.com/t5/learn-arcgis-documents/how-to-copy-content-from-one-arcgis-online-account/tac-p/1048468/highlight/true | CC-MAIN-2021-49 | refinedweb | 1,131 | 75 |
Restart is not supported if not using gnome session manager (affects XFCE & LXDE)
Bug Description
Binary package hint: restartd
Installed xubuntu loged in made updates and restart required showed icon i clicked and error in picture shown
1. I installed xubuntu 2 days ago on 5 computers. After installing from live cd restarted and removed cd. Started pc. Autologin logs in. Made internet connection. Made updates. Grub-pc asked what version i want. I took take package maintainers version. When update finishes restart required button appears. I click it and Reboot Failed dialog appears. Failed to request reboot, please shutdown manually. I took screenshot and uploaded. now ill upload another one.
But when taking shutdown a dialog appears requesting password for shutdown. I couldnt take screenshot of that. Screenshot utility didnt work while that dialog was open. So thats another bug that shutdown after updates requires password.
2. I expect to restart happen after clicking that blue restart icon witch appears in taskbar after updates are made.
3. Look #1.
4. Xubuntu 9.10 on 4 pcs and 1laptop.
lsb_release -rd
Description: Ubuntu 9.10
Release: 9.10
5. apt-cache policy restard
restartd:
Installed: (none)
Candidate: 0.2.2
Version table:
0.2.2 0
500 http://
maybe i needed to take this info from that time when updates were made.
As i mentioned this affects 5 computers. I installed them using 2cds to make installing faster and cds were checked for errors and all is fine. So its big problem already in iso file.
Also as i mentioned clicking shutdown asked for password. So maybe becouse somehow on update system restarting was locked down thats why maybe restart couldnt work. So maybe a solutions could be
1. make restart have sudo access.
2. make nothing on update lock computers shuting down option.
is it correct that update-manager makes that restart blue icon?
and is it correct that gksu asks for password on shutdown? maybe that proses should be added as also affected?
Thank you for the better description of this bug. You are correct that this is a bug in Xubuntu 9.10.
Could you please add the log files from '/var/log/
Heres /var/log/
at first i got error from trying upload directly to LP. Cannot upload empty file.
then i sudo mousepad var/log/
so i tryd copying to home Dir but got error Failed to copy "/var/log/
Failed to open "/var/log/
Why to copy it needs to open it? Just copy..
Is there easyr way to upload files like this? Now i copyd all whats inside in new file and uploading it.
Thanks for your supporting documentation. Since this bug has enough information provided for a developer to begin work, I'm going to mark it as confirmed and let them handle it from here. Thanks for taking the time to make Ubuntu better!
I just installed xubuntu 9.10 for another friend and made updates and heres another screenshot of restart not working.
Is this beeing now fixed?
This bug report is marked "confirmed" in the yellow status line at the top of the report. That means it can be looked at by a developer. Please look at https:/
Screenshots are great to show what the bug looks like. Unfortunately, most of the time they do not give any information about why the bug occurred. Normally, that requires the log files be attached, where the error occurs.
Confirming this affects Xubuntu but not Ubuntu. The cause appears to be a reliance on gnome session manager to trigger the restart:
UpdateManager/
def show_reboot_
self.
self.
res = self.dialog_
self.
if res == gtk.RESPONSE_OK:
try:
bus = dbus.SessionBus()
proxy_obj = bus.get_
iface = dbus.Interface(
# FIXME: try sesion restart with hal?
except dbus.DBusException, e:
pass
Attached is a patch that potentially fixes this issue. I cannot test it right now because I have yet to find a way to force update-manager to perform a restart action when the updated packages don't require one.
To apply it locally to the installed update-manager Python script:
cd $HOME
# download patch into user home directory
cd /usr/share/pyshared
sudo patch -p1 -i $HOME/01_
Now, next time update-manager offers the restart now/later dialog, and the user chooses "Now", the script should try and fail to connect to the Gnome session manager over Dbus and then try to connect to the XFCE session manager instead.
Unable to patch source
neil@desktop:
patching file UpdateManager/
Hunk #1 FAILED at 597.
1 out of 1 hunk FAILED -- saving rejects to file UpdateManager/
IMO, you should also add a fallback to ConsoleKit Restart method, so no XFCE and no GNOME session should work also.
Here's a new proposed patch (unfortunately, I wasn't aware of this bug report so I redid it from scratch...), to use consolekit if gnome-session isn't available. I tested on xubuntu natty, and it worked fine here.
I'll push it to the bzr branch in a few hours, and probably upload it tomorrow.
This bug was fixed in the package update-manager - 1:0.146.1
---------------
update-manager (1:0.146.1) natty; urgency=low
[ Michael Vogt ]
* merged lp:~evfool/update-manager/fix689034:
- Some basic string fixes (lp:#689034), thanks to Robert Roth
* UpdateManager/
- add backend for roaming detection, thanks to Alex Chiang
- display warning when on 3g and when roaming (fixes half of
LP: 323108)
* merged lp:~thibault-lemaitre/ubuntu/natty/update-manager/from_pkg.isInstalled_to_pkg.is_installed
that fixes a bunch of deprecated python-apt issues (many thanks!)
[ Lionel Le Folgoc ]
* UpdateManager/
gnome-session isn't present (fixes rebooting on Xfce and LXDE, lp: #530161).
-- Michael Vogt <email address hidden> Tue, 01 Mar 2011 08:55:53 +0100
Thank you for taking the time to report this bug and helping to make Ubuntu better. Unfortunately, we cannot work on this bug).
4. The release of Ubuntu you are using, via 'lsb_release -rd' or System -> About Ubuntu.
5. The version of the package you are using, via 'apt-cache policy packagename' or by checking in Synaptic.
Thanks! | https://bugs.launchpad.net/ubuntu/+source/update-manager/+bug/530161 | CC-MAIN-2016-18 | refinedweb | 1,020 | 67.35 |
Hey Justin
On 31 Jul 2012, at 15:14, Justin Mclean wrote:
> Nor am I suggesting one namespace per new component added.
I was aware of that, I meant to imply we would have got a new namespace with 4.5 and the introduction
of Spark DataGrid, Form, Image, Module, Busy Indicator, SkinnablePopUpContainer, Date/Time,
Number/Currency Formatters & Number/Currency Validators. If we start out with a pattern
of introducing a new namespace when u have new components in a release, we should continue
that pattern no matter how many components you introduce in a release. For me if they are
spark based classes they should be in spark packages and in the spark namespace, if they are
mx based classes they should be in mx packages and namespace.
The packages and namespace names should not be influenced by the release a component was introduced
in.
> The postccode formatter/validator classes are not quite mx and not quite spark so it's
a little difficult to know where to add them if we didn't add a new namesake.
The PostCodeValidator implementation extends the mx validator and the PostCodeFormatter extends
the mx validator. Neither extend the spark validation or formatting base classes, therefore
IMO they should both go in mx packages and be in the mx namespace. If someone then adds a
spark based solution they can be also be easily added to the SDK without conflict and preserving
backwards compatibility.
> +1 to that. We might be able to change that via adding duplicate packages via manifest
files (I think not tired). Along the same lines as mx:Rect/s:Rect?
mx:Rect/s:Rect are namespace issues. My point was a little off topic i guess although the
package names do fit into the 2 broad namespaces of mx and spark.
Moving the components out of "components" and into "containers" & "controls" could again
be a bit of a headache for those that have used them in AS (find and replace would do the
job again though). By updating the manifest, there wouldn't be any mxml namespace issue.
We in agreement that changing the URI for the namespaces to remove 'adobe' would also be good.
maybe we could provide a simple AIR tool that performs the find and replace on a codebase
for both the URI, and spark container/controls packages.
Tink | http://mail-archives.apache.org/mod_mbox/incubator-flex-dev/201207.mbox/%3CCB9CF661-96BB-47E4-8EA2-920760C9DE00@tink.ws%3E | CC-MAIN-2015-32 | refinedweb | 393 | 59.84 |
#include <hallo.h> * Bill Allombert [Tue, Apr 11 2006, 12:34:45AM]: > Please take into account that Debian menu will only display modules > suitable for the running window-manager (because they use a specific Okay... now I understand. > 'needs' field that only this wm 'support'). So in effect you are just > renaming "WindowManagers/Modules" to "Window Managers/$wm Modules". Yep. WRT you said above, what abot renaming "WindowManagers/Modules" to "$wm Modules" (one level above WM starters and indicating which "modules" are meant by that). > I am not a typical user, but I have 45 window-managers installed > so I have a hard time finding the single Modules subsection and > naming it "Foo WM Modules" will not make things any easier. That > might not make me the best judge of the issue, though. Ehm - yes to both. Eduard. -- For any stupid thing chosen at random, you'll find at least 5 people on the Internet who thinks it's a good idea. -- Steve Langasek in debian-devel | https://lists.debian.org/debian-devel/2006/04/msg00220.html | CC-MAIN-2017-26 | refinedweb | 167 | 64.1 |
>>>>> "Samir" == Samir Patel <spatel@...> writes:
Samir> I am trying to save an image without showing it. Here is
Samir> small program
There are a couple of ways to do it. It would help to know what
platform you are on. On linux/unix, there are the postscript and GD
backends which can generate images 'offline' w/o showing them. At
present, there is no way to generate a GTK image (GTK is the default
backend) w/o showing it. You should read the web pages
for more information on these issues.
Postscript is a high quality output that is more useful on linux/unix
platforms where there are usually viewers, converters and printers by
default. GD can be used to make PNGs and other image formats without
showing the image, but as far as I know there is no good windows
installer for gd module yet. I've spent some time working on it, and
have been corresponding with the author of gdmodule, and can probably
come up with one in the near future.
So that's the long answer. The short answer is -- if you are on
linux, install gd module following the instructions on the matplotlib
web site and use the GD or PS backend. If you are on windows, wait a
little bit and I'll see about getting the gd installer going, which is
something I've been meaning to do anyway.
Cheers,
John Hunter
PS solution works for me. One thing is that afm fonts are in gnome-print
package (Took me some time to find where this fonts came from). Now I am
trying to see whether I can make it work with Quixote (web server). I will
try GD solution later on. Thanks for your suggestions.
- Samir
Samir,
Either call it with "python test.py -dGD" or use this code, with 2 new
lines at the beginning.
from matplotlib import use
use('GD')
from matplotlib.matlab import *
plot([1,2,3])
savefig('test.png')
----------------
Instructions for installing stuff for GD on the website. But if you just
need an image, do -dPS or use('PS') for postscript output.
-C
--
Ask not what your computer can do for you; ask.... [ Uh-oh. ]
First of all, one of the easiest graph package yet fill with tons of
capability and future potential.
Now my issue:
I am trying to save an image without showing it. Here is small program
**************************************************************
from matplotlib.matlab import *
plot([1,2,3])
savefig('test.png')
#show()
***************************************************************
This does not create test.png file, but if I uncomment last line, it create
test.png file. How can I create a test.png file without showing it?
I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details | https://sourceforge.net/p/matplotlib/mailman/matplotlib-users/?viewmonth=200310&viewday=24 | CC-MAIN-2016-30 | refinedweb | 487 | 75.81 |
StencilJS Hello World
Information drawn from
Getting Started
Starting a new project
Stencil requires a recent LTS version of NodeJS and npm. Make sure you’ve installed and/or updated Node before continuing.
Note that you will need to use npm 6 or higher.
npm init stencil
Stencil can be used to create standalone components, or entire apps. After running init you will be provided with a prompt so that you can choose the type of project to start.
? Pick a starter › - Use arrow-keys. Return to submit. ❯ ionic-pwa Everything you need to build fast, production ready PWAs app Minimal starter for building a Stencil app or website component Collection of web components that can be used anywhere
Updating Stencil
To get the latest version of @stencil/core you can run:
npm install @stencil/core@latest --save-exact
My First Component
Stencil components are created by adding a new file with a .tsx extension, such as my-first-component.tsx, and placing them in the src/components directory. The .tsx extension is required since Stencil components are built using JSX and TypeScript.
Here is an example of what a Stencil component looks like:
import { Component, Prop, h } from '@stencil/core'; @Component({ tag: 'my-first-component', }) export class MyComponent { // Indicate that name should be a public property on the component @Prop() name: string; render() { return ( <p> My name is {this.name} </p> ); } }
Don’t fully understand what’s going on? Don’t worry, we’ll explain each piece in detail later on.
Once compiled, this component can be used in HTML just like any other tag.
<my-first-component</my-first-component>
Web Components must have a - in the tag. firstComponent would not be a valid tag name.
When rendered, the browser will display
My name is Max.
So what is really going on here?
Let’s dive in.
The first piece we see is the
@Component decorator. This decorator provides metadata about our component to the Stencil compiler. Information, such as the tag to use, and external styles, can be set here and picked up by the compiler.
Below the @Component() decorator, we have a standard JavaScript class. This is where you’ll write the bulk of your code to bring your Stencil component to life. Here is where you’d write functions or provide business logic.
In order for the component to render something to the screen, we must declare a
render function that returns JSX.The quick idea is that our render function needs to return a representation of the HTML we want to push to the DOM.
The name property on the class also has a decorator applied to it,
@Prop(). This decorator tells the compiler that the property is public to the component, and the user should be setting it. We set this property like so:
<my-first-component</my-first-component>
Any property decorated with
@Prop() is also automatically watched for changes. If a user of our component were to change the element’s name property, our component would fire its render function again, updating the displayed content.
Component Generator
The Stencil CLI can generate new components for you. If you used one of the starters, you can simply run the generate npm script in your project, which will start the interactive generator.
npm run generate
Or you can invoke the Stencil CLI directly with the generate command (g for short). If you don’t have stencil installed globally, prefix the command with npx.
stencil generate
You can optionally pass the component tag name directly to the command. Remember that the component tag name needs to be lowercase and contain at least one hyphen. In the second step, the generator will ask you which files to generate. This allows you to bootstrap a stylesheet as well as spec and e2e tests along with the component file.
All components will be generated within the src/components folder. Within that, a folder will be created with the same name as the component tag name you provided, and within that folder the files will be generated. It is also possible to specify one or multiple sub-folders to generate the component in.
For example, if you specify
pages/page-home as the component tag name, the files will be generated in
src/components/pages/page-home.
stencil generate pages/page-home
src |- components |- pages |- page-home |- page-home.css |- page-home.e2e.ts |- page-home.spec.ts |- page-home.tsx
------------------------------------------------------------------------
Last update on 14 Apr 2020
--- | https://codersnack.com/stenciljs-hello-world/ | CC-MAIN-2022-33 | refinedweb | 749 | 56.25 |
Answered: How to define global config for a sencha app
Hello everybody,
I'd like to know which's the way to define global configuration to be used from the Controllers and Views. Is there any 'sencha-way' to do so? or should I use just simple javascript global variables which is not, I know, the best way?
Thanks in advance,
What I do is have a singleton class..
Code:
Ext.define('MyApp.util.Config', { singleton : true, config : { foo : 'bar' } });
Code:
MyApp.util.Config.getFoo();
- Join Date
- Mar 2007
- Location
- Gainesville, FL
- 38,669
- Vote Rating
- 1146
- Answers
- 3731
What I do is have a singleton class..
Code:
Ext.define('MyApp.util.Config', { singleton : true, config : { foo : 'bar' } });
Code:
MyApp.util.Config.getFoo() to bring this thread back from the dead but I have a follow up question.
Is using a singleton object to store variables preferable to using a namespace for the same purpose?
Sencha 2.1 andCmd 3.0 config issue
Hi guys, I used this class as well for my app config, but when I upgrade my sencha I have issue when I try to build production and I have not idea what is the issue :
Code:
TypeError: Object #<Object> has no method 'define'
Is someone having the same issue, or do you know a fix bu change.
Thanks in advice .
Overide the constructor?
I still work on v2.1 for my project, but the config class does not work for me if I don't overwrite the constructor with:
Code:
constructor: function (config) { this.initConfig(config); return this; }
I got this from
Cheers. | https://www.sencha.com/forum/showthread.php?186134-How-to-define-global-config-for-a-sencha-app | CC-MAIN-2015-48 | refinedweb | 267 | 72.97 |
Red Hat Bugzilla – Bug 439210
multiple problems with repository viewer
Last modified: 2014-03-16 23:13:17 EDT
Description of problem:
1) It allows users to enable debuginfo repos, which likely won't help them much
other than increasing all update times
2) It allows users to enable source repos, which doesn't really make sense at all
3) If you try to enable a repo, you get an error:
PackageKit daemon
Backends should send status <value> signals for repo-enable!
If you are:
* Calling out to external tools, the compiled backend should call
pk_backend_set_status() manually
* Using a scripted backend with dumb commands then this should be set at the
start of the runtime call
- see helpers/yumBackend.py:self.status()
Version-Release number of selected component (if applicable):
gnome-packagekit-0.1.9
How reproducible:
Steps to Reproduce:
1.
2.
3.
Actual results:
Expected results:
Additional info:
TBH, why is packagekit complaining to *me* that one of its backends is broken?
We've already fixed the pk_backend_set_status thing in git (the messages are
just for developers, I'll turn them off for the release).
Do you think that we should hide the debuginfo and source repos completely or
make this configurable?
Not sure. TBH, ignoring them would be encoding some sort of Fedora-specific
repository layout information in the backend, which is kinda gross.
CC'ing other people for opinions.
Would it help if there was some sort of descriptive comment about each repo?
That way we can (hopefully) make it clear to the user what the repo is there for
and prevent them from shooting themselves in the foot?
Where would this come from? From the repo files themselves?
(Hey, I know. Let's move them to XML and intltool-ize them!)
Well, we can do the filtering in a fedora specific way (using the abstract
FILTER_DEVELOPMENT) which is very easy to do.
What about just having a ticky box in pk-repo with "[ ] Show development
repositories" and classing -debuginfo and -source as DEVELOPMENT?
Richard
That will catch the people confusing 'rawhide' with 'Fedora development'.
(In reply to comment #5)
> Where would this come from? From the repo files themselves?
>
> (Hey, I know. Let's move them to XML and intltool-ize them!)
Well, we can try to put in more descriptive text in the name= line. Save the
terseness for the [foo] part. But yeah, English only for the lose.
Really, you can't rely on a name or a [foo] section to be sure that "these are
source packages" or "these are debug packages" because really, one can put any
URL there they want, and some have all of those types of packages mixed in together.
Jesse, is there a way we could have a type= parameter?
Where type is:
* debuginfo
* source
* normal
That should be pretty easy to add, no?
The only problem is that there's no logical limitation on what can be in a repo.
you can have source, binary, debug, etc rpms in one repo w/o any sort of logical
conflict.
so, we can put a type on it but it would just be an arbitrary label.
Sure, I don't think type would have to be mutually exclusive. What about:
type=debuginfo
or
type=normal;debuginfo;source
Richard.
The problem is that you're trying to define what will be in a remote repository,
that you have no control over. I could /say/ that the development URL I'm
pointing at will be 'normal', but I can't prevent the person who runs that repo
from dropping debuginfo packages into it, or source packages.
Well, the ultimate use case is a repo viewer with three entries:
[X] Fedora 9
[X] Livna 9
[ ] DAG 8.92
----------------------
[ ] Show detailed repository information
And if the last checkbox is enabled, then the -source, -debuginfo and such are
also shown.
Created attachment 302057 [details]
what PackageKit git looks like
This is what the UI looks like when we filter out all the ~devel repos - this
isn't typical for rawhide users but cuts the list down to a few entries on F8
and F9. The average user doesn't care about -source repos much at all.
FWIW, I used this metric:
def _is_development_repo(self, repo):
if repo.endswith('-debuginfo'):
return True
if repo.endswith('-testing'):
return True
if repo.endswith('-debug'):
return True
if repo.endswith('-development'):
return True
if repo.endswith('-source'):
return True
return False
When the repos can give us more information, then we can use that.
I've merged this into 0.2.0 - which will be put into rawhide when it re-opens.
F9 still has the long list of repos as is based on the 0.1.x codebase. | https://bugzilla.redhat.com/show_bug.cgi?id=439210 | CC-MAIN-2018-09 | refinedweb | 791 | 64.41 |
Be the first to know about new publications.Follow publisher Unfollow publisher The Inlander
- Info
Spread the word.
Share this publication.
- Stack
Organize your favorites into stacks.
- Like
Like this publication.
Inlander 11/28/2013
NEWS BOOTING PARKING SCOFFLAWS 1 8 APPLE CUP HALLIDAY VS. SANKEY 2 3 MUSIC PEARL JAM ON TRIAL 3 9 NOV. 28 - DEC. 4, 2013 LOCAL, INDEPENDENT AND FREE SINCE 1993 H o li d ay G ui de A day-by-day guide, from now until New Year’s Page 28 SUPPLEMENT TO THE INLANDER PHC_I_Chose_Powers_Inlander_FP.pdf 4 9/23/13 11:00 AM C M Y CM MY CY CMY K 2 INLANDER NOVEMBER 28, 2013 INSIDE Your Downtown Full-Service Grocery Store & Deli Local gifts, local food No Downtown’s full time Membership full service grocery store Required NOVEMBER 28- DECEMBER 4, 2013 | VOL. 21, NO. 6 COMMENT NEWS CULTURE HOLIDAY GUIDE FOOD FILM 5 13 23 28 29 34 MUSIC EVENTS BULLETIN BOARD WELLNESS I SAW YOU LAST WORD 39 44 50 51 52 54 ON THE COVER | SCOTT ANDERSON ILLUSTRATION FOOD It wasn’t all turkey during the original holiday feast • Locally made soap • Great gifts for foodies • Fair trade wool clothing • Sustainable wood earrings and goods Holiday gift baskets now available. • Sustainable kitchenware Housemade • Localcheesecakes, greenery pies, and•cookies Gluten free baking supplies with vegan and gluten-free options. • Poinsettias and bouquets • Local, vegetarian, and gluten *Please call with special orders 72 hours in advance. free foods for your holiday meal • Locally made jewelry 44 W. Main Ave 509-458-2667 Mon~Sat 8am – 8pm Sun 10am – 6pm Free Parking ! E L A S Y R O S S E C C A A SP TO 30% OFF UP ICALS, FILTERS, CHEM & ACCESSORIES HARD COVERS ON SALE NOW! PAGE 29 350 W. Bosanko Ave, Cd’A 720 N. Fancher, Spokane Valley 7808 N. Division St., Spokane apollospas.com FILM REVIEW Disney shows it gets what it’s like to be a young girl with Frozen FREE Teeth Whitening PAGE 34 . SPOK ANE | EA S TERN WA SHINGTON | NORTH IDAHO Collins Family Dentistry Call our office for Even More (509) 487.9000 15 E. Central Ave, Spokane (509) 235.8451 1841 First St, Cheney 20 OFF % NEED TO FIT INTO THAT LITTLE BLACK DRESS? OTHER SERVICES • Botox • Dermal Fillers • Cosmetic Skin Lesion Removal • Spider Vein Injections Call for your appointment today! VASERShape!™ IT! Offer Expires 12/30/13. Our newest addition is VASERShape™, which is an Ultrasound Heat Technology to decrease regions of stubborn fat, without surgery or down time! As Seen on Dr. Oz. Best results are seen in 3 to 5 short treatments. specials! Now Accepting Care Credit Melissa Sousley, MD | Spokane Enhanced Health | (509) 466-1188 NOVEMBER 28, 2013 INLANDER 3 Black Friday DEALS Don’t miss your chance to grab these incredible Black Friday deals on America’s Largest 4G LTE Network. FRIDAY ONLY! FREE NEW! Verizon Ellipsis™ 7 tablet Requires new 2-yr. activation. No rebate required. FRIDAY ONLY! FREE LIMITED-EDITION DROID RAZR HD by MOTOROLA 3499 EACH $ DEVICE COVER Speck® FitFolio™ for Verizon Ellipsis 7 Offer only for Stealth Black device. Limited quantity available. Requires new 2-yr. activation. No rebate required. Tablet not included. Get 30 days free of Google Play™ All Access with your all-new DROID. FRI–SUN NOW $ JUST FRI–SUN NOW $ JUST 5999 99 99 EACH WAS $79.99 WAS $149.99 POWER ON THE GO mophie juice pack® powerstation™ 4000 PORTABLE BLUETOOTH® SPEAKER JAWBONE® JAMBOX™ CALL: 1.800.256.4646 | Also available in black and red. Phone not included. CLICK: vzw.com/holiday | VISIT: vzw.com/storelocator Activation/upgrade fee/line: Up to $35. IMPORTANT CONSUMER INFORMATION: Subject to Cust. Agmt, Calling Plan & credit approval. Up to $350 early termination fee/line. Restocking fee may apply. 4G LTE is available in 500 markets in the U.S. Android and Google Play are trademarks of Google Inc. Limit one trial of Google Play Music All Access per account. © 2013 Electronic Arts Inc. EA, EA SPORTS, the EA SPORTS logo, Plants vs. Zombies and PopCap are trademarks of Electronic Arts Inc. All other trademarks are the property of their respective owners. Ellipsis™ is a Verizon Wireless trademark. DROID is a trademark of Lucasfilm Ltd. and its related companies. Used under license. © 2013 Verizon Wireless. G9412 4 INLANDER NOVEMBER 28, 2013 CWST-G9412-Pacific Northwest Inlander-9.3x11-4C-11.28 COMMENT STAFF DIRECTORY PHONE: 509-325-0634 Ted S. McGregor Jr. (tedm@inlander.com) PUBLISHER J. Jeremy McGregor (x224) WHAT ARE YOU THANKFUL FOR? Jacob H. Fries (x261) EDITOR JORDAN CLEMENTS I’m thankful for these waffles! Mike Bookey (x279) CULTURE EDITOR ART DIRECTOR Lisa Waananen (x239) WEB EDITOR ALL FACIALS Buy one get one FREE on a gift card! Start your Christmas shopping now! GIFT CAR D GIF T CA RD Get your GLOW ON only for the Holidays Laura Johnson (x250) MUSIC EDITOR LISTINGS EDITOR for Hair removal, pigment removal, spider vein removal, skin tightening, and tattoo removal Gift Cards available! Chris Bovey (x248) Chey Scott (x225) 50% OFF! Offers expire 12/31/13 GENERAL MANAGER EDITORIAL ALL LASER PACKAGES LESLIE McCRAY with teeth whitening! 99! $ Michael Mahoney COPY EDITOR Heidi Groover (x249) Jacob Jones (x237), Deanna Pan (x282), Daniel Walters (x263) STAFF WRITERS Young Kwak I am thankful for these gluten-free pumpkin waffles, and Boots. I’m thankful for sunshine, and crisp temperatures this morning, and for my sweetheart, the love of my life. PHOTOGRAPHER Amy Alkon, Andy Borowitz, Eli Francovich, Jim Hightower, E.J. Iannelli, Maryann Johanson, Scott A. Leadingham, Ari LeVaux, Jo Miller, Mary Lou Reed, Leah Sottile, Howie Stalwick, Bronwyn Doubet CONTRIBUTORS Emera L. Riley, Katelyn Smith, Sarah Wurtz INTERNS ADVERTISING Kristi Gotzian (x215) ADVERTISING SALES MANAGER Bruce Deming (x217), Carolyn Padgham-Walker (x214) SENIOR ACCOUNT EXECUTIVES PAUL ARGUINCHONA Every year this week I’m thankful for the opportunity to take inventory of all the blessings that have been provided for me, and it allows me to reflect on God’s provision in my life. It’s unbeatable. Autumn Adrian (x251), Jamie Albertini (x247), Bonnie Amstutz (x212), Gail Golden (x236), Janet Pier (x235), Emily Walden (x260) ACCOUNT EXECUTIVES Kristina Elverum (x223) DIRECTOR OF MARKETING Raevyn West (x222) EVENTS COORDINATOR Rebecca Rison (x216) ADVERTISING COORDINATOR Gilbert Sandoval (x242) ADVERTISING ASSITANT Aaron Willrich CHHE TAING Learning how to accept the things I can’t change right now, which will allow me to enjoy the little things that I have in my life every single day. And also work towards the things I do really, really want in life. SALES & MARKETING INTERN OPERATIONS Dee Ann Cook (x211) BUSINESS MANAGER Kristin Wagner (x210) ACCOUNTS RECEIVABLE Angela Rendall (x213) OPERATIONS ASSISTANT SARAH BENTON I am thankful for this fork, and for people who share! Trevor Rendall (x226) DISTRIBUTION MANAGER PRODUCTION Wayne Hunt (x232) PRODUCTION MANAGER Alissia Blackwood Mead (x228), Derrick King (x238), Jessie Spaccia (x205), Tom Stover (x265) GRAPHIC DESIGNERS INTERVIEWS BY KATELYN SMITH, BOOTS BAKERY AND LOUNGE, 11/22/13 NOVEMBER 28, 2013 INLANDER 5 MASON LAW FAMILY LAW • Divorce • Spousal Maintenance / Alimony • Child Support Modifications • Parenting Plans BY MARY LOU REED Craig Mason W. 1707 BROADWAY, SPOKANE, WA | TOP PRICE$ PAID! E. 911 Marietta (East of Hamilton) Mon-Fri 8-5 • Sat 8-4 509 443-3681 Aluminum Stainless Steel Brass Copper Gold Silver 483-4094 A flat surface for transporting all those things you don’t want to spill! .293.7816 1028 W. Rosewood #100-C Spokane WA 6 INLANDER NOVEMBER 28, 2013 Behind the Curtain The hijacking of a venerable arts institution AUTO INJURY • CIVIL LITIGATION CA$H REWARD COMMENT | THE ARTS. E ssentialwinning onethirdworking. I. Mary Lou Reed served two separate terms on the board of directors of the Coeur d’Alene Summer Theatre, last serving in 2010.. COMMENT | PUBLISHER’S NOTE Strangers and Saints. BY TED S. McGREGOR JR. *One-hour session, which consists of a 50-minute massage and time for consultation and dressing. Prices subject to change. Rates and services may vary by location. Additional local taxes and fees may apply. ©2010 Massag Good for massages, retail products and peace of mind. Ready to gift in any denomination at your local Massage Envy O MADJAZZ BIG BAND CHRISTMAS Dec 7 @ 8pm JEN SORENSON CARTOON featuring the Glenn Miller “Nutcracker Suite” SPONSORED BY: THE BING CROSBY THEATER TICKETS AVAILABLE THROUGH TICKETSWEST AT 800.325.SEAT OR Applicable service fees apply. Become a member today! “Like” us on Facebook! NOVEMBER 28, 2013 INLANDER 7 COMMENT | DIGEST ON OUR FACEBOOK How much do you worry about car crashes? OPEN ENROLLMENT POTTERY CLASSES BILL TURNER: If I worried about car crashes, I’d never get in a car. Especially around here. All Skill Levels & Ages Morning/Evening Classes Fun & Friendly Atmosphere Learn at Your Own Pace Supplies Included ANDREA SMITH: Every time I get in the car I worry about it. I never run yellow lights and I always look both way when going through an intersection… always keeping an eye out for people and animals. clayconnection.net 714 E. Sprague Spokane | 509-747-6171 What will you build? EMERALD DEWEY: More than I used to now that I have a child in the backseat. JACK OHMAN CARTOON GUEST EDITORIAL A New State of Mind Secessionist movements are afoot all over the West BY PETER LAUFER VOLUNTEER TODAY! Check out why we build & why you should too. Sign up at: Habitat-Spokane.org 509.534.2552 8 INLANDER NOVEMBER 28, 2013 F rustrated.” University of Oregon journalism professor Peter Laufer is author of The Elusive State of Jefferson. A version of this column first appeared in High Country News (hcn.org). DOUGLASS PROPERTIES: One almost has to look both ways when crossing a 4-way after the light turns green. A yellow light apparently means “accelerate rapidly” to a large portion of the population. Side impacts hurt at just about any speed! TIZZELY McJIZZEL: Waaaay tooo much!!! I don’t even go ANYWHERE if I don’t have to!! JENNIFER VINCENT: I worry a lot! Seven weeks ago, I was at a red light when a one-ton pickup slammed into the back of my Honda at 40 mph, and it pushed my car into the truck in front of me as well. In less than five seconds, I now have no car, four to six weeks of PT, and anxiety that I have never had before. These kinds of accidents are very preventable… Put down the phone and pay attention, please! CARA THOMPSON: When I started driving, my dad, the firefighter/EMT, told me, “Someday you will be in a wreck. It might not be your fault, you might not even be driving, but learn to expect it.” MARY K SIMMONS: I don’t drive but have had near misses more times than I can count. You wouldn’t believe how many times I almost get hit crossing in a crosswalk, with the walk sign on. … People don’t pay attention to anything. They’re too busy on their phones, doing their makeup, or eating a double cheeseburger and usually in a hurry. LUKE BISHOP: I worry a fair amount. Especially when I drive other people around such as my wife or the foster kids I care for. And I also get really nervous when certain friends drive as I tend to be on the side of the car that is about to sideswipe a semi! WHERE WATCHING SPORTS IS A SPORT. NOVEMBER 28, 2013 INLANDER 9 LARGEST SELECTION IN THE NORTHWEST • SAME DAY DELIVERY Save 701! Save $ up to 1000! $ Samsung Steam Washer & Dryer 549 $ al is FREE! e dryer pedest th r pedestal and Buy the washe each! Save up to $1000 on select KitchenAid appliances Washer: #WF365BTBGWR • 3.6 cu ft capacity, 8 Wash Cycles, 6 Options, VRT Plus Technology, Deep Steam Cycle. Dishwasher: #KUDS35FXSS Dryer: #DV365ETBGWR fer expi Hurry in! This of • 7.3 cu ft capacity, 13 Drying Cycles, 4 Options, 3 Timed Settings, Sanitization Cycle, Steam Dry, Woolmark and Sensor Dry. FREE DISHWASHER! res 12/31/13! • 24” Wide 15 Place Settings Capacity Tall Tub Dishwasher, ProScrub Option, Whisper Quiet System, 4 Hour Delay Wash Option, Energy Star Rated: Stainless Steel. $1950! SAVE UP TO. 10 INLANDER NOVEMBER 28, 2013 COMMENT | SATIRE Iran Throws Obama a Big Pity Party BY ANDY BOROWITZ T he Supreme Leader of Iran, Ayatollah Ali Khamenei, told reporters this week that website, we realized it would be uncaring of us not to try to help him out.” The Ayatollah said he was not “overly optimistic” that signing a nuclear treaty with the West would be sufficient to distract attention from the President’s Obamacare woes, 34 years,” he said. “At the very least, maybe dial it back until he gets that website straightened out.” n For more fake news from Andy Borowitz, visit borowitzreport.com. COMMENT | FOOD GMO Fight Not Over I BY JIM HIGHTOWER f you doubt that big money and lies can pervert elections, look at Initiative 522 in Washington State. It had been put on the ballot by a grassroots coalition of consumers, organic producers, environmentalists and others who want honesty in food labeling. The initiative would’ve required grocery manufacturers that slip genetically manipulated organisms into their products to state that fact on their food labels. But the industry ran a dishonest, multimilliondollar PR campaign, including ads to scare Hidethe-Brand artifice. It let big-name food giants put some $11 million into the no-labeling campaign, without revealing their participation and angering consumers. But the state attorney general exposed this dodge and forced the giants to fess up. Behind this hoaxwithin GMO profiteers can run, but they won’t be able to hide from the growing number of Americans who are onto them — and literally fed up with their tactics. GMO labeling laws are currently being pushed in some 20 other states. The fun is just beginning. n For more from America’s populist, check out jimhightower.com. NOVEMBER 28, 2013 INLANDER 11 LARRY H. MILLER DOWNTOWN TOYOTA NEW 2014 TUNDRA NEW 2013 RAV4 LE AWD 4 DAYS ONLY! FRIDAY, NOV. 29 - MONDAY DEC. 2 TOYOTA WILL DOUBLE YOUR DOWN PAYMENT OFFER* up to $1000 on select 2013 Toyotas 10 models with PLUS! LARRY H. MILLER DOWNTOWN TOYOTA WILL TRIPLE YOUR DOWN PAYMENT up to $2000 on all 2013 Toyotas TOTAL BLACK FRIDAY SAVINGS OF Plus factory incentives up to $3000! UP TO $3000! 0% apr financing! & SPECIAL LOW PAYMENT LEASES! NO PAYMENTS UNTIL MARCH 2014 FOR QUALIFIED BUYERS! COMPLIMENTARY HOLIDAY GIFT † With any new vehicle purchase during this event. † While supplies last. COMPLIMENTARY WALMART GIFT CARD WITH EVERY TEST DRIVE! 32” Flat Screen TV WE WANT EVERY TOYOTA TO BE A DOWNTOWN TOYOTA Samsung Galaxy Tablet $200 Best Buy Gift Card 800.380.8860 | 1208 West 3rd Ave. *Select 2013 Toyota models: Prius Liftbacks (Excludes C, V, Plug-In), RAV4s, Camrys (Gas/Hybrid), Venzas, Highlanders (Gas/Hybrid). All offers on contracts through Toyota Financial Services. Subject to credit approval. 0% apr financing for 60 month terms. Discounts on MSRP only. Triple your down payment up to $1000 limited to selected models. Excludes Scion. Only valid on Toyota Financial Services funded APR or Lease deals. This program is ONLY compatible with Toyota LEASE RCFs up to 36 Months and APR rates up to 60 Months. Offer valid only 11/29/13-12/02/13. POLICE An Inside Look SPD’s new Internal Affairs director is changing the way officer misconduct is investigated BY JACOB JONES I.” ...continued on next page Spokane Police Department Director of Strategic Initiatives Tim Schwering. YOUNG KWAK PHOTO 10% OFF NEWS | DID YOU KNOW... Researchers believe that acupuncture may re-activate the "memory" in damaged nerve cells, explaining why acupuncture can be an effective method for treating paralyzed patients. There are gentler, equally effective means of treatment other than harsh drugs. HOLISTIC HEALTH CARE FOR PETS Dr. Dennis Thomas, D.V.M. 1707 E. 11th Ave. Spokane 509-214-2676 Dr. Thomas has been a licensed, practicing veterinarian for over 30 years. For more than a decade he has focused on alternative modalities to address pet health care. 14 INLANDER NOVEMBER 28, 2013 Police Chief Frank Straub says an early warning system will track behavioral red flags. JACOB JONES PHOTO “AN INSIDE LOOK,” CONTINUED....” T.” I ‘got.” P olice ‘If this rule gets broken, this is the type of punishment, this is the type of range you would get,’” he says. I.” n jacobj@inlander.com NOVEMBER 28, 2013 INLANDER 15 NEWS | DIGEST NEED TO KNOW The Big News of the Past Week PHOTO EYE HERE COMES SANTA 1. The Spokane County Prosecutor’s Office ruled last Thursday a Spokane Valley sheriff’s deputy was “justified” in fatally shooting a man armed with a knife in June. Investigators say Roy Jacobs ignored repeated commands to drop the weapon and moved toward the deputies. 2. Iran has agreed to freeze parts of its nuclear program in a historic six-nation agreement signed Monday. In exchange, Iran will receive temporary relief on certain economic sanctions. 3. Disgraced Spokane developer Greg Jeffreys pleaded guilty to four counts of fraud and contempt of court last week, stemming from his deceptive dealings surrounding the vacant Ridpath Hotel and investment manipulations. Prosecutors are seeking an eight-year sentence. 4. The U.S. Senate changed filibuster rules to limit delays against presidential nominees for federal positions. Outnumbered Republicans strongly opposed the change, calling it a power grab. SARAH WURTZ PHOTOS J. ON INLANDER.com DIGITS 10,000 $ 16 INLANDER NOVEMBER 28, 2013 5. An 11-year-old Colville boy recently convicted of conspiring to murder a classmate was sentenced to more than four years in juvenile detention. What’s Creating Buzz The bounty that members of Aryan Nation, a white supremacist prison gang, allegedly placed on the two black teenagers accused of beating World War II veteran Delbert Belton to death. After Spokane police received word of the bounty, the suspects were moved from juvenile detention to protective adult custody. FUN: Find video of Macklemore and Ryan Lewis riding scooters through Spokane and shopping at Value Village, plus other fun stuff on the blog under the ‘For Fun’ tag. NEWS | BRIEFS Work in Progress The city’s Use of Force Commission weighs in on progress at SPD; plus, Lakeland Village under fire NOT DONE YET A month-old letter from the city’s USE OF FORCE COMMISSION surfaced last week in response to the Spokane Police Department’s ongoing reform efforts, commending initial progress, but also calling out three recommendations in need of additional attention. The Oct. 15 letter served as the commission’s written response to a six-month update in August on the police department’s implementation of 26 reforms recommended by the commission. Chairman Earl “Marty” Martin says they wanted to recognize early progress while calling attention to concerns raised during the sixmonth update. While the SPD has introduced new policies and training, the commission’s letter calls for police officials to follow through with a “culture audit” on officer attitudes, which commissioners have criticized for being in some cases defensive or demoralized. The letter also encouraged greater transparency during future union negotiations and reinforced commission support for an independent police ombudsman’s office, which remains under public debate in the wake of Proposition 1’s passage earlier this year. “We believe independence is an important value,” Martin says. As far as additional feedback, the letter explains “the Commission will reserve commenting on the evolution of specific recommendations until such time as the on-going efforts have had a chance to mature.” — JACOB JONES BROKEN RULES Lakeland Village, a state-run institution in Medical Lake for PEOPLE WITH DEVELOPMENTAL DISABILITIES, broke federal law more than 40,000 times over the past two and half years by failing to provide adequate services to more than two dozen residents, according to a new review by investigators at the Centers for Medicare and Medicaid Services (CMS). In a letter to officials at the state Department of Social and Health Services, CMS described illegal cuts to services for 27 people with developmental disabilities. Before the cuts were made in 2011, David Lord, with the advocacy organization Disability Rights Washington, says these residents were receiving numerous services intended to help them develop life skills for reintegrating into the community. “These individual were essentially warehoused instead of being provided the kind of treatment they should have been getting,” Lord says. “You can’t just dump people in nursing homes.” Speaking to the Seattle Times, DSHS spokeswoman Chris Case said the letter was based on a “technicality” and a failure to provide evidentiary paperwork, but David Carlson, an attorney for Disability Rights Washington, says the state’s decision to deny treatment to these individuals was made in response to a 2011 directive to cut more than $1.8 million from the department’s budget. CMS is demanding Washington pay back as much as $16 million in federal matching dollars. The agency is also recommending that the feds conduct a civil rights investigation into the matter. — DEANNA PAN Well-being now in downtown. Stop by our new location. Spokane • 502 W. Riverside numericacu.com • 800.433.1837 Federally Insured by NCUA NOVEMBER 28, 2013 INLANDER 17 LATE NIGHT NEWS | PARKING HAPPY HOUR FRI & SAT 10-CLOSE W/ FULL MENU Sun-Thur 11a-11p | Fri-Sat 11a-2a 3011 South Grand Blvd | Spokane, WA ManitoTapHouse.com Shop Local Inland Northwest Shopping Guide JUST IN TIME FOR THE HOLIDAYS Under the Boot ON INLANDER STANDS NOW Next year the city will start booting the cars of parking “scofflaws” BY HEIDI GROOVER I n a database at City Hall, officials track booted with no response from the owner, the city more $4 million in unpaid parking tickets, will impound the car. Making it onto the scofflaw often seeing the same names — about 3,500 list comes with a $25 fee and getting booted will “frequent flyers,” who have four or more unpaid cost drivers another $50, but it’s still unclear tickets — appear over and over again. Now, one which impound lot the city will use and therefore man thinks he has a way to target just 10 or 20 of how much it’ll cost owners, on top of outstanding those drivers and make the whole lot listen. tickets, to get their vehicles out of impound. (The Dave Steele, with the city’s Business and Spokane Police Department contracts with tow Development Services Department, has been companies when they impound vehicles. Towing leading the overhaul of parking downtown: starts at $178 an hour and impoundment at $45 credit-card-friendly meters, sensors to erase extra a day, increasing with the size of the vehicle, time when cars leave parking spots and now tire according to the Washington State Patrol, whose boots to immobilize cars when the owner has rates SPD uses.) four or more unpaid parking tickets. The city Councilman Mike Fagan, who supports the council will vote in coming weeks on the bootprogram, says the city “bends over backwards” ing program, and Steele says he hopes to buy to give people chances to pay their tickets. The between 10 and 20 boots at $500 each early next city’s new parking meter system will make it posyear. sible to pay tickets online starting next month. “We want to just have enough “We are definitely a very, very forof them present that people recoggiving and very, very accommodating nize, ‘Oh yeah, you’ve got to pay government,” he says, “but, you know, Send story ideas to your parking tickets,’” Steele says, patience does tend to run out from time tips@inlander.com or emphasizing the program is more to time. … I think that’s what we’re seecall the tip line at about perception than trying to boot (509) 325-0634 ext. 264 ing right here.” every offending owner. If passed by the council, the law The ordinance would give would take effect in early January, but parking enforcement officers the authority to add the city would offer an “amnesty” period, warnsomeone with four or more unpaid tickets in coling people with enough tickets to get booted, lections to a “scofflaw list” and boot the car if the but not actually booting them until the summer. owner doesn’t respond by paying the tickets, beSteele says he’s still working with the municipal ginning a payment plan or challenging the tickets court to determine just how much help he can in court within 10 days. After 48 hours of being give people looking to pay off their debt before GOT A TIP? To advertise in our Shop Local products: sales@inlander.com | 509.325.0634 ext 216 18 INLANDER NOVEMBER 28, 2013 g n i v i g T hanks AT TH T R O S E R O IN S A C E COEUR D’ALENE N OV E M B E R 2 8 TH Thanksgiving Feast TWO FOR $40 The latest step in the city’s parking overhaul: a booting program The top five offenders and how much than unable, to pay they owe. City of Spokane Parking tickets them. Center for range from $10 to $450, depending on Justice attorney the offense. Data from Spokane Municipal Julie Schaffer isn’t Court. so sure. Among its work on behalf of Matthew R. Hardie: $8,920 low-income people, the legal nonprofit Ian Wingate: $7,175 runs a relicensing program to help Bruce P. Reed Jr.: $6,830 people who’ve had their licenses susThomas C. Verhaag: $6,125 pended for failing to pay traffic tickets Sara Heller: $6,115.” 11 am - 9 pm Four Course Surf ‘n Turf Dinner Add a bottle of wine $20 FREQUENT FLYERS CA F É Thanksgiving BUFFET 11:30 am – 9 pm $19.99 All your Thanksgiving favorites! DINNER 5 – 9 pm MIXED GREEN AND PEAR SALAD ROASTED TURKEY DINNER PUMPKIN PIE $24 Visit CDACASINO.COM for all Thanksgiving menus. 1 800 523-2464 | CDACASINO.COM | /CDACASINORESORT NOVEMBER 28, 2013 INLANDER 19 NEWS | POLITICS Idaho’s “Litmus Test” Medicaid expansion under Obamacare is shaping up to be a wedge issue in the 2014 race for Idaho governor BY DEANNA PAN B a sup- 20 INLANDER NOVEMBER 28, 2013 port po- Idaho Gov. Butch Otter has warmed (at least a little) to Obamacare. litical. Accord- ing. Send comments to “A healthier population is more produceditor@inlander.com. tive,”. deannap@inlander.com LETTERS! NOVEMBER 28, 2013 INLANDER 21 22 INLANDER NOVEMBER 28, 2013 THE APPLE CUP Washington St. at Washington Husky Stadium Seattle Fri, Nov. 29 at 12:30 pm The Gunslinger Connor Halliday is guiding the Cougars to their first bowl game in a decade, one pass at a time BISHOP SANKEY >> Year: Junior Hometown: Spokane High School: Gonzaga Prep Height: 5-10 Weight: 203 2013 rushing yds: 1,575 In a Rush Three seasons in, ex-Gonzaga Prep standout Bishop Sankey is leaving his mark on the Husky record book BY HOWIE STALWICK BY MICHAEL MAHONEY O N pposing defenses have spent decades trying to figure out how to stop Mike Leach’s high-octane, no-huddle, pass-happy offense. In most cases, defenses have experienced little success and considerable frustration. Spokane native Connor Halliday knows the feeling, even though he’ll be playing quarterback for Washington State when Leach’s Cougars try to cement their first bowl berth in 10 years Friday at Washington. “He came in last year,” Halliday recalls, “and he tells you a little bit about the offense, but that’s it … even if you’re not getting it.” Halliday shared the starting job last season with Jeff Tuel, who now plays for the NFL’s Buffalo Bills. Both players were shocked to discover how much play-calling Leach entrusts with his quarterbacks. “He doesn’t call very many plays,” Halliday says. “I’d say 70 percent of the time … he’ll call the formation, and then I call the play.” ...continued on page 24 << CONNOR HALLIDAY Year: Junior Hometown: Spokane High School: Ferris Height: 6-4 Weight: 190 2013 passing yds: 3,905 apleading ...continued on page 25 NOVEMBER 28, 2013 INLANDER 23 CULTURE | APPLE CUP The MAC Gives Thanks to the Artists and Patrons of the 2013 • Steven Adams • Laura Blaker • Diana Botkin • Denise Bowles • Don Brown • John Buck • Maria Caldera • George Carlson • Felisa Carranza • Virginia Carter • Margot Casstevens • Clinton Chambers • Dale Chihuly • Jude Clarke • Melissa Cole • Gloria De Los Santos • Coral DeWilliam Studer • Larry Ellingson • Timothy Ely • Hulan Fleming • Neicy Frey • Steven Ford • David Forlano • Ric Gendron • Lila Girvin • Mel Griffin • Tobe Harvey • Sage & Tom Holland • Brenna Helm • Tamara Helm • Melville Holmes • Carlos Horcos • Betsey Hurd • Catherine Hysell • Dick Ibach • Aaron Johnson • Marty Jones • Ildikó Kalapács • Christina Klein • Dalas Klein • Bill Kostelec • Robert Kraut • Robert Krogle • Melissa Lang • Terry Lee • Joey Marcella • Roni Marsh • David Marty • Mel McCuddin • Alan McNiel • Karen Mobley • James Moore • Sean O’Connell • Kay O’Rourke • Kyle Paliotto • Charlie Palmer • Bruce Park • Cliff Rossberg • Brad Rude • Shawn Saumell • Jared Shear • Stephen Shortridge • Hayley ShortridgeGabriel • Patrick Siler • Robert Spannring • Sophie Stein • Paula Turnbull, SNJM • Judy Warner • Gordon Wilson • Mike Wise • Steven Young Lee • Ken Yuhasz • Spokane Town Musicians Gordon Wilson Golden Ticket Selection 24 INLANDER NOVEMBER 28, 2013 Spokane native Connor Halliday has thrown for almost 4,000 yards this season and has put WSU in line for a bowl appearance. “THE GUNSLINGER,” CONTINUED... Halliday says Leach’s reasoning makes sense to him. Now, anyway. “He says, ‘I can give you a play, but how am I going to know if that play is going to be right?’” Halliday says. “‘You’re the guy out there that sees it. I’m on the sideline.’ “‘I?’” Halliday starred in a pass-oriented offense at Spokane’s Ferris High School, but nothing fully prepares a quarterback for Leach’s pass-’til-youdrop style of offense. The Cougars pass more and run less than any other team in major college football (the 123team Football Bowl Subdivision). Halliday ranks third in the nation with 3,905 passing yards (355 per game), first with 597 pass attempts (a Pac-12 Conference record with a couple of games left to play), tied for 12th with 26 touchdown passes and, alas, first with 19 interceptions. Halliday has learned to tone down his gunslinger instincts this season, settling for the many short passes available in Leach’s offense instead of constantly looking to throw the long bomb. Halliday has thrown just two interceptions in the past three games, and he set an FBS record with 89 passes and Pac-12 records with 58 completions and 557 passing yards in an Oct. 19 loss at Oregon. Halliday might be even more respected for his leadership and toughness than his skill. Although he scatters just 190 pounds on a 6-foot-4 frame, Halliday is more than willing to take a hit. Asked to name the toughest player on the team, hard-nosed linebacker Darryl Monroe immediately blurted, “Connor Halliday.” Monroe well remembers Halliday (unknowingly) playing with a lacerated liver most of the game in his first college start two years ago. Halliday simply waited until the end of the game to check himself into the hospital. “He’s the toughest quarterback I’ve ever known,” rugged WSU safety Deone Bucannon says. The Cougars are 6-5 overall, 4-4 in the Pac12; the Huskies are 7-4 and 4-4. Six wins makes a team bowl eligible — many observers consider WSU a lock for a bowl, regardless of Friday’s outcome — but seven wins guarantees a team will go bowling. “It would be terrible to put in all that work, build this program from where it was on up and leave it to old guys [bowl officials] making decisions,” Halliday says. The Cougars finished last four straight years prior to this season, and it took Halliday four years (counting a redshirt season as a freshman) to earn a full-time playing role. He says he never considered transferring, even to schools like Boise State (where father Duane was a backup quarterback), Eastern Washington and Idaho that recruited him out of high school. “I just love this place,” Halliday says. .” n Win 4 Tickets $ & 50 Gift Card to with FREE parking December 12 - 15 Center INB Performing Arts e.com an ok Sp ay dw BestofBroa GO TO inlander.com/milliondollarquartet After a stellar career at Gonzaga Prep, Bishop Sankey is taking aim at UW record books. SCOTT EKLUND PHOTO Tickets for opening night (Friday, December 12th, 2013), non exchangeable, & not redeemable for cash “IN A RUSH,” CONTINUED... semifinalist for the Doak Walker Award, presented to the nation’s top college running back. Coug fans celebrating the possibility of a bowl game for the first time in a decade can only imagine him as the feature back in Mike Leach’s balls.” n NOVEMBER 28, 2013 INLANDER 25 NOW OPEN: The Cigar Loft - A Premium Cigar Sports Lounge. The one and only in the Spokane/Stateline area features 350 fine wines, over 40 micro brews, 6 beers on tap, a savory appetizer menu and a brand new walk-in humidor. Free WiFi! FREE WINE & BEER TASTING Happy Hour 5PM-7PM • NFL Ticket on 13 HDTVs MON, WED, THUR 4 PM-10 PM • FRI-SAT 1PM-10 PM • SUN 10 AM-8 PM CARTONasS as Low $27.99 LOW IDAHO PRICES ON FUEL & TOBACCO! BRAND NEW WALK-IN HUMIDOR Huge Inventory of Premium Cigars, Chew, E Cigs and Cigarettes MON- SAT 5:30AM-11PM • SUN 6:30AM-11PM OPEN ON THANKSGIVING 7200 W. Seltice Way (I-90 Exit 299, next to Cabela’s) (208) 777-7778 • (877)390-5778 Inland Empire Toyota Dealers 4 DAYS DA ON ONLY! Friday, 11/29/2013 Monday, 12/2/2013 PLUS - TOYOTA WILL DOUBLE YOUR DOWN PAYMENT up to $1000 on all 2013 Prius Liftbacks, Rav4s, Camrys, Venzas and Highlanders. 10 models with 0% apr financing! & SPECIAL LOW PAYMENT LEASES! 26 INLANDER NOVEMBER 28, 2013 All offers on contracts through Toyota Financal Services. Subject to credit approval. 0% apr financing for 60 month terms. Double your down payment up to $1000 limited to selected models. Offers valid only 11/29/13-12/02/13. OLYMPIA Winners and losers in Washington’s new budget PAGE 18 MUSIC CULTURE | DIGEST Is the next Justin Bieber in Newman Lake? PAGE 41 JULY 4-10, 2013 | THE FINAL WORD IN LOCAL ENTERTAINMENT NEWS VENTURE AT THE DRIVE-IN T BY MIKE BOOKEY | PAGE 20 901 W E S T S P R A G U E A V E , S P O K A N E | 5 09. 227 . 7 638 Could a drive-in return to Spokane? JIM CAMPBELL ILLUSTRATION. — MIKE BOOKEY Follow the developments of the theater project at facebook.com/spokanedriveintheater. Friends of the Bing present a benefit for & For Your Consideration GRAMMY AWARD WINNER Shawn Colvin BY DEANNA PAN December 8th 7:30 PM Tickets $45 Shook Twins Thefitness ‘Qu. w/ Morning Ritual Dec 14 | 8PM Tickets: $10 - $12 Stay at For Reservations Call: 509.747.1041 or visit *A $2 RESTORATION FEE IS ADDED TO EACH TICKET COST. BINGCROSBYTHEATER.COM NOVEMBER 28, 2013 INLANDER 27 CULTURE | THEATER LOCAL & INDEPENDENT NEWS • INNOVATION • WELLNESS Get your copy at hospitals, medical offices & select Inlander rack locations. Patrick Treadway provides a powerful performance in Our Town. STEPHEN SCHLANGE PHOTO Town and Universe Interplayers has adapted Thornton Wilder’s Our Town without changing a thing, and that’s good BY E.J. IANNELLI Dec/Jan Edition On Stands Dec. 3rd With expanded coverage of health, news, parenting, cooking and more. Always Online! On the New Inlander.com Local stories on topics important to you: parenting, health trends, super foods and much more! /InHealthNW 28 INLANDER NOVEMBER 28, 2013 Tcomthe. n arts@inlander.com Our Town • Through Dec. 14: Wed-Sat, 7:30 pm; Sun, 2 pm • $28 ($22 senior/military, $12 student) • Interplayers Theatre • 174 S. Howard • 455-7529 • interplayerstheatre.org S U P P LE M E N T TO THE IN LAN DE R ’Tis the Season Holiday Guide 2013 2 INLANDER HOLIDAY GUIDE 2013 Come on, Buddy. GET UP. TAKE OFF THOSE DAMN SWEATPANTS. YOU CAN DO IT. THE HOLIDAY SEASON ISN’T AN OPEN INVITATION TO ALLOW THOSE STICKY CANDY-CANE REMNANTS TO MAKE YOU ONE WITH YOUR EGGNOG-STAINED COUCH. NO MATTER HOW MUCH YOU TRY TO TELL YOURSELF THIS IS ACCEPTABLE JUST BECAUSE YOUR SHOPPING IS DONE AND NO ONE SEEMS TO HAVE NOTICED THAT YOU HAVEN’T GONE TO WORK IN TWO WEEKS, YOU ARE WRONG. TURN THE PAGE AND YOU’LL FIND SOMETHING TO YOU DESERVE IT. YOUR FAMILY DESERVES IT. THOSE DAMN SWEATPANTS DESERVE IT. IN THIS GUIDE YOU’LL FIND ENOUGH PLAYS AND CONCERTS AND ICE SKATING AND SOUND OF MUSIC SING-ALONGS AND CRAFTILY LIT CRUISE BOATS TO MAKE EVEN THE JOLLIEST ELF PEE HIS TIGHTS. YOU’RE GOING TO DO SOMETHING THIS SEASON, GOT IT? SERIOUSLY. TAKE OFF THE SWEATPANTS. DO IN THE COMING WEEKS. How long has it been? We can help with Window Treatments • Counter Tops • Hardwood Floors Tile • Carpet • Area Rugs • Wallpaper Plus a full service drapery/fabric department for custom he It ’s t ect Perf ft Gi SECTION EDITOR: Jacob H. Fries DESIGN: Chris Bovey CONTRIBUTORS: Eli Francovich, Laura Johnson, Jo Miller, Chey Scott, Leah Sottile bed spreads, pillows, upholstery & more. Shop Local with 509.534.5064 | wallflwr@aimcomm.com | M-F 9a-5:30p Sat 10a-3p 2820 E. 30th Ave | Spokane, WA | HOLIDAY GUIDE 2013 INLANDER 3 november 28 november 29 november 30 THU, NOV. 28 GAMES AT THE TABLE Presumably you’ve just packed your belly full of turkey, potatoes, rolls, stuffing, green beans and cranberry sauce. It’s going to take a while for that food to start moving along to make room for a sampling of the pies on the kitchen counter — time to get comfy and relax. Instead of taking a nap (although still quite acceptable after a feast like this), gather up the family and have some good old fashioned fun with a game or two. We’re not suggesting the digital variety, but a co-op video game like Mario Kart or Wii Bowling could be fun for all. It’s the older classics, though — Sorry!, Pictionary, Life, etc. — that can really get rowdy and fun, and may just make the extended family forget what’s most annoying about each other. If these board games aren’t on hand, try a more recent release that’s great for entertaining a multigenerational group, the always popular Apples to Apples (if it’s an adults-only affair, maybe the similar yet crude Cards Against Humanity). We also like the simple-tolearn crossword competition game Bananagrams, and its counterparts, Appletters and Pears in Pairs. If you don’t have any of these games, all you need is that 52-card deck in the junk drawer. Start a competitive round of “Pig” or “Snap.” The site classicgamesandpuzzles.com lists the rules and strategies of these and tons of other games. (CHEY SCOTT) 4 INLANDER HOLIDAY GUIDE 2013 Try some low-tech games for the family. [holiday`packages} “KISS ME UNDER THE MISTLETOE” PACKAGE $ 160 30 Min Massage • Hydrating Express Facial • Moisturizing Hair Wash & Style Tanning Session (Matrix or Versaspa Sunless) • Peppermint Mani & Pedi ENTER TO WIN! FRI, NOV. 29 OFFICIAL CHRISTMAS KICKOFF Santa seems to make his rounds at local malls earlier every year, but it’s still perfectly OK to ignore the holiday season entirely until the day after Thanksgiving. Then go all out. The opening ceremony of the Coeur d’Alene Resort’s annual holiday lights show always happens on this official Christmas season kickoff day. It’s an event all Inland Northwesterners should try to experience at some point. An illuminated parade first heads through town, followed by the singing of classic Christmas carols and a spectacular fireworks show over the water. The 160-foot fir at the resort’s entrance is then lit up for the season with 40,000 LED lights. If you can’t make turnon of the official lights display, see it during one of the “Journey to the North Pole” holiday lake cruises, which depart at multiple times daily from the resort through Jan. 1. The holiday lights opening ceremony starts at 5 pm and is free to attend. Cruise prices: free for kids under 5 years, $5 kids ages 6-12, adults $19.75, seniors $18.75. (CS) SPEND $50 AND RECIEVE AN ENTRY TO WIN A GIFT BASKET VALUED OVER $500! BLACK FRIDAY Makes a Great Gift! Bring in 3 Cans of Food For 2nd Harvest Food Bank and get a FREE Entry Level Tan 509.533.6300 • SunnyBuns.com • 2821 E. 27th RED, BROWN, PURPLE, GREEN BLUE AND BCK FRIDAY GREAT PRICES ON ALL COLORS OF SOFAS, EVEN BCK. SOFAS STARTING AT $499 Pole Journey to the North cruises on Lake CdA ily through Jan. 1. run da 303 E. Spokane Ave. 208 664-2131 rungefurniture.com SAT, NOV. 30 SHOP SMALL For those who braved the insanity of Black Friday shopping, congratulations. For those who didn’t, congratulations to you as well. Corporate America’s holiday sales approach is a touchy subject for many, entirely overlooked by others. But with the birth of Shop Local movements and the growing number of “Small Business Saturday” events, it’s becoming trendier and more conscionable to avoid the malls and stick to Main Street. The weekend-long 29th Annual Festival of Fair Trade (Nov. 29-Dec. 1) isn’t on Main Street, per se, but Main Avenue, at the Community Building in downtown Spokane. With the intent of supporting the local economy as well as providing an income to global artisans, the gift fair offers an array of thoughtful, more sustainable choices. Items for sale — including jewelry, clothing, textiles, pottery and more — aren’t made in factories or sweatshops, but handmade by artisans and farmers in Nepal, Mexico, Guatemala and Chile. Those who want to learn more about the global fair trade movement can attend the festival-hosted benefit screening of the documentary Half the Sky: Turning Oppression into Opportunity for Women Worldwide at the Magic Lantern Theatre next door. The festival is open from 10 am-5 pm; documentary at 2 pm. Free admission to festival, $5 suggested donation to see film. Visit festivaloffairtrade.com (CS) CHRISTMAS LAYAWAY One year same as cash OAC. Bellezzaspokane.com 509.321.3660 10 N. Evergreen (Corner of Evergreen & Sprague) salon & spa $50 off Combo Service Includes: Deep Condition, Haircut, Full-Foil & Wax $10 OFF Eyelash Extentions $20 off Sculptured Acrylic Nails $15 Off Pedicures $20 OFF Massage - NEW CUSTOMERS ONLY HOLIDAY GUIDE 2013 INLANDER 5 december 1 december 2 december 3 december 4 december 5 takes two... SUN, DEC. 1 MON, DEC. 2) CANDY AND WAX 6 INLANDER HOLIDAY GUIDE 2013 GET IT ON) 6 december 7) 10 SALE! HOUR december SMALL BUSINESS SATURDAY NOVEMBER 30 9AM - 7PM 50% OFF 60% OFF 75% OFF HOLIDAY DECOR UP TO * HOME FURNISHINGS UP TO * ACCESSORIES The Santaland Diaries runs Dec. 6-22 at Coeur d’Alene’s Lake City Playhouse. SAT, DEC. 7 *Select items. See store for details. ALL THREE SHOWROOMS!) 1727 E Sprague Ave 509-535-1111 401 W 1st Ave 509-413-1185 1702 E Riverside Ave 509-209-3954 HOLIDAY GUIDE 2013 INLANDER 7 48156-11 Nov 22-10 Hour Sale-12V.indd 1 11/6/13 1:28 PM SUPPORT YOUR NEIGHBORS Small Business Saturday November 30, 2013 Small businesses are the building blocks that BLACK FRIDAY November 29, 2013 10:00am - 7:00pm One Day Only! On Site Only! BOGO Special Buy $100 Gift Card Get $100 Gift Card FREE really create the identity of a neighborhood. When you shop local, the owners you stand face to face with are essentially your neighbors. They might literally live down the street from you, they might not, but every local business owner benefits when shoppers take on a we’re-all-in-this-together mentality. By bringing money to their business, you’re helping to secure their livelihood as well as the people they employ. And in return (along with their goods or services, of course) you get an often-rare opportunity to pause, chat and be neighborly. Instead 1237 West Summit Parkway, Suite A 509- 747-3529 | SpaParadiso.com Annu al Festi val of Fair Trade Come�visit�us�next�door! Sponsored by Ganesh Himal & Kizuri Music�EquipmenT Products from Nepal, Guatemala, Chile, Mexico, Thailand, Vietnam, Rwanda & more Guilt�Free�Retail�Therapy home decor, gifts & accessories Thanksgiving weekend Fri, Sat, Sun 10am to 5pm Holiday shopping that makes a world of difference! HOURS: Mon-Sat: 10am-5:30pm Vintage�AudiO Antiques,�Furniture� &�Home�DecoR Uniqu e Gifts & Clothi ng 35 W. Main, Spokane 509-464-7677 Pirate Traders 12415�E.�1st�AvE.�:�509.482.0419�:�Tue-Sat�10-5pm Advertising Supplement BEST SELECTION OF HOLIDAY LO C AL K N • HI POINSETTIAS IN TOWN! •T L A C O L P O SH 509.926.9397 22 Poinsettia Varieties, 9 Paint Colors, Plant-Farm.com & Endless Possibilities! 14208 E 4th Ave Spokane Valley , IT S COMiNG! • L • LI A C V E LO < T h O S e G I rl s > of the usual experience of being herded through a beeping checkout line, you can hear their story. After all, they did what not too Home Decor & Gift Shop many people have the courage to do: start Furniture • Jewelry • Antiq ue Handbags • Soaps • Lotio s ns their own business. Even better, unlike national chains, local SATURDAY 11 . 30 . 13 businesses are in tune to the interests and needs of you, their local customers. They do what they do for you. So just for Boo Radley’s Uncommon Gifts a moment forget about the need to support 232 N. Howard . 456-7479 across from the carousel local businesses for their sake — although that’s obviously important — and think of yourself. When th Nov 30 8am-6pm SS SMALL BUSINELE SATURDAY SA First 50 people get a loot bag! Wedding & Party Rentals • Custom Signs American Paint Mineral Chalk Paint Craft Classes & Retreats you don’t shop local, you’re missing out. Those Girls and True Love are teaming up Saturday Nov 30th! Enter to win prize pack valued over $600. save the date lolo holiday eve fri dec 6th Must purchase min $10 at both location s on November 30th to enter to win. See Facebook for more details. nt 20% off one favorite lolo item small business saturday s Like us for special offernewest pieces! and our Those Girls | 616 E. 3rd Ave True Love | 2001 N. Division 319 west second avenue | spokane 509.747.2867 | loloboutique.net monday-saturday 10—5:30pm Advertising Supplement O C L A K L• N I H Small Business Saturday is a day to remind people to Shop Small® which is a big deal for small businesses. And it’s a really important way to empower people to do something positive for their community. L A C O L P O H •T FINE HOME AND GIFTS The Gift Store for Everyone on Your Shopping List December 6th S Holiday Open House We Offer an Instore Wish List L • LI A V E LOC • DECORUM Make a difference, Shop Local. 305 W. 2nd Spokane WA. 99201 509-340-9830 | Decorumon2nd.com and leave the pies to us. Cut your own Christmas tree, grab one of our take n’ bake pies and ship apples any where in the USA. All while enjoying a hot cup of cider and a delicious holiday treat from the cafe. Nov. 11 to Christmas (10am - 4pm) FRI/Sat/SUN Advertising Supplement appleranch.com 505-238-4709 BURNERS (starting at $69 ) KET TLES (starting at $32 ) ) HOMEBREW STARTER KITS (starting at $89 THANKSGIVING NIGHT SPECIAL 95 95 ok, please don’t buy the same old boring, electronic things that everyone in SPOKANE sells. It is a fine ART to search out gifts that SUPPLY your kids and family with activities and 95 20% OFF Everything In Stock! 11pm to 1:30am Midnight Beer & Wine Tasting Gift Certificates Available! ne Valley Call Us Today! 14109 E Sprague Suite 8, SpokaomeBrew (509) 808-2395 Like us for updates! /NUH Why buy a gift that becomes obsolete in a year? A framed memory will always be cherished. hobbies that enrich their brains! 1 3 0 3 NORTH Creative Design & Quality Custom Framing MONROE 2525 East 29th Ave • Spokane • 509.535.4616 bartlettframing.com • /bartlettgallery ST R E ET “Inland NW most trusted bike shop since 1972” Top 100 Bicycle Retailer out of 6,000 entries by Bicycle Retailer & Industry News 14 Years Running “Best Bike Shop” Chosen “Best Bike Shop” by KREM 2 VIEWERS Find us & follow us for the latest... COME EARLY FOR THE BEST SEATS!! 2013 Fuji Absolute 2.1 $479.99 SALE PRICE $399.99 SAVE $79.99 2013 Fuji Nevada 1.7D $509.99 SALE PRICE $399.99 SAVE $109.99 2013 Fuji Nevada 1.9V $389.99 SALE PRICE $299.99 SAVE $89.99 2013 SE Quadangle $369.99 SALE PRICE $279.99 SAVE $89.99 All of our bikes are Professionally Assembled and come with our exclusive Free Lifetime Gear and Brake Adjustments! BUY A BIKE AND DINNER’S ON US Hours: Mon-Sat 9-6 & Sun 11-4 Receive a $20 Gift Card to the Mustard Seed or Noodle Express with purchase of a bicycle!! Wheel Sport Central 1711 N. Division St. Spokane, WA 99207 509-326-3977 Wheel Sport South 2820 E. 29th St., Ste. 2 Spokane, WA 99223 509-747-4187 Advertising Supplement Wheel Sport East 606 N. Sullivan Rd. Spokane Valley, WA 99037 509-921-7729 december 8 december 9 december 10 december 11 The country-crooning Oak Ridge Boys take the stage at the INB Performing Arts Center on Dec. 9.. 12 INLANDER HOLIDAY GUIDE 2013based december 12 december 13 december 14 COLOR MATTERS You put so much work into that perfect design. Shouldn’t your printing company put just as much effort into printing it right and making sure it has the perfect color? We think so too. DigitalLizardPrint.com • 866.494.6155 CustomerService@DigitalLizard.com 600 W. Buckles Rd Hayden, ID 83835 Manito’s Gaiser Conservatory is lit up Dec. 13-22. for many more local families, who don’t miss the chance to “ooh” and “ahh” ‘n’winning musical Million Dollar Quartet tells the story of what did and could have happened inside the studio’s four walls that fated night. Take a break from all that Christmas music and rock out oldschool instead. $32.50-$72.50. Dec. 14 at 2 pm and 8 pm; show runs Dec. 12-15 at the INB Performing Arts Center. (CS) Not TONIGHT Fri, Nov 29 to Sun, Dec 1 Buy FIVE items from the GIMME FIVE LIST and take 50% OFF ALL FIVE! GIMME FIVE LIST • ALL System JO Products • ALL Panties & Hosiery • ALL Party Supplies • ALL Massage Essentials • ALL Books & Games • ALL Sutera Products 40% OFF In-store merchandise only. One per customer per visit. Not valid with any other offer. Subject to availability. Expires 12/12/13. HOLIDAY GUIDE 2013 INLANDER 13 Holiday Pulse Food The arrival of FIRE (816 W. S a • a a a. in Spokane around this time last year was quite an event, and it’s not hard to see why. The hip restaurant’s artisan pizza is handtossed, fastidiously topped and wood-fired as though every pie were a work of art. Alongside the build-your-own options, there are a few set toppings like the Billy (goat cheese, roasted red pepper, Kalamata olives, fresh arugula), the Crimini (mushrooms, thyme, garlic olive oil, mozzarella) plus an always intriguing daily special. Like Fire, MACKENZIE RIVER Events PIZZA & MORE PIZZA CO. ( 1 W. • a a. recently added a downtown location to complement its Northside and South Hill franchises, which ought to make it easier for holiday shoppers to enjoy a menu that prides itself on unique flavor combinations. Play it safe and traditional with the Bear Tooth Sausage (hot Italian sausage, diced tomatoes, red onions, red peppers) or go adventurous with the Caribbean chicken (spicy jerk chicken, sweet Caribbean sauce, pineapples, topped with fresh cilantro). Even their Buffalo Wing pizza features tempting, out-of- THIS HOLIDAY SEASON, DOWNTOWN SPOKANE IS THE PLACE TO BE. COME VISIT THE INLAND NORTHWEST’S MOST EXCITING DESTINATION. the-ordinary toppings like celery and bleu cheese. A wide range of pastas, salads, burgers and steaks rounds out the menu. EUROPA (125 S. Wall • a . a. a a is renowned for its delicious Tuscan-style pies, but it’s a lot more than that. A full range of salads like the Steak Tenderloin and Harvest Pear, along with pastas, calzones and pastries, makes for a menu that can sate any appetite. Overwhelmed by choice? The chicken marsala gets consistent five-star praise. & downtownspokane.org, good from Nov. 22-Dec. 19, excludes skate rental.) spokaneriverfrontpark.com (625-6601) OUR TOWN Runs through Dec. 14 - See this classic play telling the story of small-town America at the turn of the 20th century. Performances held Wed-Sat at 7:30 pm; select Sat and Sun matinées at 2 pm. $12-$28. Interplayers Theatre, 174 S. Howard St. interplayerstheatre.org (455-7529) THE CHRISTMAS SCHOONER Runs through Dec. 22 - A holiday musical telling the true story of the ships that transported Christmas trees across the Great Lakes. Performances held weekly Thu-Sat at 7:30 pm and Sun at 2 pm. $22-$30. Spokane Civic Theatre, 1020 N. Howard St. spokanecivictheatre.com (325-2507) TREE OF SHARING Through Dec. 12 - Spokane’s Tree of Sharing, the largest organization of its kind in the U.S., provides holiday gifts to thousands of low-income children, women and men in the Inland Northwest each year. Donated gifts are distributed to 50 community service agencies serving those in need. River Park Square, 808 W. Main Ave. treeofsharing.org (290-0002) SANTA EXPRESS Through Dec. 23 - Youth (ages 4-12) can shop for affordable Christmas gifts ranging from 50 cents to $8. Proceeds benefit the Vanessa Behan Crisis Nursery. Open Mon-Sat from 10 am-8 pm and Sun from 11 am-6 pm. Crescent Court skywalk level, 707 W. Main Ave. vanessabehan.org (535-3155) FESTIVAL OF FAIR TRADE Nov. 29-Dec. 1 from 10 am-5 pm - The 29th annual event features local vendors offering globally made gift items from jewelry and pottery to clothing and more, all handmade in sweatshop-free environments. Free admission. Community Building, 25 W. Main Ave. festivaloffairtrade.com (448-6561) CHRISTMAS TREE ELEGANCE Dec. 3 POPOVICH COMEDY PET THEATER Dec. 5-6 at 7:30 pm, Dec. 7 at 11 am - The world-famous Popovich Comedy Pet Theater returns to Spokane, with all its four-legged principals in tow. See 15 cats and 10 dogs — all rescued from shelters — perform cute tricks. $9-$22. Bing Crosby Theater, 901 W. Sprague Ave. bingcrosbytheater.com (227-4704) MACKENZIE RIVER PIZZA CO SPECIAL ADVERTISING SECTION THE NUTCRACKER Dec. 5-8 Thurs-Sat at 7:30 pm and Sat-Sun at 2 pm - Santa Barbara, Calif.’s State Street Ballet dances to the music of Tchaikovsky’s Nutcracker Suite, performed by the Spokane Symphony Orchestra. $25-$75. Martin Woldson Theater at the Fox, 1001 W. Sprague Ave. spokanesymphony.org (624-1200) Shopping Mothers and daughters can shop together at APRICOT LANE (River Park Square • facebook.com/apricotlanespokane), which has a range of fashions that will appeal to shoppers of all ages and tastes. “We’re a boutique, so we carry pieces no one else would carry,” says store manager Rose Lange. “The biggest trends come straight from L.A., and we get six pieces of each item. It’s exclusive to us. So if you have an item, your girlfriend isn’t going to have it, too.” Surprisingly, all that exclusivity CUTE BOUTIQUES doesn’t come at a cost. Prices max out below $80. “Our biggest seller right now is our fleece-lined leggings,” says Lange. “You just have to touch it, and it sells itself.” If you want to snoop before you shop, visit Apricot Lane on Facebook or Instagram, where they frequently showcase new arrivals, great outfit combinations and special promotions. Fashion can be as fickle as it is fleeting, and that’s why it pays to call on ARTEMIS (1021 W. 1st • artemishop.com). This boutique deals in up-to-the-minute styles in clothing, furniture and jewelry, which will put you ahead of the curve when it comes to the finer points of couture — like cuts, prints, colors and fabrics. Breadth doesn’t escape CALAMITY JANE’S (303 W. 2nd • bit.ly/CalamityJanes) either. This cool boutique can supply you with all the sweaters, cardigans, vests, scarves, jackets, dresses and leggings you need for an entire season. For the fashionconscious Cougs, Eagles or Bulldogs fan, it even has stylish university sports necklaces. Bringing Christmas Back to the Crescent! Meet St. Nicholas | Special Treat for Children Live Music Buffet ~ Breakfast December 8th | From eight to two o’clock Adults $19.95 | Children (3-12) $12.95 Children under three are free Call to make reservations Call for all event catering too! 707 W. Main | 509.624.2253 Taking orders for Buche de Noel, Holiday Cookies, and Pumpkin Pie Take a Break from Holiday Shopping with a hot espresso and delicious French pastry! LET YOUR LOCAL AUTHORS HELP YOU SHOP ARTEMIS Cool Carriage Nov. 29-Dec. 24 Fri 3-8 pm, Sat-Sun 12-5 pm, Christmas Eve 12-3 pm To the Spokane community, downtown’s horse-drawn carriage is the epitome of the Christmas season. The rides, both classic and timeless, allow the whole family to do something together, and can be a fun experience for all ages, toddlers to teens. The old-fashioned carriage takes riders throughout downtown Spokane to enjoy the festive sights and sounds of the city during the holiday season. If you see the slowmoving carriage while out and about, you might hear riders singing Christmas carols and see them munching on candy canes. If anything, you’ll at least hear the horses clop-clop on the pavement and the cheery jingle bells around their harnesses. The best part? The annual downtown carriage rides, sponsored by STCU, cost only a smile. Free • Departs from Wall and Main • downtownspokane.org SPECIAL ADVERTISING SECTION Bestselling authors will be in store, helping you select your perfect holiday books at Auntie’s on Saturday, November 30, from 11 am to 4 pm. 11 am to 1 pm: Jess Walter and Kelly Milner Halls 1 to 3 pm: Kenn Nesbitt and Chris Cook with Rosanne Parry 2:30 to 4 pm: Trent Reedy and Shawn Vestal with Glenda Burgess We hope to see you there, too! Shopping ACTIVE LIFESTYLES PISTOLE LULULEMON (707 W. Main • ace oo co u u e onS o ane caters to both runners and yogis of any gender, with all the requisite gear for each activity and a pinch of style to boot. Some of their seasonal cold-weather running attire incorporates clever materials that keep you warm without adding weight. Or turning you into a SPECIAL ADVERTISING SECTION living pressure cooker. Plus, there are Merino wool gloves with “tech-friendly” fingertips so you can still use your smartphone on frigid winter days, as well as goose-down wraps that are both form-fitting and cozy-warm. “Our holiday shopping bags are reusable, as always, and have a snap on the inside to make gift-giving super easy,” says Nina Gardner, who handles community relations for Lululemon. “I’d rather take the time I spend wrapping and get a run in anyways. Spokane is such an active community, full of runners and yogis — I imagine they feel the same!” Pick up their four-page holiday guide full of gift ideas for men and women in their new downtown store. Whether you skate, snowboard or just dig the fashion, PISTOLE S o ard • sto e est e co will equip you with everything you need, including boards by Stereo and PowellPeralta or threads by Gnarly and Fallen. ATHLETA er ar Square, second floor • atheta a co , the Gap-owned specialty fitness store for women, has been making inroads in the Pacific Northwest and has just opened a brand new store in River Park Square. Their line of yoga, running and seasonal sport attire is as functional as it is fashionable. Food YOUR DESTINATION FOR GREAT COCKTAILS, FOOD, AND MUSIC HOME OF THE RAINDROP MARTINI INTERNATIONAL FLAVORS Owned by KHQ anchor Stephanie Vigil and her husband Jay Underwood, MISO (River Park Square Food Court • misofreshasian.com) has quickly become a popular mid-shopping food stop due to its reliably fresh, fast, high-quality Asian fare. In addition to lots of vegetarian options, there are some great Eastmeets-West sandwiches like the Vietnamese bánh mi, which features Sriracha mayo, cilantro and a choice of meat, seafood or organic tofu on a bakery-style bun; or the increasingly soughtafter spring rolls, wrapped in light rice paper and served with a Thai peanut dipping sauce. “Our objective was to try to emulate some Southeast Asian street-vendor-type fare — something unique for a food court setting with what we think are healthier food options and flavors that aren’t your typical Thai or teriyaki,” says Underwood. “It’s got our own vibe to it.” All dishes are wok-sizzled right in front of you, and the emphasis on speed means shoppers are guaranteed a “piping hot meal” in “less than five minutes.” You might want to move to PHỚ CITY (112 N. Howard • phocity509.com) if you’ve got a predilection for this classic Vietnamese soup. Although their menu features other tantalizing dishes like fish sauce wings and lemongrass tofu vermicelli, phở (pronounced “fah,” incidentally) is where they really excel. The website also makes it incredibly easy to place your order online for convenient carryout. For some authentic Thai cuisine, head to THAI ON FIRST (411 W. 1st), a favorite of foodies and spicy-hot addicts for more than two decades in downtown. The City’s parking PARKING RANGERS enforcement staff also serve as parking ambassadors, and they can give you directions and answer your questions related to parking. Now known as the Parking Services Group, they work closely with the Downtown Spokane Partnership and downtown businesses. is brought to you by the Downtown Spokane Partnership and the Business Improvement District in conjunction with the Inlander. For more info go to DowntownSpokane.net FOOD - Sandwiches to savor SHOPPING - Cute Boutiques JUST FOR KIDS HOLIDAY PULSE PHÓ CITY NEXT WEEK 1009 W. 1st Ave. (next to Scratch Restaurant) 509.456.5656 :: rainspokane.com ! MORNING BRIEFING IN ADDITION TO HOT, NEW ITEMS, JAN, THE TOY LADY, CARRIES CLASSIC TOYS: We’ve made it 2 years! Anniversary Sale 10% off all in-stock items Nov 27 - Dec 4 Romper, bomper, stomper, too! Tell me, tell me, tell me, do! Fresh News, Every Morning. Only on Inlander.com Oops! Wrong screen! River Park Square (509) 456-TOYS Downtown • 824 W Sprague Avenue • 509-340-2800 • SPECIAL ADVERTISING SECTION Nightlife WINE TASTINGS USED, RARE OUT-OF-PRINT 10% OFF YOUR PURCHASE Unique Gifts & Fine Crafts Made Locally 123 S. Wall St. Spokane 509.838.0179 PotteryPlacePlus.com | 509.327.6920 North of Auntieʼs in the Liberty Building for holiday hours, go to Banana Republic monkeyboybooks.com BARRISTER Sephora Pottery Barn Magic that light s up the holidays. Find the brands you love, and the gifts they’ll love, only at River Park Square in Downtown Spokane: Nordstrom, The Apple Store, Sephora, The North Face, Pottery Barn, and so much more. Visit riverparksquare.com to purchase gift certificates online; gift certificates can be mailed anywhere within the U.S., or picked up at the Concierge desk at River Park Square. riverparksquare.com • 509.363.0304 808 W Main Ave • Spokane, WA SPECIAL ADVERTISING SECTION PATIT CREEK (822 W. S ra ue • atitcreekcellars. com) opened its downtown tasting room this past June. Located across from the Davenport Hotel, it makes a great starting point for a short urban tour of some of the best vintners in Washington state. Here visitors can sample Merlot, Bordeaux and Cabernet Sauvignon wines from vineyards in the Columbia and Walla Walla valleys. “We have other varietals like our signature red blend called The Creek,” says Sonya Morrison, Patit Creek’s director of hospitality for Spokane. “It’s similar to the bordeaux, but it has Grenache [grapes] in the body so it’s a bit lighter.” An off-season hit this year is the lightly oaked chardonnay, which has seen sales continue into the autumn months. “Normally I think of whites as more summertime wines, but people are really enjoying it,” says Morrison. Patit Creek’s tasting room is unique in that it allows visitors to enjoy hors d’oeuvres that have been paired with appropriate wines. The winter menu, which rolls out in early December, will feature a cabernet cream cheese brownie. From there, head west to BARRISTER ( io Pacific Railroad • barristeri er .com), where each sip is enhanced by the rarity of the vintage. In 2012, for example, Barrister only produced about 3,200 cases of red wine and just 400 cases of white. But before you put it on your itinerary, be sure to make a note of Barrister’s holiday hours. Every vintage — all of them red — produced by WHITESTONE WINERY ( . Post • hitesto e i er .com) comes from their family estate vineyard next to the massive outcrop of Whitestone Rock near Lake Roosevelt. Their tasting room offers at least five wines that derive from their exclusive Cabernet Franc, Cabernet Sauvignon or Merlot grapes. “We’re really well known for our Pieces of Red,” says tasting room employee Carrie Jorgens. “It’s a popular and award-winning blend of Cabernet Sauvignon and Merlot.” Whitestone’s top-of-the-line blend is the St. Vincent Meritage: a deep purple mix of Cabernet Sauvignon, Merlot and Cabernet Franc in a 6:3:1 ratio aged in new French oak barrels. Finally, cap off your mini-tour (there are even more wineries downtown) at the downtown tasting room for ARBOR CREST (River Park Square, third floor • arborcrest.com), another family-owned regional winery that is popular with oenophiles as well as causal wine drinkers. Their prize-winning varietals and blends include the acclaimed Dionysus meritage blend, Malbec and a Columbia Valley Syrah. december december 15 december 16 17 See our local boy Bing on the big screen in the holida y classic White Christmas at the Bing Crosby Theat er on Dec. 15. SUN, DEC. 15 MON, DEC. 16 TUE, DEC. 17 Movies and Christmas are like apple pie and baseball — AllAmerican. performs at 5:30 pm and White Christmas at 6 pm. At the Bing Crosby Theater. Tickets are available at TicketsWest or at the door: $8 for adults (all day, does not include bus tour), children 12 and under free. (ELI FRANCOVICH) For a kid, an allowance can be limiting, especially come the holiday season. That’s why the Vanessa Behan Crisis) HOLIDAY FILM FESTIVAL ALLOWANCE-FRIENDLY SHOPPING CHRISTMAS-LIGHT STALKING HOLIDAY GUIDE 2013 INLANDER 19 december 18, the organization is always in need of more hands. To sign up contact: 252-6257 or volunteer@2-harvest.org. (EF) THU, DEC. 19 SHIPS AND CHRISTMAS TREES We all have our own horror stories about finding a Christmas tree. It’s either the gardenvariety “We drove all over and they were so rude to us and all the trees were anemic runts,” or the hardier “I hiked for 30 minutes and then cut it down with my Leatherman Multi-Purpose tool.” Volunteer and give back by helping sort spokane crafted ales 5 min from downtown spokane • eight taps • beers handcrafted on site • patio seating • trivia thursdays . donations at Second Harvest Food Bank Ho, ho, holy moly. Switch your number to Sprint and save up to $100 on any phone. Orig. Get unlimited talk, text and data while on the Sprint network with the Unlimited, My WaySM plan. Guaranteed for life and only from Sprint. $ 19999 Now 9999 $ Reg. qualifying data plan & new 2-yr. agmt./activation. 2204 east mallon ave Sprint 4G LTE available in select markets. irongoatbrewing.com Screen image simulated. Activation Fee: $36/line. Credit approval required. Early Termination Fee (sprint.com/etf): After 14 days, up to $350/line. Unlimited Guarantee: Available while line of service is activated on the Unlimited, My WaySM plan or My All-inSM plan. Applies to unlimited features only. Price and phone selection subject to change. Account must remain in good standing and non-payment may void guarantee. Non-transferrable. Plan: No plan discounts apply for talk or messaging. Premium content/downloads are an addʼl charge. Text to 3rd parties to participate in promotions or other may result in addʼl charges. Intʼl svcs are not included. Includes select email. Amount of data depends on option selected.. Port-in Instant Credit: Offer ends 11/27/2013. $100 instant credit applied toward purchase of qualifying Sprint phone or smartphone. $100 credit will be applied within 3 invoices. Other Terms: Offers and coverage not available everywhere or for all plans or networks. Restrictions apply. See store for details. ©2013 Sprint. All rights reserved. Sprint and the logo are trademarks of Sprint. All other marks are property of their respective owners. tue–fri 4–9, sat 2–9 509.474.0722 facebook.com/irongoatbrewing 20 INLANDER HOLIDAY GUIDE 2013 IronGoat_Inlander_2unit_basic.indd 1 10/7/13 1:43:43 PM december 19 21 20 pm. (EF) VISIT FIRSTNIGHTSPOKANE.ORG FOR MORE INFORMATION. december december) 13TH ANNIVERSARY CELEBRATION 2014 TUESDAY, DECEMBER 31ST DOWNTOWN SPOKANE PICK UP YOUR PASSPORT and return it when completed to one of our four convenient locations (Spokane Convention Center, INB Performing Arts Center, Bank of America, and River Park Square) during the First Night event. 7p.m. to 10 p.m. Complete information at firstnightspokane.org Buttons Now On Sale! BUY YOUR ADMISSION BUTTON EARLY & SAVE! • $15 through Dec. 30 • $18 on Dec. 31 • Children 10 & Under FREE Admission buttons now available at Cenex Zip Trip Stores, River Park Square Concierge, Aunties Book Store & Aunties Annex, and Tickets West. OVER 150 PERFORMANCES AT 40 LOCATIONS INB Performing Arts Center Haran Irish Dancers and Floating Crowbar 7 p.m., 8 p.m. & 9 p.m. and The Curt Show 10 p.m. & 11 p.m. 4TH ANNUAL 5K RESOLUTION RUN Starting in River Front Park at 6:45pm on New Year’s Eve, Entry is Free!! For complete race information go to firstnightspokane.org SPONSORED BY NUMERICA CREDIT UNION Hotel Packages Available Convention Center Ballrooms A&B – 7 p.m. – 11:40 p.m. - Variety Show with Alex Zerbe, David Lichtenstein a.k.a., Leapin’ Louie, Dan Raspyni, The Comedy Circus Show and Charlie Williams, The Noise Guy. Miss Abbey’s Steampunk Spectacular, Blue Door Theatre, Bopping Heads and much, much more. North of Main Avenue Singing in the New Year Finale – IMAX Theatre 7 p.m. – 11:40 p.m., Free Carousel Rides sponsored by STCU, Fox 28 Main Stage dancing until midnight, Spokane Civic Theatre players at Wheatland Bank Drive-thru West of Post Street Ballet at the Bing, 48 Hour Film Festival, Comedy, Theatre, Drumming, Music, Crafts and Magic. South of Main Avenue Music and dance from Latin to rock and roll, visual arts, craft making and more FREE PARKING & SHUTTLE SERVICE Shuttles every 10 min. from Riverpoint Campus Midnight Fireworks Spectacular by See package listings at, Get your Event Program in the 3-6pm at the Spokane Convention Center Crafts, Live Performances, And more... December 19th issue of Extended hours 7-9pm HOLIDAY GUIDE 2013 INLANDER 21 december december december december december 22 23 24 25 26 Traditions of Christmas runs Dec. 12-23 at the Kroc Center in Coeur d’Alene. SUN, 22 INLANDER HOLIDAY GUIDE 2013) december 27 december 28) HOLIDAY GUIDE 2013 INLANDER 23 december december 29 SUN, DEC. 29 EAT A WHEEL OF CHEESE Not sure how you operate, but during the holidays I like to feel as gross as possible about myself. No — I’m dead serious. I’m a big eater. It’s gross, and I try to keep in check the rest of the non-holiday days of the year. But from Christmas Eve until New Year’s Eve, I usually can be found consuming as much as my stomach will allow because it is more socially acceptable to be gluttonous, and because I know I’m going to torture myself at the gym come Jan. 1. A few years ago, I discovered the sharp, piquant joy that is Cougar Gold cheese — made by hand at the WSU Creamery down in Pullman — at my grocery store, and brought a can home. Between Christmas and New Year’s, my husband and I ate the entire 30 oz. wheel of cheddar. How? You do it by eating Cougar Gold for breakfast. Cougar Gold for lunch. For snacks. With coffee. In front of the TV. Laying in bed with a book. Do yourself a favor: buy a can now and suck it down before your New Year’s resolutions 24 INLANDER HOLIDAY GUIDE 2013 30 of juice cleanses and morning yoga kick in. Trust me: Cheese doesn’t mix with fitness. Find it at local stores and at cougarcheese.wsu.edu. (LEAH SOTTILE) MON, DEC. 30 GET ALL NORMAN ROCKWELL When Norman Rockwell was painting his portraits of American life, he had to have been imagining a place like Spokane, where horse-drawn carriages clop along the streets during the holidays, where holiday music emanates from invisible speakers downtown and twinkle lights brighten up the industrial facade of the city. A city where at the very center, there is an ice skating rink. Suit up the family in their winter finest and head down to Riverfront Park for an evening of skating and hot cocoa at the Ice Palace. Admission for kids is just $3.50, and for adults (13 and older) it’s $4.50. Rentals available. Visit spokaneriverfrontpark. com. (LS) N ew 2U december 31 C onsignment Layaway available for the holidays *Come in and ask how!* Baby Kids Women’s Name-brand Purses b and more! b b b b 12021 E. Sprague Ave. (1/2 block W. of Pines) 509-891-0143 Sandpoint A Hometown Place To Be • TREE LIGHTING CEREMONY Nov. 29 at 5 pm. Santa arrives 6 pm! Holiday entertainment and hot cider in Jeff Jones Town Square. • GET YOUR JINGLE ON Thurs. Dec. 6-8. Shopping specials and door prizes downtown all weekend. • GUY’S NIGHT OUT Thurs. Dec. 20. Evening shopping and specials downtown for last minute shoppers. • SANTA AT THE NORTH POLE Saturdays Nov. 30-Dec. 21 from 11am-3pm. Visit Santa Claus in the Cedar Street Bridge. FREE PARKING Ring in the New Year with Helado Negro at the Bartlett on Dec. 31. IN THE CITY LOT THANKSGIVING THROUGH NEW YEAR’S DAY TUE, DEC. 31 DANCE ’TIL DAWN There’s a lot to do in Spokane on New Year’s Eve — from the traditional Spokane Symphony performance of Beethoven’s Ninth at the Fox, to the glittery Lincoln Center party Bling in the New Year to First Night Spokane. But if pressed, we’re the types who like to ring in the new year with a good old-fashioned dance party. Spokane’s hippest soon-to-be-open joint, the Bartlett, has got you covered. Electronic artist Helado Negro comes to town, toting a catalog of warm, ethereal, upbeat tunes that reflect both his tropical South Florida upbringing and his newfound attraction to the woods of Connecticut. This is the exact opposite of the EDM rave stuff you’ll hear pounding away at lots of clubs; Helado Negro makes electronic music for the more mature, cocktail-sipping set. Get your tickets now for the show, which is 21-and-over only. They’re for sale at thebarlettspokane.com for $30 a pop. (LS) SandpointOnline.com Photo courtesy Bonner County Daily Bee HOLIDAY GUIDE 2013 INLANDER 25 The fur children can try convincing Santa they’ve Holiday Treats BENEFIT CHRISTMAS TREE ELEGANCE 18 holiday trees are on display and available to win in a fundraiser raffle benefiting the Spokane Symphony. Trees are located on the mezzanine of the Davenport Hotel (Dec. 3-14 from 10 am-9 pm) and on the 2nd floor of River Park Square (Dec. 3-15, from 10 ammall closing). Free to view, $1/raffle ticket. spokanesymphonyassoc.org CRAB FEED & AUCTION Annual event benefiting local children’s organizations, including the Vanessa Behan Crisis Nursery and the Children’s Home Society of Washington. Dec. 7 at 4:30 pm. $65. Convention Center, 334 W. Spokane Falls Blvd. downtownspokaneexchangeclub) GINGERBREAD BUILD-OFF The annual fundraiser benefiting Christ Kitchen features elaborate gingerbread houses decorated by local culinary teams, with the public voting for their favorites. Kids can also make their own gingerbread houses. Dec. 15 at 10 am. $1-$7. Davenport Hotel, 10 S. Post St. christkitchen.org (325-4343) COMEDY GUFFAW YOURSELF! Open-mic comedy, including stand-up, sketch, improv or anything weird. Five minutes per performer. Every other Thursday at 10 pm. Free. Neato Burrito, 827 W. First Ave. (847-1234) FAMILY DINNER Live comedy improv show 26 INLANDER HOLIDAY GUIDE 2013 based on audience suggestions about their family members. Fri at 8 pm through Nov. 29. $7-$9. Blue Door Theatre, 815 W. Garland Ave. (747-7045) SEASONS GREETINGS Live comedy improv show using holiday cards and messages for inspiration. Dec. 6-17, Fridays at 8 pm. $7-$9. Blue Door Theatre, 815 W. Garland Ave. (747-7045) AN EVENING WITH MARIA BAMFORD Live comedy show. Dec. 7 at 9 pm. $16$20. Knitting Factory, 919 W. Sprague Ave. sp.knittingfactory.com (244-3279) CHRISTOPHER TITUS & RACHEL BRADLEY Live comedy show. Ages 18+. Dec. 15 at 8 pm. $25. Knitting Factory, 919 W. Sprague Ave. sp.knittingfactory.com (244-3279) MEG O’ROURKE The New York comedian presents an evening of stand-up. Dec. 27 at 8 pm. Free. Ages 21+. nYne Bar, 232 W. Sprague Ave. nynebar.com (474-1621) COMMUNITY HELP THE HUNGRY FOOD SORTING Join other volunteers to sort and pack produce and other bulk food items for delivery to local emergency food outlets. Ages 14+. Volunteer shift times and need varies, sign up online at 2-harvest.org. Second Harvest Food Bank, 1234 E. Front Ave. (252-6267) RIVERFRONT PARK ICE SKATING The Ice Palace is now open through March 2; TuesSun from 11 am-5 pm, and also Tues-Thurs from 7-8:30 pm; Fri-Sat from 7-10 pm. Extended holiday hours TBA. Adults/$4.50; kids ages 3-12, military and seniors/$3.50. Skate rental $3.50. spokaneriverfrontpark. com (625-6601) HOLIDAY GIFT DRIVE Gift drive for new or gently used board games and arts and crafts supplies, to benefit families served been good at “Santa Claws For Pets and People” at by rural DCFS offices in the Spokane area. Drop off unwrapped gifts Mon-Fri between 8 am-5 pm, through Dec. 10. Empowering, Inc. Services, 1025 W. Indiana Ave. (6247104) JOURNEY TO THE NORTH POLE 40-minute family lake cruises with a visit to Santa at the end. (No cruise on Thanksgiving Day.) Departs daily at 5:30 pm, 6:30 pm and 7:30 pm through Jan. 1. Kids ages 6-12/$5, kids under 5/ free; adults/$20, seniors/$19. Coeur d’Alene Resort, 115 S. Second Ave. cdalakecruises.com (208-6647268) SANTA EXPRESS The annual kids’ gift store benefits the Vanessa Behan Crisis Nursery and features allowance-friendly items for children to purchase as gifts for friends and family. Open daily through Dec. 23, MonSat from 10 am-8 pm, Sun from 11 am-6 pm. Crescent Court Bldg., Skywalk level. Items priced between $0.50-$8. Crescent Court, 707 W. Main Ave. vanessabehan.org TREE OF SHARING Community members can pick up a tag noting gift items requested by local charities serving those in need. Gift items must be returned by Dec. 12 for distribution to recipients. Pick up tags at Northtown, Spokane Valley, or River Park Square malls before Dec. 12. treeofsharing. org (290-0002) WOMEN & CHILDREN’S FREE RESTAURANT VOLUNTEERS Volunteers are needed as prep cooks, servers, dishwashers, food platers and to work various other shifts during the week, Mon-Fri. Positions are weekly or biweekly, and a food handlers card is required. Submit a volunteer application online. wcfrspokane.org (324-1995) CDA RESORT HOLIDAY LIGHT SHOW The 27th annual holiday light display features more than 1.5 million lights, and is the largest on-water display of its kind in the U.S. the Lincoln Center on Dec. 1. Nov. 29-Jan. 1, 2014. Lighting ceremony, parade and fireworks show on Nov. 29 starting at 5 pm. The Coeur d’Alene Resort, 115 S. Second Ave. cdaresort.com (208-7654000) DASHING THROUGH DOWNTOWN Enjoy downtown Spokane by horse and carriage, sponsored by STCU. Nov. 29-Dec. 24, Fri from 3-8 pm, Sat-Sun from noon-5 pm, and Mon, Dec. 24, from 12-3 pm. Free. Corner of N. Wall St. and W. Main Ave, downtown Spokane. downtownspokane.org FESTIVAL OF FAIR TRADE The 29th annual event features local and globally-made handcrafts, clothing, jewelry, pottery and more, made in non-sweatshop environments. Nov. 29-Dec. 1 from 10 am-5 pm daily. Free admission. Community Building, 35 W. Main Ave. festivaloffairtrade.com (448-6561) DAYTON’S CHRISTMAS KICKOFF Fireworks show on Friday; lighted parade, hayrides, Santa’s workshop, live Nativity and more on Saturday. Nov. 29-30, starts at 11 am each day. Free. Dayton, Wash. historicdayton.com (509-382-4825) HOLIDAYS IN SANDPOINT Traditional tree-lighting ceremony featuring caroling, a visit from Santa and more. Nov. 29. Free. Downtown Sandpoint, Idaho. sandpoint. com (208-263-2161) SANTA CLAWS FOR PETS & PEOPLE Fundraiser event benefiting local animal rescue nonprofits, featuring Santa photos, a pet food drive, local vendors, adoptable pets, raffle, games and more. Dec. 1 from 12-2:30 pm. Free admission. Lincoln Center, 1316 N. Lincoln St. wabr.net (590-9667) SOAP FOR HOPE DRIVE The sixth annual toiletry drive benefits local charities, including Hope House/StreetWise, Hearth Homes, Transitions for Women and more. NEW OWNERS • NEW LOOK ard St. (625-6600) CHRISTMAS LIGHTS WALK A sanctioned volksswalk (5K or 10K) to view holiday lights displays. Flashlights recommended; homemade soups and bread served after. Dec. 14 at 5 pm. Free. Meet at Spokane Friends Church, 1612 W. Dalke Ave. lilaccityvolks.com (326-3575) WINTER DATE NIGHT Reconnect with friends or a loved one, sans kids, who can participate in programs and entertainment. Ages 3 mos.-11 years. Dec. 14, 6-9 pm. $10/ child. Kroc Center, 1765 W. Golf Course Rd. krocccda.org (208-667-1865) FRIENDS OF MANITO OPEN HOUSE The organization is selling calendars and locally-grown Poinsettia plants. At the Manito Meeting Rm., east of the Gaiser Conservatory. Dec. 14-15 from 4:30-7:30 pm. Free admission. Manito Park, 1800 S. Grand Blvd. friendsofmanito.org (456-8038) HOSPICE TREE Hospice of Spokane displays its Memorial Tree for community members to honor loved ones by purchasing a dove ornament to hang on the tree, with proceeds benefiting Hospice of Spokane. Dec. 14-23. River Park Square, Third Level, 808 W. Main Ave. hospiceofspokane. org (456-0438) CHRISTMAS LUNCH WITH SANTA The community center hosts a lunch with Santa, including photos and prizes; open to all. Dec. 17 from 12-1:30 pm. $8. Southside Senior & Community Center, 3151 E. 27th Ave. sssac.org (535-0803) MOBIUS KIDS’ LEGOMANIA Build elaborate bases, vehicles and create a winter wonderland, complete with snow. Ages 4-10. Dec. 18, 4-5 pm. $8-$10. Mobius Kids, 808 W. Main Ave. mobiusspokane.org (3217124) CAMPBELL HOUSE HOLIDAYS See what the historic mansion would have been like during the holidays in 1910, with professional local actors portraying residents like the cook, the family and their visitors. Included in regular museum admission. Dec. 20 from 12-4 pm. $5-$10. Northwest Museum of Arts & Culture, 2316 W. First Ave. northwestmuseum.org (363-5355) MOBIUS KIDS SHOP-N-DROP Parents can drop of children at Mobius Kids for holidaythemed activities while they finish Christmas shopping. Dec. 20 from 1-4 pm and from 5:30-8:30 pm. All ages of children welcome (must be able to use restroom independently). $15/child. Mobius Kids, 808 W. Main Ave. mobiusspokane.org (321-7124) SCHOOL’S OUT DAY CAMP Day camps during Christmas vacation offer activities including swimming, rock climbing, crafts, games and more. Lunch and snacks provided. Ages 6-13. Dec. 23 and Dec. 30 from 9 am-4 pm. $45/session. Kroc Center, 1765 W. Golf Course Rd., CdA. krocccda.org (208-667-1865) MOBIUS KIDS’ BOXING DAY Celebrate the Canadian holiday of Boxing Day by building a box city across the museum floor. Dec. 26 from 10 am-1 pm. Free with museum admission. Mobius Kids, 808 W. Main. mobiusspokane.org (624-5437) COOL CAMP Spokane Valley Parks & Rec hosts a winter day camp for kids, ages 6-11, with activities, crafts, games and field trips. Dec. 30-Jan. 2 from 8 am-5 pm. Online registration available, space is limited. $30/day or $100 for full camp. CenterPlace Regional Event Center, 2426 N. Discovery Place Dr. spokanevalley.org/recreation. (688-0300) FIRST NIGHT SPOKANE Annual family New Year’s celebration featuring more than 150 performers at 40 downtown locations, including live music, art demonstrations, comedy shows and free ice skating. Dec. 31 TOYS-4-TANS from 7 pm-midnight. $5-$18, kids under 10 free. firstnightspokane.org (456-0580) FILM CHITTY CHITTY BANG BANG Screening as part of the Garland’s “Totally Tubular Tuesdays” series. Dec. 3 at TBA. $1. Garland Theater, 924 W. Garland Ave. garlandtheater.com (327-1050) RIFFTRAX LIVE: “SANTA CLAUS CONQUERS THE MARTIANS” Live screening of the movie with the commentary by stars of “Mystery Science Theater 3000.” Dec. 5 at 8 pm. $12.50. At Regal Cinemas Northtown Mall and Regal Cinemas Riverstone, CdA. fathomevents.com (800-326-3264) INTO THE MIND Ski and snowboarding film by Sherpa Cinema. Dec. 6 at 7 pm. $15. Panida Theater, 300 N. First Ave. panida. org (208-263-9191) SCROOGED Screening as part of the Garland’s “Totally Tubular Tuesdays” series. Dec. 10 at TBA. $1. Garland Theater, 924 W. Garland Ave. garlandtheater.com (3271050) BING CROSBY HOLIDAY FILM FESTIVAL The 8th annual festival features classic Bing Crosby films, and a motor coach tour “On the Bus with Bing,” visiting Spokane places where Crosby lived and played (Dec. 15 from 1-4 pm, $20). Film fest: officially airs in the U.S. Dec. 15 from 2-4 pm Free, reservations required. Lincoln Center, 1316 N. Lincoln St. ksps.org (800-735-2377) CHRISTMAS SPECIAL Screening (film TBA) as part of the Garland’s “Totally Tubular Tuesdays” series. Dec. 17 at TBA. $1. Garland Theater, 924 W. Garland Ave. garlandtheater.com (327-1050) INLANDER GIVE GUIDE PRESENTS: ELF The Inlander’s Give Guide, the annual local philanthropy issue, hosts a screening of the holiday family film with proceeds benefiting Catholic Charities of Spokane. Dec. 18 at 7 pm. Price TBA. Bing Crosby Theater, 901 W. Sprague Ave. bingcrosbytheater.com (227-7404) RIVERFRONT PARK HOLIDAY FILM FEST Films to be screened include “Arthur Christmas,” “Elf,” “Disney’s A Christmas Carol” and “How the Grinch Stole Christmas.” Dec. 21-24 and Dec. 26-29 at 11 am, 1 pm, 3 pm and 5 pm daily. Free. Riverfront Park, IMAX Theater, 507 N. Howard St. (625-6600) K (TOYS FOR TOTS) Bring a new toy in on BLAC FRIDAY and receive a FREE TAN! ONE MONTH UNLIMITED TANNING 25 15% OFF LEVEL 2 & 3 BEDS $$ * * LEVEL 1 BEDS MUST PRESENT COUPON 509.483.7359 MUST PRESENT COUPON 1225 E. Francis, Spokane :: TropicalTanSpokane.com GIFTS FOR EVERYONE Wait a ON YOUR LIST. minute.... I hate all of these people. Even if the only person on it is yourself. We understand. CRAFTS CHRISTMAS CARD MAKING CLASS Class on stamping and die-cut making. All materials provided. Dec. 5 from 12-2 pm. Free. Hayden Library, 8385 N. Government Way. (208-772-5612) CRAFT FAIR Featuring handmade items by Providence staff and supporters. Dec. 6 from 8 am-4 pm. Providence Holy Family, 5633 N. Lidgerwood St. holy-family.org (482-0111) VINTAGE VIXENS HOLIDAY SHOW Local vendor gift fair featuring antique, retro and primitive items, paper crafts and more. Dec. 6-7 starting at 10 am each day. Riverwalk Plaza, 1003 E. Trent Ave. DECK THE FALLS Annual holiday gift sale featuring work by local and regional artists. Dec. 7 from 10 am-4 pm. Free admission. Cutter Theatre, 302 Park St., Metaline Falls. cuttertheatre.com (509-446-4108) 50% OFF ALL MERCHANDISE 25% OFF ALL GLASSWEAR *ALCOHOL ALREADY AT AMAZING PRICES. SO WHY DISCOUNT? DRY FLY [drink responsibly] Donations can be dropped off at any local AAA office. through Dec. 31. AAA Downtown Spokane, 1717 W. Fourth Ave. aaa. com/soapforhope TEDDY BEAR & BLANKET DRIVE Hosted by the Health Policy and Administration Association of Healthcare Students at WSU. Bears to go to children at Shriners Hospital for Children and Sacred Heart Children’s Hospital. New or gently used blankets to be donated to homeless teens at CrossWalk shelter. Dec. 3-4 at 11 am. WSU Riverpoint Campus, 412 E. Spokane Falls Blvd. (3587500) LANDS COUNCIL HOLIDAY PARTY Annual holiday celebration hosted by the local environmental nonprofit. Dec. 4, 5:30-7:30 pm. Community Building, 35 W. Main Ave. landscouncil.org (232-1950) SPOKANE BLIND BASEBALL FUNDRAISER Open mic Christmas carols, holiday trivia, silent auction and more. 25 percent of the night’s sales to be donated by Shakey’s Pizza to the nonprofit. Dec. 4, 5:30-8:30 pm. Free admission. Shakey’s Pizza, 9602 N. Newport Hwy. (464-0200) DECEMBER D’LIGHTS Holiday season kick-off celebration featuring hayrides, children’s activities, food, beverages, a tree-lighting ceremony and parade. Dec. 6 at 5 pm and Dec. 7 at 1 pm. Free. Rathdrum, Idaho. (208-687-2866) BREAKFAST WITH SANTA Pancake breakfast with Santa, kid’s holiday activities and more. Dec. 7 at 9 am. $4-$5. First Church of Nazarene, 9004 N. Country Homes Blvd. (467-8986) HOLIDAY BALL Formal holiday dance featuring music by the Desert Rose Band. Guests are asked to bring an appetizer to share and a food bank donation. Dec. 7 from 7-10 pm. $5-$9. Ponderay Events Center, 401 Bonner Mall Way, Ponderay. usadancesandpoint.org (208-699-0421) MOBIUS KIDS SANTA BREAKFAST The annual event benefits Mobius Kids Children’s Museum and includes breakfast and festive activities, including a visit with Santa. Dec. 7 from 8:30-10:30 am. $25. Davenport Hotel, 10 S. Post St. mobiusspokane.org (321-7121) WINTER FAIRE FOR FAMILIES Children’s crafts and activities, kids’ gift store, food, silent auction, craft fair and more. Dec. 7 from 11 am-3 pm. Free admission. Windsong School, 4225 W. Freemont Rd. spokanewindsongschool.org (326-6638) PAWS & CLAUS Bring your pet to sit on Santa’s lap and tell him he or she hasn’t been too naughty this year. Dec. 8 and 15 from 6-7 pm. River Park Square, 808 W. Main Ave. (363-0304) TEDDY BEAR TEAS The library hosts its annual celebration of the American icon, encouraging participants to bring their favorite stuffed friend. See the library’s website for other branch’s events. Dec. 10 and 13 at 10 am. Free. Downtown Library, 906 W. Main Ave. spokanelibrary.org (444-5300) GAISER CONSERVATORY HOLIDAY LIGHTS The Friends of Manito’s annual holiday lights display showcases the Gaiser Conservatory’s plant collection decked out in thousands of lights. Best viewing after 4 pm. Dec. 13-22, 8 am-7:30 pm. Free, donations accepted. Manito Park, 1800 S. Grand Blvd. friendsofmanito.org (456-8038) NORTH POLE EXPRESS Train rides through Riverfront Park and a stop at the North Pole to visit Santa, with hot chocolate, cookies, crafts, and more. Reservations recommended. Children ages 5 or younger free with adult. $12. Dec. 14-15 and Dec. 21-22. Departs at noon, 2 pm and 4 pm (also at 6 pm, Sat only). Riverfront Park, 507 N. How- VODKA | GIN | WHISKEY | BOURBON 509-489-2112 | DRYFLYDISTILLING.COM 1003 E. TRENT # 200 | SPOKANE, WA 99202 HOLIDAY GUIDE 2013 INLANDER 27 The Inlander is hosting Elf on Dec. 18 at the Bing as a fundraiser for Catholic Charities . Holiday Treats FAIR TRADE FESTIVAL Handmade artisan items and more. Dec. 8 at 8 am. Free. First Presbyterian Church, 521 Lakeside Ave., CdA. cdadowntownchurch.org (208-667-8446) KENDALL YARDS HOLIDAY BAZAAR Holiday gift bazaar featuring 20+ local vendors of food, artwork, handmade items and more, also includes photos with Santa. Dec. 14 from 10 am-3 pm. Free admission. The Nest at Kendall Yards, 1335 W. Summit Parkway. facebook.com/kendallyards (474-1316) FOOD & DRINK BLACK FRIDAY WINE SPECIAL Class on value wines to stock up on for the holiday season. Nov. 29 at 7 pm. $20, reservations required. Rocket Market, 726 E. 43rd Ave. rocketmarket.com (343-2253) RED SATURDAY Instead of Black Friday, celebrate “Red Saturday”, a cigar bar, reservations required. Jacklin Arts & Cultural Center, 405 N. William St., Post Falls. jacklincenter.org (208457-8950) DAVENPORT HOTEL HOLIDAY LUNCHEON Enjoy lunch at the historic hotel while it’s elegantly decorated for the holidays. Dec. 6 from 11:30-1 pm. $25. Davenport Hotel, 28 INLANDER HOLIDAY GUIDE 2013 10 S. Post St. thedavenporthotelcollection. com (789-6819) CHRISTMAS LUNCHEON “Peace on Earth” holiday luncheon fundraiser featuring live entertainment and more. Dec. 6 at 11 am. $15-$18. Corbin Senior Center, 827 W. Cleveland Ave. corbinseniorcenter.org (3271584) SANTACON This event currently takes place in 300 other cities, and returns to Spokane for the second annual pub crawl. Starts at the Red Lion Barbecue. Ages 21+, participants are encouraged to dress as Santa or Mrs. Claus. Dec. 14, at 4 pm. Free entry. Downtown Spokane. santacon.info (206-310-4164) INLAND NW VEGAN SOCIETY POTLUCK Bring a plant-based (no animal products or honey) dish to share along with an ingredient list and the recipe. Dinner is followed by a guest speaker. Dec. 15 at 5 pm. Donations accepted. Community Building, 35 W. Main Ave. (315-2852) WINTER ALES TASTING Sample winter beers to celebrate the Winter Solstice. Dec. 21. $5. Huckleberry’s Natural Market, 926 S. Monroe St. huckleberrysnaturalmarket.com (624-1349) THE DAVENPORT’S CHRISTMAS DINNER Favorite and traditional holiday dishes from the hotel’s kitchen are served a la carte in the Palm Court Grill and the Safari Room. Reservations suggested. Dec. 25 from 12-8 pm. Prices vary. Davenport Hotel, 10 S. Post St. davenporthotelcollection.com (455-8888) MUSIC THE SHOOK TWINS Second annual “Home for The Holidays” concert featuring the Sandpoint natives with Anna and The Underbelly opening. Nov. 29 at 7:30 pm. $15-$18. The Pearl Theater, 7160 Ash St., Bonners Ferry. Also with Justin Lantrip and Mama Doll on Nov. 30 at 7:30 pm. $12-$15. Panida Theater, 300 N. First Ave., Sandpoint. (208-267-7327) CELTIC THUNDER World music concert. Nov. 29-30 at 7 pm. $45-$60. Northern Quest Casino, 100 N. Hayford Rd. northernquest.com (481-6700) AVÉ! HOLIDAY CONCERT Featuring music from the 16th Century to the modern day, including the premier performance of a composition by William H. Mays, of Spokane. Dec. 1 at 3 pm. Free, donations accepted. Convent of the Holy Names, 2911 W. Fort George Wright Dr. (326-9516) THE VIVACE ACCORDION ORCHESTRA Concert showcasing the versatility of the accordion and featuring accomplished local performers. Dec. 1 at 3 pm. $10. Bing Crosby Theater, 901 W. Sprague Ave. bingcrosbytheater.com (227-7404) SFCC ORCHESTRA HOLIDAY CONCERT Featuring music by Brahms, Bach and Beethoven, directed by Shelley Rotz. Dec. 2 at 7 pm. $2-$5. Spokane Falls Community College, 3410 W. Fort George Wright Dr. spokanefalls.edu ) COEUR D’ALENE SYMPHONY “Christmas at the Kroc” holiday concert. Dec. 4 and 6 at 7:30 pm. $8-$20. Kroc Center, 1765 W. Golf Course Rd. cdasymphony.org (208765-3833) SFCC JAZZ NIGHT HOLIDAY CONCERT Directed by Kevin Woods and Danny McCollim, featuring a holiday-themed program. Dec. 4 at 7 pm. $2-$5. Spokane Falls Community College, 3410 W. Fort George Wright Dr. spokanefalls.edu (533-3720) EWU SYMPHONY ORCHESTRA Holiday concert also featuring the EWU Wind Ensemble. Dec. 5 at 5 pm. $3-$5. Eastern Washington University, Showalter Hall Auditorium, 526 Fifth St. ewu.edu/music (359-7078) THE JUBILEE CHRISTMAS TOUR Southern-style gospel Christmas concert featuring The Booth Brothers, Greater Vision and Legacy Five. Dec. 5 at 7 pm. Lake City Community Church, 6000 N. Ramsey Rd., CdA. (208-676-0632) “CRACKED PEPPER” Pepper, an awardwinning barbershop quartet, presents its sixth annual Christmas show “A Fractured Fairytale,” with guest quartets Amore, QTopia and In Harmony. Dec. 6 at 7:30 pm and Dec. 7 at 3 pm. $5-$25. Holy Names Music Center, 3910 W. Custer Dr. pepperquartet.com (953-1231) THE HOT CLUB OF SAN FRANCISCO “Cool Yule” gypsy-jazz concert. Dec. 6 at 7:30 pm $10-$20. Jones Theatre at Daggy Hall, Washington State University, Pullman Campus. (335-8522) SHAWN COLVIN Concert by the singersongwriter. Dec. 8 at 7:30 pm. $45. Allages. Bing Crosby Theater, 901 W. Sprague Ave. (227-7638) “ANNUNCIATA E MYSTERIUM” Spokane Choral Artists’ holiday program, featuring music composed by Poulenc, Gabrielli, Biebl, Lauridsen and more. Dec. 7 at 7:30 pm. $12-$18. Salem Lutheran Church, 1428 W. Broadway Ave. Also on Dec. 8 at 3 pm. $12-$18. First Presbyterian Church, 521 Lakeside Ave., CdA. spokanechoralartists. com (251-6296) BACH FESTIVAL WINTER CLASSICS Concert featuring music by Bach, Britten, Chopin, Debussy and Franck, featuring Zuill Bailey on cello and Natasha Paremski on piano. Dec. 7 at 3 pm. $15-$30. Barrister Winery, 1213 W. Railroad Ave. barristerwin- ery.com (924-1132) DE COLORES HANDBELL CHOIR Concert by the Spokane-based handbell choir. Dec. 7 at 6 pm. Free, donations accepted. Cutter Theatre, 302 Park St., Metaline Falls. cuttertheatre.com (509-446-4108) SPOKANE JAZZ ORCHESTRA The orchestra performs its annual holidaythemed concert, “A Big Band Christmas,” featuring guest vocalists Nicole Lewis and Jon Brownell. Dec. 7 at 8 pm. $20-$26. Bing Crosby Theater, 901 W. Sprague Ave. spokanejazz.org (4351007) HOLIDAY ON PIPES Concert by local organist Kenneth Fuller, featuring traditional Christmas Carols. Dec. 8 at 6 pm. Free, donations accepted. First Church of Nazarene, 9004 N. Country Homes Blvd. (467-8986) GONZAGA SYMPHONY ORCHESTRA Conducted by Kevin Hekmatpanah, featuring Tchaikovsky’s Piano Concerto, with pianist Natasha Paremski as guest soloist. Dec. 9 at 7:30 pm. $10-$13. Martin Woldson Theater at The Fox, 1001 W. Sprague. (624-1200) OAK RIDGE BOYS Country/gospel concert and Christmas show. Dec. 9 at 7:30 pm. $42-$52. INB Performing Arts Center, 334 W. Spokane Falls Blvd. (279-7000) SINGING NUNS CHRISTMAS CONCERT The Spokane-based choir presents its annual Christmas concert, joined by the Strolling Strings of East Valley High School. Dec. 11-12 at 2 pm and 7:30 pm, both days. $10-$20. Bing Crosby Theater, 901 W. Sprague Ave. (227-7404) TEDESCHI TRUCKS BAND Blues/rock concert. Dec. 11 at 7:30 pm. $30-$62. The Fox, 1001 W. Sprague. foxtheaterspokane.com (624-1200) MEAD HIGH SCHOOL JAZZ CHOIR “Holiday Harmony” concert featuring the award winning high school choir. Dec. 12 at 7 pm. Free. North Spokane Library, 44 E. Hawthorne Rd. scld.org (893-8350) TRADITIONS OF CHRISTMAS Musicalstyle. $20-$33. Kroc Center, 1765 W. Golf Course Rd., CdA. traditionsofchristmasnw.com (208-391-2867) I’LL BE HOME FOR CHRISTMAS Holiday musical-drama inspired by the nostalgia of WWII, performed in a dessert-theater format, featuring the church’s voice choir. Dec. 13 at 7 pm, Dec. 14 at 2 pm and 7 pm. $5. First Church of Nazarene, 9004 N. Country Homes Blvd. (467-8986) SOUNDS OF CHRISTMAS Concert featuring the NIC Wind Symphony, Cardinal Chorale and Chamber Singers and Cardinal Vocal Jazz. Dec. 14 at 7:30 pm and Dec. 15 at 2 pm. North Idaho College, 1000 W. Garden Ave. nic.edu (208-665-2759) SPIRIT OF SPOKANE CHORUS “The Secret of Christmas” concert, featuring guest soloists, ensembles and instrumentalists. Event also includes a bake sale and food drive, guests are asked to donate a food item. Dec. 14 at 7 pm. $10. Opportunity Presbyterian, 202 N. Pines Rd. spiritofspokanechorus.org (208659-7346) WHITWORTH CHRISTMAS FESTIVAL The annual concert features 120+ students performing choral works, readings and traditional carols. Dec. 14 at 8 pm, Dec. 15 at 3 pm. $15-$18. Martin Woldson Theater at The Fox, 1001 W. Sprague. fox- theaterspokane.com (624-1200) CLARION BRASS “This is What Christmas Sounds Like” holiday concert. Dec. 16 at 7:30 pm. $16-$18. Kroc Center, 1765 W. Golf Course Rd. (208-667-1865) Also on Dec. 17 and 18 at 7:30 pm. $18. Cathedral of St. John the Evangelist, 127 E. 12th Ave. (325-7328) HARMONY FOR THE HOLIDAYS Holiday music and light opera featuring acclaimed vocalists Jonathan Mancheni and Isabella Ivy. Proceeds benefit Catholic Charities Foundation and Second Harvest Food Bank. Dec. 20 at 8 pm. $25. Bing Crosby Theater, 901 W. Sprague Ave. bingcrosbytheater.com (227-7404) CHRISTMAS AT THE BING Holiday concert hosted by Douglas Webster, joined by Krista Curry, Jenny Shotwell, Chelsea LeValley and locals Krista Kubicek and Max Mendez. Dec. 21 at 7:30 pm. $18-$27. Bing Crosby Theater, 901 W. Sprague Ave. bingcrosbytheater.com (227-7404) SPOKANE SYMPHONY SuperPops Series: “Holiday Pops Celebration” feat. conductor Morihiko Nakahara, the Symphony Chorale and Spokane Area Children’s Choirs. Dec. 21 at 8 pm, Dec. 22 at 2 pm. $26-$62. Martin Woldson Theater at The Fox, 1001 W. Sprague. (624-1200) SOUND OF MUSIC SING-A-LONG Screening of the classic holiday film with subtitles for the audience to sing along, as well as bags of props and a costume contest. Dec. 22 at 5 pm. $25. INB Performing Arts Center, 334 W. Spokane Falls Blvd. inbpac.com (279-7000) SPOKANE SYMPHONY Annual New Year’s Eve performance of Beethoven’s Ninth Symphony featuring the Spokane Symphony Chorale. Dec. 31 at 7:30 pm. $23-$28. The Fox, 1001 W. Sprague. spokanesymphony.org (624-1200) PUTTIN’ ON THE RITZ The Spokane Symphony’s formal New Year’s Eve party features live music with the Master Class Jazz Orchestra and a champagne toast at midnight. All proceeds benefit the Symphony. Dec. 31 at 9 pm. $65-$75. Davenport Hotel, 10 S. Post St. spokanesymphonyassoc.org (624-1200) PERFORMANCE NUTCRACKER MINI PERFORMANCES Local children perform scenes from the classic holiday tale. Nov. 29-Dec. 1 from 1-3 pm. Performances held on first level, outside Nordstrom. Free. River Park Square, 808 W. Main. riverparksquare. com (624-3945) TOY SHELF A family-oriented holiday show about toys in a workshop. Nov. 30 at 2 pm and 7 pm. $12. Bing Crosby Theater, 901 W. Sprague Ave. spokaneelitedance.com (509-227-7404) THE NUTCRACKER Ballet performed by the State Street Ballet, and musical score by the Spokane Symphony. Dec. 5-8. $25-$75. Martin Woldson Theater at The Fox, 1001 W. Sprague. (624-1200) POPVICH COMEDY PET THEATER Circus-style show featuring tricks and feats performed by trainer/performer Gregory Popovich’s 10 dogs and 15 cats, all adopted from shelters. Dec. 5-6 at 7:30 pm, Dec. 7 at 11 am. $9-$22. Bing Crosby Theater, 901 W. Sprague Ave. bingcrosbytheater.com (509-227-7404) A CELTIC CHRISTMAS Holiday-themed dinner theater concert. Dec. 6-7, Dec. 10, 12 and Dec. 13-14 at 6:30 pm. $25-$35. Circle Moon Theater, Hwy 211 off Hwy 2. (208-448-1294) 2013 nd - 23rd 2 r e b Decem am – 3 pm Monday - Saturday 9 60% SAVINGS great deals on shoes, apparel, outerwear up to and golf equipment 10 rounds of golf for $700 ($950 value) for every $300 spent receive a round of golf for 2014 season ($95 value. Merchandise purchases only.) A SP la•la•la•la December 12th – 24th Celebrate 12 DAYS OF SPA this Holiday Season Special offers and discounts on your favorite treatments. 1 800 523-2464 | CDACASINO.COM | /CDACASINORESORT HOLIDAY GUIDE 2013 INLANDER 29 The family-friendly First Night Spokane features more Holiday Treats JOY TO THE WORLD Holiday-themed performance by Festival Dance & Performing Arts, also featuring local musicians. Dec. 7 at 7 pm. $10-$16. University of Idaho Administration Bldg, 851 Campus Dr., Moscow. festivaldance.org POPVICH COMEDY PET THEATER Circusstyle stage show featuring tricks by trained dogs and cats, led by trainer and performer Gregory Popovich. Dec. 8 at 3 pm. Panida Theater, 300 N. First Ave. panida.org (208263-9191) ALLEGRO DANCE CHRISTMAS RECITAL “Twas the Night Before Christmas” annual holiday recital. Dec. 14 at 7 pm. Panida Theater, 300 N. First Ave. panida.org (208263-9191) MILLWOOD BALLET: THE NUTCRACKER Children of the ballet school present their than 150 performers. production of the classic holiday story. Dec. 14 at 7 pm and Dec. 15 at 2 pm. $12. Spokane Community College, 1810 N. Greene. companyballetspokane.com (869-5573) EUGENE BALLET’S NUTCRACKER Performance of the classic holiday ballet. Dec. 16 at 7 pm. $10-$25. Panida Theater, 300 N. First Ave., Sandpoint. (208-263-9191). (455-7529) THE CHRISTMAS SCHOONER Holiday family musical. Through Dec. 22, Thu-Sat at 7:30 pm, Sun at 2 pm. $22-$30. Spokane Civic Theatre, 1020 N. Howard St. spokanecivictheatre.com (325-2507) A CHRISTMAS CABARET An evening of music, stories and laughter, featuring Ellen Travolta joined by Mark Cotter and Jack Bannon. Nov. 29-Dec. 21, Thurs-Sat at 7:30 pm, Sun at 5 pm. $20-$25. The Coeur d’Alene Resort, 115 S. 2nd Ave. achristmascabaret.com (208-435-4000) THE CHRISTMAS TOY SHOP Holidaythemed play. Through Dec. 15, show times vary. $10-$12. Spokane Children’s Theatre, 2727 N. Madelia. spokanechildrenstheatre. org (325-4886) THOROUGHLY MODERN MILLIE Musical performed by the Lewis & Clark High School Drama Dept. Dec. 5-14, Thurs-Sat at 7 pm. $10. Lewis and Clark High School, 521 W. Fourth. tigerdrama.com (354-7000) A CHRISTMAS CAROL Performed by StageWest Community Theatre in the style of a live radio broadcast. Dec. 6-15, Fri-Sat at 7 pm, Dec. 8 at 3 pm, holiday brunch matinee ($25) on Dec. 15 at 2 pm. $10-$12. Emmanuel Lutheran Church, 639 Elm St. (768-2150) A DICKENS OF A DINNER Originally-adapted production of “A Christmas Carol” with a Victorian-style dinner. Dec. 6-7 and Dec. 13-14 at 6 pm. Reservations encouraged as seating is limited. $40-$45. The Lion’s Share, 1627 N. Atlantic St. lionaround.org (327-1113) THE SANTALAND DIARIES Holidaythemed, one-man comedy show, written by David Sedaris. (This show replaces the “Christmas Belles.”) Dec. 6-22, Thurs-Sat at 7:30 pm, Sun at 2 pm. $11-$17. Lake City Playhouse, 1320 E. Garden Ave., CdA. lake- cityplayhouse.org (208-667-1323) TINY TIM’S CHRISTMAS Holiday-themed comedy/mystery, performed as a sequel to “A Christmas Carol.” Dec. 6-15, Thurs-Sat at 7:30 pm (except Sat, Dec. 7). Sat-Sun at 2 pm. $12. Liberty Lake Community Theatre, 22910 E. Appleway Ave., Ste. 1. libertylaketheatre.com (342-2055) THE BEST CHRISTMAS PAGEANT EVER Holiday musical performed by the JACC’s Theatre Troupe. Dec. 12-15 at 7:30 pm, Dec. 15 and 22 at 2 pm. $15-$20. The JACC, 405 N. William St., Post Falls. (208-457-8950) MILLION DOLLAR QUARTET Broadway musical about rock icons Elvis Presley, Johnny Cash, Jerry Lee Lewis and Carl Perkins. Dec. 12-15, show times vary. $33-$73. INB Performing Arts Center, 334 W. Spokane Falls Blvd. (279-7000) THE BEST CHRISTMAS PAGEANT EVER Performance of the holiday musical. Dec. 14-22, Fri-Sat at 7 pm, Sun at 3 pm. Pend Oreille Playhouse, 240 N. Union Ave. pendoreilleplayers.org (447-9900) THE LION, THE WITCH & THE WARDROBE Stage adaptation of the classic children’s fantasy story by C.S. Lewis. Dec. 13-22, FriSat at 7 pm, Sat at 4 pm, Sun at 2 pm. $8$10. Theater Arts for Children, 2114 N. Pines, Ste. 3S. (892-5413) THE BEST CHRISTMAS PAGEANT EVER Performed by students ages 8-17 in the Civic’s Academy, for the theater’s sixth annual scholarship benefit performance. Dec. 14 at 1 pm and 4 pm, Dec. 15 at 7 pm. $5-$15. Spokane Civic Theatre, 1020 N. Howard St. (325-2507) AWAY IN A BASEMENT A holiday-themed musical comedy starring the lovable Church Basement Ladies. Dec. 19-Jan. 5, Wed-Fri at DECEMBER 12 – 23 Kroc Center 1765 W. Golf Course Rd, CdA Produced by Laura Little Productions, Courtesy of CCT 2ND Tickets can be purchased at: 1323 Sherman (Corner of 14th & Sherman, CdA) 208-391-2867 30 INLANDER HOLIDAY GUIDE 2013 7:30 pm, Sun at 2 pm. Select Thurs (Dec. 26, Jan. 2) and Sat (Dec. 21, 28, Jan. 4) matinees at 2 pm. Christmas Eve show Dec. 24 at 2 pm. $12-$28. Interplayers Theatre, 174 S. Howard St. interplayerstheatre.org (455-7529) VISUAL ARTS HOME FOR THE HOLIDAYS Artwork exhibited by resident and invited artists, with all pieces for sale and new work added throughout the exhibition. Through Dec. 29, Thurs-Sun from 10 am-6 pm. Dahmen Barn, 419 N. Park Way, Uniontown. artisanbarn.org (229-3414) HANDMADE ORNAMENT SHOW The annual show features handmade tree ornaments by local artists. Nov. 29-Dec. 1, FriSat from 10 am-6 pm, Sun from 10 am-3 pm. Tinman Gallery, 811 W. Garland Ave. tinmanartworks.com (325-1500) NORTHWEST TREASURES Handmade ornaments in copper, felt, glass, metal and more by local and regional artists. Through Dec. 31. Free. Gallery Northwest, 217 E. Sherman Ave., CdA. thegallerynorthwest. com (208-667-5700) 15TH ANNUAL SMALL ARTWORKS INVITATIONAL The annual exhibition features 39 local/regional artists, exhibiting more than 200 new works. Opening reception Dec. 6 from 5-8 pm, show runs through Dec. 31. Free admission. Art Spirit Gallery, 415 Sherman Ave., CdA. theartspiritgallery. com (208-765-6006) DECEMBER FIRST FRIDAY Local galleries and businesses display new artwork for the month. Dec. 6, most artist receptions from 5-8 pm, locations throughout downtown Spokane and beyond. See Inlander.com/ FirstFriday for complete event listings and an interactive map. Free. spokanearts.org HOLIDAY GIFT GALA The 8th annual event features work by 38 local and regional artists for sale, as well as custom gift baskets and more. Dec. 7 from 10 am-4 pm. Expanded holiday hours, open daily from 10 am-6 pm through Dec. 23. Free admission. Dahmen Barn, 419 N. Park Way., Uniontown. (229-3414) WINTER WONDERLAND The gallery hosts its annual holiday art exhibition reception Dec. 7 from 5-8 pm. Art Works Gallery, 214 N. First Ave., Sandpoint. sandpointartworks.com (208-263-2642) HOLIDAY OPEN HOUSE Four-day holiday event, featuring a pottery sale, expanded gift shop, book signings, kids’ activities and more. Dec. 12-15 from 10 am-6 pm. Free admission. Dahmen Barn, 419 N. Park Way. artisanbarn.org (229-3414) ARTWALK Monthly art showcase throughout downtown galleries and businesses. Second Friday of the month (Dec. 13) from 5-8 pm. Free. Downtown Coeur d’Alene. artsincda.org (208-292-1629) ETC. WINTER BLESSING Native American performances, food and more. Nov. 30 at 5 pm. Coeur d’Alene Casino, 37914 S Hwy 95. cdacasino.com (800-523-2467) ARGENTINE TANGO LESSONS No experience or partner necessary. Mondays from 7-9 pm. $5. Spokane Tango, 2117 E. 37th Ave. spokanetango.com (688-4587) COMPASS CLUB CHRISTMAS LUNCHEON Catered luncheon featuring entertainment by pianist Diane Copeland. Reservations requested. Dec. 3 at 11 am. $20. Manito Country Club, 5303 S. Hatch Rd. (4557789) RAINMAKER’S PAJAMA PARTY Client appreciation part featuring a performance by dueling piano performers from NYC, “Michael and Amy.” Dec. 6 at 6 pm. $75 for non-clients. Lincoln Center, 1316 N. Lincoln St. therainlab.com/ (509-327-8000) THE TELLING OF WINTER TALES A literary reading featuring Jonathan Johnson and Shawn Vestal. Dec. 7 at 3 pm. Free. Sandpoint Library, 1407 Cedar St. losthorsepress.org (208-255-4410) HOLIDAY VINTAGE FASHION TEA Holiday-themed tea event featuring a live fashion show showing 100 years of Spokane’s vintage fashion history. Dec. 7 at 1 pm. $20. Woman’s Club of Spokane, 1428 W. 9th Ave. (466-6677) JOHN STOCKTON AUTOBIOGRAPHY SIGNING The former Utah Jazz player and Gonzaga alum will sign copies of his autobiography, “Assisted.” (Note: This event was originally schedule for Nov. 9 but has been postponed until Dec. 7) Dec. 8 at noon. Auntie’s Bookstore, 402 W. Main Ave. auntiesbooks.com (838-0206) AUTHOR MATTHEW GONDER The author signs copies of his two memoirs, “Christmas On The Move Out West” and the sequel “Music On The Move Out West.” Dec. 10 at 7 pm. Free. Auntie’s Bookstore, 402 W. Main Ave. auntiesbooks.com (8380206)! Wa ch professtio gingerbr nal e hous ad being beus ilt VOTE UR FOR YROITE! FAVO ets $ 1 k o V te Ticfor $ 5 6 r o 2012 Gingerbread Winner ‘Kids of all ages’ can make their own mini-gingerbread house GINGER Products sales & prices vary BREA$D Pictures KITS 7 $5 HOLIDAY GUIDE 2013 INLANDER 31 32 INLANDER HOLIDAY GUIDE 2013 The Real Thanksgiving It wasn’t all turkey during the original holiday feast BY ARI LEVAUX T. n SEE SOBAHEG RECIPE ON NEXT PAGE >> NOVEMBER 28, 2013 INLANDER 29 $17.Salad9Entrée5 Dessert FOOD | HOLIDAYS NEW 3-Course Dinner Menu 3-6 pm daily NEW MENU SELECTIONS SALAD Caesar or Garden ENTRÉE Braised Short Ribs • Coconut Prawns • Herb Grilled Wild Salmon Creole Chicken Pot Pie • Pan Roasted Chicken Penne Pasta DESSERT Signature Davenport Cheese Cake. Herb Grilled Wild Salmon bouillon. If using it, add sunflower seed flour and stir it in. 509 789 6848 • palmcourtgrill.com Historic Davenport Hotel 10 S. Post St., Downtown Spokane 30 INLANDER NOVEMBER 28, 2013 It’s a simple yet texturally diverse pot of stew, full of complementary flavors. If you want to take it even further, a dollop of cranberry sauce adds a refreshing zing — even if there weren’t cranberries at the original Thanksgiving. n FOOD | COOKIES Alberta Bake Shop owner Robie Calcaterra shows off some mint chocolate chip cupcakes. SARAH WURTZ PHOTO Baking The Dream Shadle Park gets a dose of snickerdoodles and fudge bars BY JO MILLER A. FOOD | OPENING The Real Deal Three friends bring their Thai food know-how to a new Gonzaga-area restaurant BY JO MILLER T. n Alberta Bake Shop • 5511 N. Alberta • Open Tue-Fri, 9 am-6 pm; Sat, 9 am–3 pm • facebook.com/AlbertaBakeShop • 241-3361. n Our Thai House • 1415 N. Hamilton • Open Mon-Sun 11 am-9 pm • 487-4237 NOVEMBER 28, 2013 INLANDER 31 R E D N O W EVER FOOD | UPDATE A T N A S E R WHE ? S A E D I S I H GETS ... ecret s s i h w o n k We Bartender Levi Alford pours a beer at Post Street Ale House. YOUNG KWAK PHOTO POST STREET ALE HOUSE 1 N. POST | 789-6900 Y IDEAS T F I G W E N ER HAS D N A L N I E OUR LIST H Y T N O E N O Y FOR EVER nds 12/12 1 • On Sta GIFT GUIDE nds 12/19 a t S n O • 2 IDE GIFT GU s, t year’s pick ! s la t u o k c e Ch Inlander.com on the new To Advertise in our holiday issues: 509.325.0634 ex 216 | Sales@Inlander.com R ighting WRongs • R ebuilding l ives James R. Sweetser ou. — MIKE BOOKEY Fit a degree into your life. CCSonline.spokane.edu Winter quarter starts January 6. Enroll today! ATTORNEY AT L AW | since 1984 Former Elected Spokane Prosecutor seRious PeRsonAl inJuRY Call: 509-328-0678 sweetserlawoffice.com 1020 N Washington, Spokane, WA 99201 32 INLANDER NOVEMBER 28, 2013 Spokane Community College Spokane Falls Community College Community Colleges of Spokane provides equal opportunity in education and employment. 13-0325 S FOOD | SAMPLER HAPPY HOUR BAKERY CELEBRATIONS BAKERY 713 W. Garland | 327-3471 Whipped cream atop a cupcake? Sure! Celebrations reimagines cupcakes with flavors, frostings and toppings that feel like a party in your mouth. Try the Banana Split, a fragrant banana cupcake filled with strawberries and topped with a swirl of whipped cream, chocolate syrup and, of course, a cherry. LOVE @ FIRST BITE DESSERTS 11305 E. Sprague | 891-2501 This spot has something on its menu called the Chocolate Explosion, which was actually born from a batch of cupcakes gone wrong. Composed of chocolate cake, toasted chocolate cake bits and a whole lotta ganache, this creation has gained a devoted following and can be enjoyed every Thursday. All cupcakes are $2.75 and they’re enormous (some would even say the biggest in town). Wash them down with a tall cup of black coffee, free depending on which day you visit, and you’re good to go. PIE HUT 502 Church St. | Sandpoint 208-265-2208 This shop is tiny but mighty, with 35 Mon-Thurs 3-6 & 9-Close Fri 3-6 | Sat 11-5 | Sun All Day 1 Bottle Beer 2 Domestic Pints $ 4 Micro Pints & House Wines $ 5 Jagermeister & Fireball $ 5 Appetizers $ 50 to 40 pie flavors to choose from on any given day. Sour cream lemon is the best seller, and the Red Delicious is made not with apples but red berries — and it’s delicious. Soups and sandwiches add justification, but it’s all about the pies. SWEET DREAMS BAKERY 3131 N. Division | 747-6900 The bakery’s raison d’etre is wedding cakes, but nuptials aren’t the only reason to stop by: Deep, resonant chocolate frosting tops delicate chocolate cupcakes. Macaroons have a toasty sweet outer edge and a light, fluffy interior. The coconut frosting shot (yes, shot glasses full of frosting are available) contains shreds of coconut saturated in the creamy flavor of coconut milk. $ 21 West Main Ave 509-473-9455 SaranacPublicHouse.com WHITE BOX PIES 28 E. Sharp | 927-8850 This eatery smells of fresh baked bread and pie crust. If that doesn’t tempt you to order a slice, we don’t know what will. Most everything at White Box is made on-site in a convenient location on your way through Spokane past Gonzaga. A great assortment of gluten-free options are available. BLACK FRIDAY FOOTBALL SPECIALS ALL WEEKEND $8 MILLER LITE & COORS LITE PITCHERS $12 LARGE 2 TOPPING PIZZA $2 OFF ALL SUBS Voted Best New Sports Bar & Restaurant When you see this icon you’ll know you’re supporting a local business. All Ages +ğğŎį ÀğÃĤıßPĥ ğPæıÃæµį ÀğÃĤıßPĥ GÃĤÀĥį,íŊįIJ įįįįįįįįįįįįįį ďqíà ÕÃĤĥêā bÕÃĤq à NOVEMBER 28, 2013 INLANDER 33 Chilled to Perfection Disney shows it gets what it’s like to be a young girl with Frozen BY MARYANN JOHANSON O h my goddess. Where did Frozen come from? It Fast-forward to the present, as Elsa comes of age didn’t come from Hans Christian Andersen; this and is about to be crowned queen (their parents died in bears little resemblance to supposed inspiration a shipwreck). Anna has spent years not knowing why The Snow Queen. It sprang from the grand Disney tradition her beloved sister has shut her out; Elsa is desperately of full-on, Broadway-style animated musicals. But unlike worried that her subjects will see her as a monster. The 2009’s throwback The Princess and the Frog, which felt like recipe for disaster is in place. nothing more than a tired retread, Frozen is — we can The villains here? Unintended consequences, good hope, anyway — the start of a new era for the wonderful intentions, and the pressures of conformity. When Elsa little subgenre Disney has claimed for itself. finally stops denying her Arctikinesis, she celebrates by Frozen is a princess story; Disney creating a wondrous mountain ice castle FROZEN is doubling down on the princesses — for herself, belting out a glorious anthem Rated PG there’s two of ’em here. But Disney is to female power. Not since Howard Directed by Chris Buck and Jennifer Lee Ashman’s remarkably astute lyrics for also doubling down on the hints of nascent feminism Brave hinted at, the sort of Starring the voices of Kristen Bell, Josh Beauty and the Beast and The Little Mermaid Gad, Idina Menzel bare-bones feminism which accepts that — which are far more about a girl’s girls and women might possibly want longings to be her own person than they more out of life than to get married. The princesses are are about finding romance — has there been a Disney sisters — the elder Elsa (the voice of Idina Menzel) and song like “Let It Go,” as Elsa tosses away “the good girl” the younger Anna (the voice of Kristen Bell) — and this is she “always [had] to be” and stops mostly the story of their troubled relationship. Which has believing that “conceal, don’t nothing to do with jealously that arises over them both feel” is a healthy way to live. liking the same prince. I had chills listening When Elsa and Anna are small children, there’s an to this: someone gets accident: Elsa’s paranormal ability to make things cold it. (The lyrics are by — a sort of Arctikinesis — knocks out Anna as they’re Robert Lopez and playing in supernaturally produced snow, threatening Kristen Anderson-Lothe little girl’s life. As part of the magical cure, Anna’s pez; they wrote the memory of Elsa’s ability is taken away — it’s probably a songs for Avenue Q.) good idea that they don’t play like this again — and their Writers and direcparents, the king and queen of Arendelle, decide that Elsa tors Chris Buck and should remain locked away lest she hurt anyone else; terJennifer Lee, with a rified of doing so, Elsa readily agrees. screenplay assist from 34 INLANDER NOVEMBER 28, 2013. FILM | SHORTS OTHER OPENING FILMS THE BOOK THIEF There’s nothing Hollywood likes to tell more than a Holocaust story — especially in hopes of winning Oscars. So when the Markus Zusak bestseller The Book Thief came on the scene in 2005, it was only a matter of time before a movie studio gobbled it up. Told from the perspective of the young girl Liesel (Sophie Nélisse) who goes to live with a foster family during WWII (Emily Watson, Geoffrey Rush), the film depicts one family’s fight to stand up against the Nazis. (LJ) Rated PG-13 BLACK NATIVITY For those in need of a little Jesus at the multiplexes this holiday season, this film adaption of Langston Hughes’ stage production is here to please. Plus, getting to see Jennifer Hudson sing on the big screen again could be worth the price of admission. When a single-mother (Hudson) is laid off from her job, she sends her son (Jacob Latimore) to live with her estranged parents (Angela Bassett, Forest Whitaker) in Harlem. Much singing and messy plot points lead up to a forgiveness-filled, feel-good finale. (L HOMEFRONT Homefront, despite the title, is not a heartwarming Lifetime melodrama. It’s a wildly ridiculous action flick in which Jason Statham plays a former DEA agent now living in Middle of Nowhere, Louisiana, alone with his preteen daughter Maddy (Izabela Vidovic) since his wife died.), the latter of whom just happens to be a meth dealer. KILL YOUR DARLINGS If you needed evidence that Daniel Radcliffe could survive a decade as Harry Potter should really check the actor as legendary poet Allen Ginsberg in this film about the early days of the beat movement. Here, we see Ginsberg, Jack Kerouac (Jack Huston) and William Burroughs brought together by the murder of David Kammerer by a mutual friend. It’s a seminal moment in American literature, but one most people haven’t heard of. At Magic Lantern (MB) Rated. Starring Judi Dench and Steve Coogan — who also helped write the movie with Jeff Pope — the film, based on a true story, has received festival-circuit acclaim. (KS) Rated R ABOUT TIME British, redheaded and freckled, Domhnall Gleeson knows how to be awkward, because he already looks the part. Then you add Rachel McAdams and have a dramatic romance. The story follows 21-year-old Tim who finds out he’s inherited his family’s curse: the ability to time travel. Turns out, it’s a great way to get a girlfriend. A moment becomes moments, and his gift allows him to take a little more from each one. (KS) Rated R PRESENTS figure to do much of the heavy lifting. At Magic Lantern (SR) Rated PG-13 BAD GRANDPA ...continued on next page at the BING CROSBY THEATER DECEMBER 17th, 2013 PRE SHOW: 6:30pm | SHOW STARTS: 7:00pm Bring the whole family! TICKETS $5 Suggested Donation Benefiting NOVEMBER 28, 2013 INLANDER 35 FILM FILM||SHORTS SHORTS THE MAGIC LANTERN FRI NOV 29TH - THUR DEC 5TH KILL YOUR DARLINGS (100 MIN -R) Fri/Sat: 4:00, 8:00, Sun: 1:30, 5:30, Tue-Thu: 7:15 ENOUGH SAID (96 MIN PG 13) Fri: 6:00, Sat: 2:00, 6:00, Sun: 3:30, Tue-Thu: 5:15 WADJDA (98 MIN PG) Fri/Sat: 6:30, Sun: 3:00, Tue-Thu: 5:00 DEC 5, 6 & 7 FRIENDS OF THE BING Popovich Comedy Pet Theater ALL IS LOST (106 MIN PG 13) BENEFITING Fri/Sat: 4:30, 8:30, Sun: 1:00, 5:00 Tue-Thu: 3:00, 7:00 BLUE JASMINE INEQUALITY FOR ALL (90 MIN PG) Tue-Thu: 3:30 25 W Main Ave • 509-209-2383 • All Shows $8 NOW PLAYING $2 OF EACH TICKET SALE GOES TO RESTORATION 901 W. SPRAGUE AVE | 509.227.7638 Spokane Fall. Writer/director Woody Allen presents us a modern yet familiar character study of how the haves and the havenots perceive themselves. (CS) PG-13 CAPTAIN PHILLIPS says THANKS for helping make the 18th annual festival a success MAJOR SPONSORS Platinum Level ($3000 and up) Rita G. Frey (Media, Pennsylvania) Gold Level ($1000-2999) Avista Foundation, Inland Northwest Community, Foundation, Pacific NW Inlander Silver Level ($750-999) Humanities Washington, SCC Bronze Level ($500-749) 4 Seasons Coffee, Cathy Thompson, Torn Retina Productions BUSINESS & ASSOCIATION FRIENDS Hero ($200-499) Kit Brennick-State Farm Insurance Agent, Eyes for Life – Dr. Heavin Maier , Rowley Rentals LLC (Kay Rowley) Supporter ($100-199) Brused Books (Pullman, WA), MTA Micro Technology Associates, North Division Bicycle Shop, Rick Singer Photography BAKERY & FOOD DONATIONS Albertsons, (Millwood, East 32nd, Wandermere, Indian Trail, North Nevada, Liberty Lake) Rocket Bakery, Bumblebar, Grocery Outlet (East Sprague), Fred Meyer, Rosaurs, Cole’s Orchard. FRIENDS OF THE FESTIVAL Hero ($200-499) Eric C. Johnson, Jerry LeClaire, Robin Redman, Fran Watson & Mary Rush Supporter ($100-199) Mitchell S. Frey, Peter and Janet Grossman, Janet E. Hays, Margie Heller, Sandi King-Hunt, Sharon & Steve McGrew, Ray and Marilyn Riches, Doug & Megan Walker 36 INLANDER NOVEMBER 28, 2013 THE CHRISTMAS CANDLE The year is 1890, and the village of Gladbury, deep in the English countryside, is about to witness a miracle. Every 25 years, an angel grants a wish to whomever receives and lights a special candle. The new minister, David Richmond (Hans Matheson), does not believe in such nonsense and hinders the belief in the candle by ushering in the electric age via lights in the church. As minister and candle maker clash and tragedy strikes the town, both theologies collide in this good-hearted film based off Mac Lucado’s best-selling novel. (ER) PG, as Woodroof finally begins to see past peoples’ surface. (ER) R. (ES) Rated R ENDER’S GAME Decades after Earth repelled an invasion by insect-like aliens who killed tens of millions of humans, the planet is preparing for another invasion by the “Formics” that may or may not come) think he could be the legendary-scale genius they’re looking for. (MJ) PG-13 ENOUGH SAID Eva (Julia Louis-Dreyfus), a divorcee, is facing the possibility of an empty nest, as her daughter goes off to college. As she bonds with similarly situated Albert (James Gandolfini) and the two click, it seems like the perfect romance. Eva also befriends Marianne (Catherine Keener), whose only flaw is her tendency to rag on and on about her ex-husband. When this friend’s ex-husband turns out to be her new boyfriend, Eva suddenly finds herself looking at Albert through Marianne’s eyes. (ER) Rated R FREE BIRDS As Thanksgiving approaches, so does, apparently, the turkey buddy films. When two turkeys from opposite sides of the track team up to stop the Thanksgiving slaughter, they travel back in time to the very first Thanksgiving to take turkey off the menu, permanently. What ensues is a bunch of silliness and a lot of turkey jokes, just in time for the holiday season. Starring the voices of Owen Wilson and Woody Harrelson. (ER) Rated PG GRAVITY effect crises: Will they have enough air and/or jetpack life to make it to the station alive? Director Alfonso Cuarón (Children of Men) uses crazy effects that dazzle, while also sometimes distracting from the story. (SR) Rated PG-13 INEQUALITY FOR ALL This film LAST VEGAS When Billy decides to finally tie the knot to a much younger woman, he calls out his senior friends for one last hurrah, which of course means a bachelor party in Las Vegas. This flick covers age by laughing at it. Features an all-star cast of actors including Michael Douglas, Robert De Niro, Morgan Freeman and Kevin Kline. (ER) Rated PG-13 Wadjda is a film that details beginnings. Directed and written by Haifaa Al-Mansour, the first ever Saudi Arabian woman film-maker, the feature describes the life of rebellious Wadjda (Waad Mohammed) who discovers a green bicycle in a store that she must have. Her mother, preoccupied with the fact that her husband may take on a second wife, dismisses the notion. Precocious Wadjda refuses to give up, though, and begins to earn money using her wits and entrepreneurship skills. At Magic Lantern. (ER) PG CRITICS’ SCORECARD THE NEW YORK INLANDER TIMES VARIETY (LOS ANGELES) METACRITIC.COM (OUT OF 100) 12 Years a Slave 97 Gravity 96 All is Lost 88 Frozen 79 Hunger Games 2 73 Ender’s Game 57 Thor: The Dark World 57 DON’T MISS IT WORTH $10 WATCH IT AT HOME SKIP IT FILM | REVIEW Jason Statham tries his hand at family life. Meth Labs Explode Or scan with your Smartphone Airway Heights 10117 W State Rt 2 • 509-232-0444 Times For 8/6 - 8/12 FROZEN WEEK OF NOVEMBER 29th THRU DECEMBER 5th And not surprisingly, Jason Statham kicks James Franco’s ass in Homefront $1 WEDNESDAYS BY MARYANN JOHANSON H ey! Jason Statham finally found a thing hanging out, not looking for any trouble. Trouble that works! Well, a thing that finally comes anyway: Maddy puts a bully in his place works for me. Lots of folks seem just on the school playground, enraging his methfine with the badass martial-arts machine he typihead mama (a truly scary Kate Bosworth), who cally portrays. But that’s so completely unintersics her meth-lord brother on Broker for having esting, so cold, and I was starting to wonder if he the audacity to teach his daughter how to fight, had anything else to offer. humiliating her son. He’s trying. With a decent script — not that There’s actually some almost-profound stuff this wholly qualifies — he’s got something. With here, not surprising as the screenplay is written the right costar, he can be downright warm and by Sylvester Stallone (based on a novel by Chuck charming. Weirdly and wonderLogan). Don’t laugh: As a writer, fully, it appears that costar is a Stallone is an astute observer of male HOMEFRONT kick-ass little girl. Once — in the machismo and suppressed emotion Rated R remarkable Safe— might have been Directed by Gary Fleder — hello, Rocky — and he makes us an anomaly. But now it’s twice. feel sorry for that grade-school bully, Starring Jason Statham, One more flick in which he’s James Franco, Winona Ryder who’s not getting appropriate adult teamed up with a tough 10-yearguidance at home. old girl, and it’ll officially be a But mostly, that’s not what trend — and perhaps the best thing that ever hapHomefront is about. It’s about discovering that pened to Statham as an actor. Bosworth’s brother is named Gator Bodine, Please don’t be misled. Homefront, despite played by James Franco in full-on crazy mode. the title, is not a heartwarming Lifetime meloWe realize it’s going to come down to Statham drama. It’s a wildly ridiculous action flick in vs. Franco. It does. Meth labs blow up real good. which Statham’s Phil Broker is both a former It’s all fairly ridiculous. Interpol cop and a former DEA agent now living Yet neither Stallone’s script nor Gary Fleder’s in Middle of Nowhere, Louisiana, alone with direction overplay the ridiculous stuff, and we’re his preteen daughter Maddy (Izabela Vidovic, never invited to take any of it too seriously. who is seriously awesome) since his wife died. Homefront maintains a bizarre, entertaining sense After being burned on an undercover drugs op of redneck soap-opera tragedy. With inevitably in New Orleans, Broker’s now just lying low, exploding meth labs. 4 $ 50 BEER & DINNER IN THEATER! ALL SHOWS ALL TIMES Percy Jackson & the Sea of Monsters Fri 12:30, 5:00, Sat 5:00, Sun 12:30, 5:00 Mon 5:00, Wed-Thurs 5:00 Despicable Me 2 Fri 2:50, 7:15, Sat 12:00, 7:15, Sun 2:50, 7:15, Mon 7:15, Tues 5:00, Wed-Thurs 7:15 Insidious 2 PG-13 Fri-Mon 9:20pm, Tues 9:40pm, WedThurs 9:20pm Chitty Chitty Bang Bang Tues 7:00 PG Daily (3:50) 6:15 8:35 Wed-Sun (11:00) (1:30) In 2D Daily (4:30) 6:45 9:10 Wed-Sun (11:45) (2:10) HOMEFRONT R Daily (4:45) 7:15 9:45 Wed-Sun (11:45) (2:15) THE HUNGER GAMES: CATCHING FIRE PG-13 Daily (3:15) (4:00) (5:30) 6:15 7:00 8:30 9:20 10:00 Wed-Sun (10:00) (12:15) (1:00) DELIVERY MAN PG-13 Daily (4:20) 6:50 9:15 Wed-Sun (11:40) (2:00) THOR: THE DARK WORLD PG-13 Daily (3:50) In 2D Daily 6:20 9:00 Wed-Sun (10:45) (1:20) ENDER’S GAME PG-13 Daily (3:00) Wed-Sun (10:20) (12:40) FREE BIRDS PG Daily (3:00) (5:00) Wed-Sun (10:45) (12:50) LAST VEGAS PG-13 Daily (4:20) 6:40 9:10 Wed-Sun (11:45) (2:00) BAD GRANDPA R Daily 7:15 9:35 Wandermere 12622 N Division • 509-232-7727 FROZEN PG Daily (1:30) (3:50) 6:15 8:35 Wed-Sun (11:00) In 2D Daily (12:30) (2:10) (2:50) (4:30) (5:15) 6:45 7:30 9:10 9:40 Wed-Sun (10:00) (11:45) HOMEFRONT R Daily (2:15) (4:45) 7:15 9:45 Wed-Sun (11:45) THE HUNGER GAMES: CATCHING FIRE PG-13 Daily (12:30) (1:00) (3:00) (3:30) (4:00) (5:30) 6:10 6:30 7:00 8:30 9:10 9:30 10:00 Wed-Sun (10:00) (12:00) DELIVERY MAN PG-13 Daily (2:00) (4:20) 6:50 9:15 Wed-Sun (11:40) THOR: THE DARK WORLD PG-13 Daily (1:20) 6:10 In 2D Daily (2:00) (4:30) 7:00 9:30 Wed-Sun (11:30) ENDER’S GAME PG-13 Daily (12:40) (3:00) Wed-Sun (10:20) FREE BIRDS PG Daily (12:35) (2:40) (4:40) Wed-Sun (10:30) LAST VEGAS PG-13 Daily (1:45) (4:00) 6:20 8:50 Wed-Sun (11:30) BAD GRANDPA How the Grinch Stole Christmas Benefit for Sat 2:00 Toys for Tots R Daily 9:10 CAPTAIN PHILLIPS PG-13 Daily (1:30) (4:15) 6:50 Wed-Sun (10:45) PG-13 924 W. GARLAND • 509.327.1050 GRAVITY Daily (3:50) 9:00 Wed-Sun (11:15) In 2D Daily 6:50 9:35 Showtimes in ( ) are at bargain price. Special Attraction — No Passes Showtimes Effective 11/27/13-12/5/13 NOVEMBER 28, 2013 INLANDER 37 Nov 27th - Dec 4th TUES MON SUN SAT FRI THURS WED 412 W. Sprague Ave. 509.747.2302 TRIVIA Starts @ 7pm CLOSED Check out Andy’s & Irvs FIREBALL FRIDAY $3 POWER HOUR 11PM-12AM Any drink - $ 6! MUSTACHE PARTY 9pm - Prizes for best ‘stache Man or Woman LIVE MUSIC 5-10 Cocktails & Food | NFL Football HOSPITALITY NIGHT Industry Specials All Night Long / DJ ONE MARTINI MADNESS $5 Doubles NFL FOOTBALL TWINTINI TUESDAY $5 Doubles OPEN AT 6PM ON THANKSGIVING The Gateway Bar Between Downtown & Browne’s Addition 509.747.0304 1401 W. 1ST AVE 38 INLANDER NOVEMBER 28, 2013 COU RT O F The ca Amer se for Pear ican r l Jam BY MIK o ck ban as the E BOOK EY great d THE HYPOTHESIS This is not a definitive declaration. The topic remains open to debate, but I hypothesize that it could be argued that Pearl Jam is the great American rock band. Others have come and gone, rising to the sort of prominence the Seattle quintet has reached, but those others have never sustained the sort of musical machinery and cultural relevance, and ability to continue to sustain such prowess, as we’ve seen with Pearl Jam. THE DEFINITION The great American rock band is defined as any outfit comprised of American citizens (or mostly American citizens), founded in the United States and continuing to reside in the United States, and playing music that can, at least in a general sense, be referred to as “rock music.” The word “band” implies that the group is not a solo effort flanked by rotating musicians or some sort of Guns ROC K N’ Roses bullshit, wherein the band exists essentially as a name only, its members having collectively given up any sense of operating as a unit. For the sake of this argument, “great” refers to longevity of both the band and its material, the band’s societal and cultural impact and the manner in which its reputation is catalogued in the minds of rock ‘n’ roll fans. THE COMPETITION You’ve likely realized by now that Pearl Jam’s competition for such a distinction isn’t as formidable as you initially perceived. The obvious challengers that might come to mind — the Who, the Rolling Stones, U2, Led Zeppelin and of course, the Beatles — all have been major influences on Pearl Jam, but, as you’ve likely realized now, are not American bands. Who are we left with, then? Aerosmith? They should have quit with the asteroid song. Bon Jovi? It’s a solo project now that Richie Sambora walked out on the last tour. Van Halen? A great band at least needs a steady lead singer. Other acts you might mention are now playing casinos. Pearl Jam is playing, and selling out, arenas. In terms of all-time greats, you’d have to give a serious look to the Grateful Dead, who revolutionized live rock music and whose influence looms large nearly two decades after their lead singer and guitarist died. The Allman Brothers, a form of which still remains, could be ...continued on next page NOVEMBER 28, 2013 INLANDER 39 MUSIC | ROCK HISTORY “COURT OF ROCK,” CONTINUED... up there, too. The best challenger, and one that will probably get the heaviest support, is Bruce Springsteen and the E Street Band, an act that strives to exude a certain sense of American-ness in its songwriting and presentation. THE EVIDENCE SUNDAY DEC 8TH DOORS 6:30PM SHOW 7:30PM SUNDAY JAN 12TH DOORS 6:30PM SHOW 7:30PM MONDAY JAN 13TH DOORS 6:00PM SHOW 7:00PM Sunday, Dec 1st Nov 27 - Dec 4 th LE GIRLS FEMALE IMPERSONATOR at Club Red @ 10pm OPEN THANKSGIVING 1pm-2am ALL WELCOME Dance your ASS off until 4am all weekend! KARAOKE W/ MATTY Headstrong: Unitarian Universalism and the 7th Chakra Rev. Dr. Todd Eklof, UUCS Minister Unitarian Universalist Church of Spokane 4340 W. Ft. Wright Drive 509-325-6383 Sunday Services Religious Ed & Childcare 9:15 & 11am SUN KARAOKE W/ LIVE WIRE MON KARAOKE W/ MATTY TUES at Club Red 6pm-10pm KARAOKE W/ MATTY WED SAT & FRI THURS WED th LE GIRLS at Irv’s 9pm-2am at Irv’s 8pm-2am at Irv’s 8pm-2am FEMALE IMPERSONATOR at Club Red @ 10pm 415 W. Sprague Ave. 509.624.4450 40 INLANDER NOVEMBER 28, 2013 225 E. 3rd Ave., Spokane, WA Pearl Jam’s story makes them especially deserving of this distinction. They came out of the ashes of a band whose lead singer had died and rose to almost immediate fame. Pearl Jam was shoveled on top of the grunge bandwagon, but the band was always a classic rock act, making big, technical sounds few, if any, other “grunge” bands displayed. They’ve been through other challenges along the way, including inner-band strife and the death of nine fans during a Danish festival performance. All the while, the band has existed both within and outside of the mainstream. It is hard to argue that a band whose 10th studio album debuted at the top of the charts in the U.S. and nearly a dozen other countries is not mainstream. That was their fifth album to debut at the top of the charts. (Oddly, Ten, the band’s top-selling album, never reached the top.) At the same time, Pearl Jam has always been fiercely independent, breaking away from their major label as soon as they could and waging an epic, albeit ultimately unsuccessful, battle against Ticketmaster. Surrounding Pearl Jam is this bizarre paradox: The band is simultaneously characterized as warriors of the rock ‘n’ roll scene — the only Seattle band to truly survive the explosion that hit there two decades ago — as well as ’90s hasbeens. This is odd, but Pearl Jam has almost always remained relevant. Not that album charts are the only metric of relevance, but it’s worth noting that the act Pearl Jam’s recent Lightning Bolt knocked off the top of the chart was Miley Cyrus, whose relevance — albeit a blight on music and common decency — is unquestioned. Sonically, Pearl Jam is most easily identified by Eddie Vedder’s thunderous vocals. Yet their sound has evolved continually through their lifespan, evidence of a rock ‘n’ roll act that has remained creatively adventurous at a point when they could easily, and profitably, eschew new records for greatest hits-packed stadium tours. But no matter where their style has wandered over the years, Pearl Jam has always circled back to a sound and attitude that’s definitively rock ‘n’ roll — loud, big, brazen and always a little bit pissed off. All the while, the band has remained one of the best live touring acts in the business. Their live show alone — marked by unpredictable, lengthy set lists — is reason enough for Pearl Jam to be considered “great.” And it’s worth noting that Pearl Jam does very American things outside of their music — like speaking out about injustice, helping people who need help and staying true to their own ideals. THE CONCLUSION If rock ‘n’ roll was a competition, the members of Pearl Jam would likely be the first ones to say they would rather not play. Still, at a time when earnest rock outfits are all but extinct, there is value in having this discussion. Maybe there’s a comfort in acknowledging some sort of leader. A band that you can be proud of. A band you can go see, even if you haven’t listened to their albums in years, and be reminded that rock hasn’t died. Pearl Jam is that band. n Pearl Jam with Mudhoney • Sat, Nov. 30 at 7:30 pm • Spokane Arena • 720 W. Mallon Ave. • $69.50 and up • All-ages • ticketswest. com • 800-325-SEAT PEARL JAM SAVED MY LIFE In August of 2011, Jason Baldwin became a free man for the first time since he was 16 years old, convicted of murdering three 8-year-old boys in a small Arkansas city in 1994. As one of the West Memphis Three, Baldwin’s plight, and the plight of the other two men convicted as the result of a sloppy, corrupt investigation, caught the attention of Eddie Vedder and Pearl Jam, who worked for more than a decade to help the men get out of prison. When he got out of prison, Baldwin had nowhere to go, and that’s when Pearl Jam’s philanthropy wing, the Vitalogy Foundation, stepped in. Now living in Seattle, here’s what Baldwin had to say about Pearl Jam: “Since the first Paradise Lost documentary was released in 1996, Eddie Vedder has contributed his money, time, energy and reputation to not only freeing Damien [Echols], Jessie [Misskelley] and myself, but to ensure that continued justice efforts for the three slain boys are not forgotten. Since our release was contingent upon the unjust Alford Plea, which prohibited compensation for our years of wrongful imprisonment, Ed has also helped ensure that we are able to live happy and productive lives. For me in particular, a major goal of free life has long been to pursue higher education. In June, I completed an Associate of Arts degree, thanks to the generosity of a scholarship provided by Pearl Jam’s Vitalogy Foundation. Each band member decides where 20 percent of the proceeds will go, and Ed chose to help me pursue my dreams. I am so thankful to him and to Pearl Jam for everything they’ve done for me.” MUSIC | LOCAL SCENE Winter Tunes Combat the early darkness and freezing temps with songs recommended by local musicians BY LAURA JOHNSON F or an entire month, holiday music is all-consuming. But after the gifts have been unwrapped and glowing fixtures taken down, which songs are there to help stave off the winter 1. “King’s Crossing” by Elliott Smith I always seem to listen to a lot of Elliott Smith this time of year. This song has my attention right now. It makes me feel calm during this potentially stressful time of year.” — Henry Nordstrom of Dead Serious Lovers 2. “Yes I Know” by Memory Tapes Besides Mariah Carey’s “All I Want For Christmas Is You,” this is my favorite winter song; I love [Dayve Hawk]. — Cody Thompson of Nude Pop 3. “Because” by the Beatles I don’t think there’s a more chilling vocal performance in history — those harmonies. Something about it makes me cold and look forward to summer that much more. — Matt Legard of the Colourflies blues? We asked Inland Northwest musicians what tunes make the seemingly never-ending season bearable. Here are eight suggested tracks: 4. “Me vs. Maradona vs. Elvis” by Brand New I just love this song. I remember spending hours of my winters in my room when I was younger listening to that album; me and my friends trying to write songs like that, that album was a big part of my growing up. — Turtle Gunion of Death By Pirates 7. “Snow (Hey Oh)” by Red Hot Chili Peppers This is our band’s song. We end up playing a ton of shows at home in the winter, also at ski resorts. “Snow (Hey Oh)” gets us in the mood to play on stage when it’s freaking cold outside. — Flying Mammals 5. “No Quarter” by Led Zeppelin Next time you are driving in falling snow, crank up that song, I defy you to not love your surroundings. — Elton Jah, reggae Elton John cover artist 8. “River” by Joni Mitchell For me, this song perfectly captures the mismatch between the overzealous happiness of the holiday season and the wintry, melancholy feeling of longing and wanting to be somewhere else. — Liz Rognes, singersongwriter n 6. “Neighborhood #1 (Tunnels)” by Arcade Fire I think snow is beautiful and all ... I just don’t like walking through it, driving in it, or shoveling it. Being cold and wet just isn’t my bag. But listening to this song, I can at least be thankful that I’m not “living out in the snow.” — Eric Shears of Half Zodiac See more winter song selections at Inlander.com/music. Wednesday Nov 27th SALLY BOP JAZZ & WHISKEY WEDNESDAY Happy Birthday Kelli! Thursday Nov 28th Closed for Thanksgiving!!! Friday Nov 29th JESSE WESTON TRIO Saturday Nov 30th THE BUTTERBALL: Vinyl Butter Reunion Show Sunday Dec 1st HAPPY TIME PRICES ALL NIGHT Monday Dec 2nd TRIVIA - 7pm with Tom the Bonana King!!! Tuesday Dec 3rd TONE DEAF TUESDAY KARAOKE - at 9! Wednesday Dec 4th SALLY BOP JAZZ & WHISKEY WEDNESDAY 25 Craft Beers & Craft Cocktails 120 E. Sprague Ave. Stay up to date on conditions & news all season long. IN THE INLANDER December 19 January 16 February 13 TO ADVERTISE IN THE SNOWLANDER SERIES: SALES@INLANDER.COM • 509.325.0634 EXT. 216 SNOWLANDER.COM /snowlander NOVEMBER 28, 2013 INLANDER 41 MUSIC | SOUND ADVICE FOLK MAMA DOLL J = THE INLANDER RECOMMENDS THIS SHOW J = ALL AGES SHOW Thursday, 11/28 H BEATS ABADAWN & ERASERFASE I BOOMERS CLASSIC ROCK BAR & GRILL, DJ Yasmine THE VAULT SOCIAL CLUB AND EATERY, DJ Seli ZOLA, Fus Bol t’s shows like these that make going out in the middle of the week worth it. Portland artist Abadawn — who’s been called a “true punk rap” artist — brings his weird, left-of-normal style to the Mootsy’s stage this week. Just when you think rappers are all starting to sound the same, Abadawn comes along. His frank, snarling style has been praised by mags like Complex, and has taken him to the stage as an opener for titans like Talib Kweli. Along with him comes Eraserfase, a fascinating beatmaker fresh off a tour opening for Del. Eraserfase makes beats that are trippy and psychedelic — the kind of stuff that will turn on both seasoned beatmakers and newbie raver kids. — LEAH SOTTILE Angry Xmas Tour feat. Abadawn, Mine+Us, Eraserfase • Wed, Dec. 4 at 9 pm • Mootsy’s • 406 W. Sprague • $5 • 21+ • 838-1570 Friday, 11/29 315 MARTINIS AND TAPAS, Darin Schaffer BEVERLY’S, Robert Vaughn BIGFOOT PUB (467-9638), SixStrings n’ Pearls BOLO’S, Torino Drive BOOMERS CLASSIC ROCK BAR & GRILL, Not Guilty J BOOTS BAKERY & LOUNGE, Oracles Kitchen THE CELLAR, Kosh and Jazz Cats J CHAIRS COFFEE (340-8787), Open Mic of Open-ness COEUR D’ALENE CASINO, Nate Ostrander, The Jam Band COLDWATER CREEK WINE BAR, Ron Kieper Jazz Trio THE COUNTRY CLUB, Truck Stop Betty CURLEY’S, YESTERDAYSCAKE FIZZIE MULLIGANS, Whack A Mole THE FLAME, DJ Wesone GIBLIANO BROTHERS, Dueling Pianos HILLS’ RESTAURANT & LOUNGE (7473946), Gretchen & the Wolf J THE HOP!, Saxeus, Autolycus, The Hep Cats, Switchin’ to Whiskey IRON GOAT BREWING CO. (4740722), The Iron Goat Trio IRON HORSE BAR, Scorpius IRV’S, DJ Prophesy JONES RADIATOR, Jesse Weston Trio J KNITTING FACTORY, All That Remains, Motionless in White, Soil, Helldorado LEFTBANK WINE BAR, Carey Brazil LUCKY’S IRISH PUB, Likes Girls J MEZZO PAZZO WINE BAR, Kevin Gardner 42 INLANDER NOVEMBER 28, 2013 ey, Terrible Buttons freaks: you’ve heard Mama Doll, right? If you haven’t, here’s the deal: Sarah Berentson — the tiny singer and keyboard player in the Buttons with the big, old voice — has started this side project with Austin Case and Jen Landis. Together, the three women form a sound that is beautiful while being bare and primal in a feminine sort of way. The band’s music is simple, with only ukulele strumming and maybe the beat of a floor tom. Mama Doll is all about the way these women harmonize, and about the things they say. Yes, it’s pretty. But Mama Doll is also sort of dark and haunting, so if you’re a Buttons fan, you’re going to love this band. — LEAH SOTTILE Mama Doll with the Shook Twins, Justin Lantrip • Sat, Nov. 30 at 7:30 pm • Panida Theater • 300 N. 1st Ave., Sandpoint • $12/$15 day of show • brownpapertickets.com • (208) 263-9191 NYNE, The Divine Jewels O’SHAY’S, Arvid Lundin and Carla Carnegie J THE PEARL THEATER, Home for the Holidays with Shook Twins, Anna and The Underbelly PEND D’OREILLE WINERY, The Powell Brothers ROADHOUSE COUNTRY ROCK BAR, Last Chance Band THE ROCK BAR AND LOUNGE (4433796), Steve Livingston, Triple Shot, DJ JWC SEASONS, Dan Mills TWELVE STRING BREWING COMPANY (241-3697), Maxie Ray Mills ZOLA, Chris Rieser & Snap the Nerve Saturday, 11/30 315 MARTINIS AND TAPAS, Jazz Guyz BEVERLY’S, Robert Vaughn BIGFOOT PUB (467-9638), SixStrings n’ Pearls BOLO’S, Torino Drive BOOMERS CLASSIC ROCK BAR & GRILL, Not Guilty THE CELLAR, Kosh and Jazz Cats COEUR D’ALENE CASINO, Nate Ostrander, The Jam Band COEUR D’ALENE CELLARS, Eric Neuhausser THE COUNTRY CLUB, Truck Stop Betty CURLEY’S, YESTERDAYSCAKE DALEY’S CHEAP SHOTS, Jesse Weston Trio FEDORA PUB, Mike Morris FIZZIE MULLIGANS, Whack A Mole THE FLAME, DJ Wesone GIBLIANO BROTHERS, Dueling Pianos J THE HOP!, Vendetta II IRON HORSE BAR, Scorpius IRV’S, DJ Prophesy J JONES RADIATOR, Vinyl Butter Reunion, Butterball LA ROSA CLUB, Will Foster Band THE LARIAT (466-9918), The Ricks Brothers Band LUCKY’S IRISH PUB, Likes Girls J MEZZO PAZZO WINE BAR, Nick Grow NYNE, DJ C-Mad J PANIDA THEATER (208-263-9191), Home for the Holidays feat. the Shook Twins, Justin Lantrip, Mama Doll (See story above) PEND D’OREILLE WINERY, Emily Baker J THE PHAT HOUSE, Paul Abner ROADHOUSE COUNTRY ROCK BAR, Last Chance Band THE ROCK BAR AND LOUNGE (4433796), DJ Sonny SEASONS, Dan Mills J THE SHOP, Angela Marie Project J SPOKANE ARENA, Pearl Jam (See story on page 39) ZOLA, Chris Rieser & Snap the Nerve Sunday, 12/1 J CARR’S CORNER, Buckthorn Borthers, Zebrana Bastard, Gardening Angel THE CELLAR, Pat Coast DALEY’S CHEAP SHOTS, Jam Night with VooDoo Church MOOSE LOUNGE (208-664-7901), Michael’s Music Technology Circus J REVEL 77 (280-0518), Hannah Siglin ZOLA, Ron Greene Monday, 12/2 BOWL’Z BITEZ AND SPIRITZ, Open mic J CALYPSOS (208-665-059), Open Mic EICHARDT’S, Blues Jam hosted by Truck Mills J THE HOP!, Gag, The Lot Lizards, Collateral Damage, Septic Schizo, Chemical Restraint PJ’S BAR & GRILL, Acoustic Jam with One Man Train Wreck RICO’S, Open mic Tuesday, 12/3 BEVERLY’S, Robert Vaughn THE CELLAR, Max Daniels FEDORA PUB, Tuesday Night Jam with Truck Mills KELLY’S IRISH PUB, The Powell Brothers LION’S LAIR (456-5678), DJs Nobe and MJ GET LISTED! Get your event listed in the paper and online by emailing getlisted@inlander. com. We need the details one week prior to our publication date. J RED ROOSTER COFFEE CO. (3217935), Open mic RICO’S, WSU School of Music Jazz Band THE ROCK BAR AND LOUNGE (4433796), Open mic with Frank Clark SPLASH, Bill Bozly THE VAULT SOCIAL CLUB AND EATERY, DJ Q Wednesday, 12/4 BEVERLY’S, Robert Vaughn J BOOTS BAKERY & LOUNGE, Benefit Show feat. the mother THE CELLAR, Barry Aiken J CHAPS, Land of Voices with Dirk Swartz EICHARDT’S, Charley Packard FIZZIE MULLIGANS, Kicho IRON HORSE BAR & GRILL, Open mic IRV’S, DJ Prophesy LA ROSA CLUB, Jazz Jam with the Bob Beadling Group J MEZZO PAZZO WINE BAR, Ron Criscione J MOOTSY’S, Angry Xmas Tour feat. Abadawn, Mine+Us, Eraserface (See story on facing page) J THE PHAT HOUSE, Be Open Mic with Mike Bethely RICO’S, WSU School of Music Jazz Band SOULFUL SOUPS AND SPIRITS, Open mic SUKI YAKI INN (624-0022), One Man Train Wreck THE VAULT SOCIAL CLUB AND EATERY, DJs Freaky Fred and MC Squared ZOLA, The Bucket List 509.535.9309 Coming Up ... BELLTOWER, Runaway Symphony CD release party, Dec. 5 MOSCOW FOOD CO-OP, Will Fontaine, Dec. 5 CHATEAU RIVE, Rick Estrin & The Night Cats, Dec. 5 KNITTING FACTORY, Adventure Club with Dvbbs, Dallask, Hunter Siegal, Dec. 5 JOHN’S ALLEY, Gypsy Lumberjacks, Dec. 5 JONES RADIATOR, Moses Wiley, Sally Bob Jazz, Dec. 6 INTERPLAYERS THEATRE, Guitarist Paul Abner, Dec. 6 THE HOP!, 5 Times Over, The Nixon Rodeo, Beyond Today, Coming ALice, Undercard, Dec. 6, 7 pm KNITTING FACTORY, Smile Empty Soul, Acidic, First Decree, Evolved, Dec. 6, 8 pm LUXE COFFEEHOUSE, Fabio Undulata, Dec. 6 NYNE, Luke Pate, The Longnecks, Mishap, Dec. 6 MOOTSY’S, Terrible Buttons, Jail Weddings, Historian, Dec. 6 LA ROSA CLUB, Cedar and Boyer, Dec. 7 REPUBLIC BREWING CO., Los Rusteros, Dec. 7 THE SHOP, EWU Music Dept. and Guests, Dec. 7 CHECKERBOARD BAR, Damaged Goods, Mautam, Wicked Obsession, Dec. 7 MOOTSY’S, Handsome Jack & The Handsome Devil, The Spirit Animals, Dec. 7 THE HOP!, F@$kface Unstoppable, Kissing Candice, Dec. 7 BING CROSBY THEATER, Shawn Colvin, Dec. 8 NORTHERN QUEST CASINO, Chris Isaak, Dec. 8 KNITTING FACTORY, Jake Miller with Action Item, Air Dubai, Dec. 8 MARTIN WOLDSON THEATER AT THE FOX, Tedeschi Trucks Band, Dec. 11 JONES RADIATOR, Six-Strings n’ Pearls, Dec. 12 NYNE, Eric Himan, Dec. 12 MOSCOW FOOD CO-OP, Lewis-Clark State College Saxophone Quartet, Dec. 12 REPUBLIC BREWING CO., Brother, Dec. 12 KNITTING FACTORY, Metalachi, Dec. 12 KNITTING FACTORY, Will Hoge, Red Wanting Blue, Dec. 13 CARR’S CORNER, 2PIECE, Roulette Delgato, Cordell Drake, Jay Cope, Dec. 13 MOOTSY’S, Marshall McLean Band, Kori Henderson, Dec. 13 REVEL 77, Gardening Angel, Dec. 14 BING CROSBY THEATER, The Shook Twins with Morning Ritual, Dec. 14 KNITTING FACTORY, Blistered Earth with Helldorado, In Denial, Dec. 14 MOSCOW FOOD CO-OP, Celebration Strings, Dec. 19 LAGUNA CAFÉ, Robinsong, Dec. 20, CARR’S CORNER, Best of Friends, Josh Withenshaw, Dec. 20 6412 E. Trent Spokane Valley BENEFIT TO SEND TO MEMPHIS IN THE SPRING! Dec 7th at 7pm LIVE MUSIC Bakin Phat VooDoo Church Pat Coast Band Whack-A-Mole Find us on FaceBook @ thecountryclubcda to see our upcoming events NOVEMBER 29 and 30 “TRUCK STOP BETTY” Sunday & Monday Funday with cornhole tournaments at 6.30 each night. $10 entry Twofer & Trivia Tuesday hosted by Dave & Janet at 6.30. Great food and drink specials. Thirsty Thursday with country dance lessons at 8 and $2 wells and PBR from 6 - 10. 208.676.2582 216 E COEUR D'ALENE AVE Great Music, Great Flavor, No Bull! Doors Open at 4pm. Every Wednesday night compete in the Country Clubs Karaoke Contest with cash prizes starting at $100. Stop by for our weekday events. Monday night Football, Thursday Ladies night with FREE line dance lessons and happy hour every weekday from 4 to 6.67 NOVEMBER 28, 2013 INLANDER 43 MUSIC AWESOME ACCORDION The accordion may have found more of a permanent home in Spokane after last year’s World Trophy Accordion Championship was held here. Many may stereotype the multifaceted instrument as intended for one genre of music — polka. Since the competition came to town, not only has support for the accordion increased in Spokane, the instrument has also been recognized as one that can play many types of music with versatility and harmony. Highlights of this upcoming performance include 13-year-old Naomi Harris, who competed in last year’s competition, as well as the Portatos, an accordion band that covers hits like “Surfin’ U.S.A.” and “The Final Countdown.” And don’t forget the Vivace Accordion Orchestra. — EMERA L. RILEY Accordion Celebration feat. The Vivace Accordion Orchestra of Spokane • Sun, Dec. 1, at 3 pm • $10 • Bing Crosby Theater • 901 W. Sprague • bingcrosbytheater.com • 227-7638 44 INLANDER NOVEMBER 28, 2013 COMMUNITY PRE-FEAST RACE The season of giving is here, and so is the annual Turkey Trot run. On what’s looking to be a crisp Thanksgiving morning, hundreds of Spokanites will gather in Manito Park to take part in this local tradition. Runners from all over town participate in the annual race to get in their pre-feast calorie burn before stuffing themselves with taters and pie. Organized by the Bloomsday Road Runners Club, participants are encouraged to donate nonperishable food or cash to benefit Second Harvest Food Bank as their race entry fee. Everyone is invited to take part, uniting in the spirit of giving. Choose from 2-, 3- or 5-mile routes. — BRONWYN DOUBET BRRC Turkey Trot 2013 • Thu, Nov. 28, at 9 am; arrive early to sign waiver and drop off donations • Manito Park Duck Pond • 1702 S. Grand • brrc.net DRINKING SCOTCHY SCOTCH SCOTCH Scotch whiskey isn’t just for Ron Burgundy. The amber liquid is something everyone — 21 and over, of course — can enjoy one slow, warming sip at a time. That’s what the Connoisseur’s Club at the Lincoln Center wants to show you The Connoisseur’s Club Scotch Social • Sat, Nov. 30, from 6-10 pm • $70 • 21+ • The Lincoln Center • 1316 N. Lincoln • thelincolncenterspokane.com • 327-8000 GET LISTED! Email getlisted@inlander.com to get your event listed in the paper and online. We need the details one week prior to our publication date. People & Pets Welcome Benefitting Washington Basset Rescue & Higher Ground Animal Sanctuary $1 Raffle Tickets Games with Prizes Silent Auction PHOTOS WITH MADDIE (the Bulldog of Gonzaga) SUn, DEC 1st 12 - 2:30PM FILM LAUGH TRACKS Some old movies are just so terrible and cheesy the only bearable way to sit through them is to be drunk, stoned (hey, it’s legal now) or while listening to sidesplitting live commentary. The latter is what audiences get at a RiffTrax show — live screenings of classic, super-dorky films with goofy, sometimes inappropriate remarks by some of the funny guys who starred on the legendary cult-comedy show “Mystery Science Theater 3000.” The next RiffTrax hitting the Inland Northwest features the 1964 sci-fi holiday fiasco Santa Claus Conquers the Martians, which regularly makes lists of the worst films ever made. It can be really fun, though, when paired with the insight of former MST3K crewmembers Michael J. Nelson, Kevin Murphy and Bill Corbett. — CHEY SCOTT RiffTrax Live: Santa Claus Conquers the Martians • Thu, Dec. 5 at 8 pm • $12.50 • Regal Cinemas Northtown and Regal Cinemas Riverstone (CdA) • fathomevents.com LINCOLN CENTER’S MONROE BALLROOM 1316 N. Lincoln St., Spokane $5 Santa Claws Photos (Kids, Fur-Kids, or the whole family) Dog and Cat Food Drive Adoptions Howliday Shopping For more info, visit: wabr.net FREE EVENT with over 15 non-profit vendors! S pokane p uBlic R adio celebrates MaRdi gRaS aS with B eau S oleil avec Michael Doucet Love Cats? F eB . 23, 7:30 p - B ing c RoSBy T heaTeR TICKETS MAKE GREAT SHOPPING SUPPORT LOCAL If the thought of rushing out to big-box stores for Black Friday feels kind of icky, save your dollars and shopping list for Small Business Saturday, a movement that began gaining steam nationwide during the worst of the recession years. You won’t find insane doorbusters at local shops, but plenty of businesses are offering modest discounts, treats and other activities, kicking off the holiday shopping season. Stop by all the hubs of local shopping, including the Garland District, downtown Coeur d’Alene and the various pockets of downtown Spokane. Following an idea from Sherman Alexie, local authors will sign books at indie bookstores, including Auntie’s. Pick up the Inlander’s new Shop Local Guide, available at most Inlander racks, to know where to go. — LISA WAANANEN Small Business Saturday • Sat, Nov. 30 • Shop at any locally owned business; many offer special discounts and promotions • search the hashtag #SmallBusinessSaturday for local deals GIFTS! $ 38 $ 30 OUTLETS / 800.325.SEAT * o t h e r f e e s a p p ly KPBZ 90.3 KPBX 91.1 KSFC 91.9 SPOKANEPUBLICRADIO.ORG DESIGN SPIKE NORTH DIVISION BICYCLE SHOP e venT d onoRS Follow Chey Scott’s Cat Friday Blog for your weekly feline fix! INLANDER.COM/BLOGS KPBZ 90 . 3 . KPBX 91. 1 . KSFC 91. 9 NOVEMBER 28, 2013 INLANDER 45 EVENTS | CALENDAR BENEFIT BENEFIT YOGA CLASS The 7th annual Thanksgiving Day class benefits Second Harvest. Attendees are asked to donate food or cash in lieu of a class fee. Nov. 28, 8:30-11:30 am. Yoga Shala, 505 E. 24th Ave. (270-6353) TEDDY BEAR & BLANKET DRIVE Hosted by the Health Policy and Administration Association of Healthcare Students at WSU. Bears to be delivered to kids at Shriners Hospital for Children and Sacred Heart Children’s Hospital. New or gently used blankets to be donated to homeless teens at CrossWalk. Dec. 4-5. Riverpoint Campus, 600 N. Riverpoint Blvd. (358-7640) HOLIDAY PAWTINI PARTY Hosted by the Spokane Humane Society and the Diva Dog Pet Boutique, featuring adoptable pets, a canine fashion show, pet photos with Santa and more. Dec. 5, 6-9 pm. $5-$10. Comfort Inn University District, 923 E. Third Ave. facebook. com/events/2302459638024) COMEDY HUGE SAVINGS! FIGHTIN’ CREEK IS YOUR ONE-STOP SHOP FOR ALL YOUR TOBACCO PRODUCTS! Cartons s a as low 20! $ g Chewin as o c c a b o T low as $ 89 8 FIGHTIN’ CREEK MARKET Open every day 5am-11pm On the corner of HWY 95 & Elder Rd. | 18 miles South of CDA 12727 W. Elder Rd | Worley, ID | 208.664.7040 1.866.51.SMOKE | FightinCreek.com HOME OF THE LOWEST CIGARETTE & TOBACCO PRICES YOU CAN FIND! 46 INLANDER NOVEMBER 28, 2013 ALL-AGES COMEDY OPEN MIC Second and fourth Thursdays at 6 pm. Free. Boots Bakery & Lounge, 24 W. Main Ave. bootsbakery.com (703-7223) GUFFAW YOURSELF! Open-mic comedy, including stand-up, sketch, improv or anything weird. Five minutes max per performer. Every other Thursday at 10 pm. Free. Neato Burrito, 827 W. First Ave. (847-1234) STAND-UP COMEDY Local comedians. See weekly schedule online. Thursdays at 8 pm. Free. Uncle D’s Comedy Underground, 2721 N. Market St. uncledscomedy.com (483-7300) FAMILY DINNER Live comedy improv show based on audience suggestions about their family members. Fridays at 8 pm through Nov. 29. $7-$9. Blue Door Theatre, 815 W. Garland Ave. bluedoortheatre.com (747-7045) SAFARI Short-form improv games based on audience suggestions. Allages. Saturdays at 9 pm. $7. Blue Door Theatre, 815 W. Garland Ave. bluedoortheatre.com (747-7045) AN EVENING WITH MARIA BAMFORD Live comedy show. Dec. 7 at 9 pm. $16$20. Knitting Factory, 919 W. Sprague Ave. sp.knittingfactory.com (244-3279) COMMUNITY FEED THE NEIGHBORHOOD Free meals provided. Volunteers also needed to cook and serve food. Wednesdays, 4:30-6 pm. Free. Feed the Neighborhood, 7th Ave. and Catherine St. , Post Falls. (208-661-5166) HOLIDAY GIFT DRIVE Gift drive for new or gently used board games and arts & crafts supplies, to benefit families served by rural DCFS offices in the Spokane area. Drop off unwrapped gifts Mon-Fri from 8 am-5 pm through Dec. 10. Mondays-Fridays, 8 am-5 pm through Dec. 10 Empowering, Inc. Services, 1025 W. Indiana Ave. ((509) 624-7104) COMMUNITY THANKSGIVING DINNER The third annual community dinner includes traditional dishes and is free to community members. Nov. 28, 11 am-4 pm. Free. Fedora Pub, 1726 W. Kathleen Ave. fedorapubandgrille.com (208-765-8888) SANTA CLAWS FOR PETS & PEOPLE Fundraiser event benefiting local animal rescue nonprofits featuring Santa photos, a pet food drive, raffles, adoptable pets, games and more. Dec. 1 at noon. Free admission. Lincoln Center, 1316 N. Lincoln St. (590-9667) SOAP FOR HOPE DRIVE The sixth annual toiletry drive benefits local charities, including Hope House/StreetWise, Hearth Homes, Transitions for Women, and others. Donations can be dropped off at any local AAA office, through Dec. 31. AAA Downtown Spokane, 1717 W. Fourth Ave. aaa.com/soapforhope MEDICARE BENEFIT WORKSHOP Community workshop on choosing a Medicare plan and more. Dec. 3 at 1 pm. Free. Bell-Anderson Financial, 12309 E. Mirabeau Parkway. bellandersenfinancial.com (993-1816) GSI’S LEGISLATIVE FORUM A panel of local and regional state legislators discuss the recent special session and what to expect from the upcoming session in January. Reception to follow the forum. Dec. 4 from 3-5 pm. $50/ members, $80/nonmember. Davenport Hotel, 10 S. Post St. greaterspokane.org (624-1393) INLAND NW NONPROFIT SUMMIT Hosted by the Spokane Valley Chamber of Commerce, featuring a keynote presentation by Patrick McGaughey. Dec. 4, 10 am-1 pm. $89. Mirabeau Park Hotel, 1100 N. Sullivan Rd. mirabeauparkhotel.com (924-4994) WEEKEND COUNTDOWN Get the scoop on this weekend’s events with our newsletter. Visit Inlander.com/newsletter to sign up. LANDS COUNCIL HOLIDAY PARTY Annual holiday celebration hosted by the local environmental nonprofit. Dec. 4, 5:30-7:30 pm. Free. Community Building, 35 W. Main Ave. landscouncil. org (232-1950) SPOKANE BLIND BASEBALL FUNDRAISER NIGHT Open mic Christmas carols, holiday trivia, silent auction and more. 25 percent of proceeds that evening to be donated to the nonprofit. Dec. 4, 5:30-8:30 pm. Free admission. Shakey’s Pizza, 9602 N. Newport Hwy. (464-0200) CATCHING FIRE COMPETITION A Hunger Games-inspired party with competitions and more. Grades 6+. Dec. 5 at 4 pm. Free. North Spokane Library, 44 E. Hawthorne Rd. scld.org (893-8350) PULLMAN HOLIDAY FEST & TREE LIGHTING Tree lighting ceremony with live entertainment, refreshments and the 3rd annual Kid’s Jingle Bell Fun Run (ages 12 and under). Race entry: $10/ child, accompanying adults are free. Dec. 7 from 4-6 pm. Downtown Pullman. pullmanchamber.com (334-3565) CRAFTS FESTIVAL OF FAIR TRADE The 29th annual event features globally-made handcrafts, clothing, jewelry, pottery and more, made in non-sweatshop environments around the world. Nov. 29- Dec. 1 from 10 am-5 pm. Free admission. Community Building, 35 W. Main Ave. festivaloffairtrade.com (448-6561) CHRISTMAS CARD MAKING CLASS Class on stamping and die-cut making. All materials provided. Dec. 5, 12-2 pm Free. Hayden Library, 8385 N. Government Way. (208-772-5612) FALL CRAFT FAIR Featuring handmade items by Providence staff and friends. Dec. 6 from 8 am-4 pm. Providence Holy Family, 5633 N. Lidgerwood St. holy-family.org (482-0111) VINTAGE VIXENS HOLIDAY SHOW Local vendor gift fair featuring antique, retro and primitive items, paper crafts and more. Dec. 6-7 at 10 am each day. Free admission. Riverwalk Plaza, 1003 E. Trent Ave. DECK THE FALLS Annual holiday gift and craft sale featuring work by local and regional artists. Dec. 7 from 10 am-4 pm. Free admission. Cutter Theatre, 302 Park St. cuttertheatre.com (509-446-4108) FILM RUSH Film based on the true story of Formula 1 race car drivers James Hunt and Niki Lauda. Nov. 29-Dec. 1, show times vary. $6. Kenworthy Performing Arts Centre, 508 S. Main St. kenworthy. org (208-882-4127) HALF THE SKY Screening as part of the 29th annual Festival of Fair Trade (Nov. 29-Dec. 1). featuring stories of women and girls around the world living in horrific circumstances. Also includes a pre-film discussion “Moving Beyond the Paralysis: Steps for Making Positive Chance.” Nov. 30 at 2 pm. $5. Magic Lantern Theatre, 25 W. Main Ave. magiclanternspokane.com (448-6561) CHITTY CHITTY BANG BANG Screening as part of “Totally Tubular Tuesdays.” Dec. 3, show time TBA. $1. Garland Theater, 924 W. Garland Ave. garlandtheater.com (509-327-1050) RIFFTRAX LIVE: “SANTA CLAUS CONQUERS THE MARTIANS” Live screening of the movie with the commentary from the stars of “Mystery Science Theater 3000.” At Regal Cinemas Northtown and Regal Cinemas Riverstone (CdA). Dec. 5 at 8 pm. $12.50. fathomevents.com (800-326-3264) INTO THE MIND Screening of the ski and snowboarding film by Sherpa Cinema. Dec. 6, 7 pm. $15. Panida Theater, 300 N. First Ave., Sandpoint. panida. org (208-263-9191) SCROOGED Screening as part of “Totally Tubular Tuesdays,” show time TBA. Dec. 10. $1. Garland Theater, 924 W. Garland Ave. garlandtheater.com (327-1050) CHARIOTS OF FIRE Screening as part of the “Great Sports Films at the Library” series. Dec. 11 at 5:30 pm. Free. Downtown Library, 906 W. Main Ave. spokanelibrary.org (444-5300) BING CROSBY HOLIDAY FILM FESTIVAL The 8th annual holiday film festival features screenings of classic Bing Crosby films, and a motor coach tour, “On the Bus with Bing,” featuring places in Spokane where Crosby lived and played (Dec. 15 from 1-4 pm, $20). Films: official airs in the US. Prizes for best costumes, refreshments, activities and more. Dec. 15, 2-4 pm. Free, reservations required. Lincoln Center, 1316 N. Lincoln St. ksps. org/da4-party (800-735-2377) INLANDER GIVE GUIDE PRESENTS “ELF” Give Guide, the paper’s annual local philanthropy issue, hosts a screening of the holiday film “Elf” with all proceeds benefiting Catholic Charities of Spokane. Dec. 18 at 7 pm. TBA. Bing Crosby Theater, 901 W. Sprague Ave. bingcrosbytheater.com FOOD TASTEFUL THURSDAYS Live music and product samples every Thursday through Dec. 19, from 5-7 pm, featuring local food vendors and musicians. Free. Moscow Food Co-op, 121 E. 5th St. moscowfoodcoop.com (208-8828537) BLACK FRIDAY WINE SPECIAL Class on the best value wines to stock up on for the holiday season. Nov. 29, 7 pm. $20, RSVP required. Rocket Market, 726 E. 43rd Ave. (343-2253) NO-LI BREWHOUSE TOURS See what goes on behind the scenes and how No-Li’s beer is made. Fridays at 5 pm and 6 pm; and Saturdays at 3 pm and 4 pm. Free. No-Li Brewhouse, 1003 E. Trent. nolibrewhouse.com (242-2739) VINO! WINE TASTING Friday features sparkling wine and Champagne and mimosas by the glass. Saturday features top Italian selections, including cheese and crackers. Nov. 29, 3-6:30 pm and Nov. 30, 2-4:30 pm. $10 per event. Vino! A Wine Shop, 222 S. Washington. vinowine.com (838-1229) RED SATURDAY Similar to Black Friday, celebrate “Red Saturday”, cigars. Jacklin Arts & Cultural Center, 405 N. William St., Post Falls. jacklincenter.org (208-457-8950) CHRISTMAS LUNCHEON “Peace on Earth” holiday luncheon fundraiser featuring live holiday entertainment and more. Dec. 6 at 11 am. $15-$18. Corbin Senior Center, 827 W. Cleveland Ave. corbinseniorcenter.org (327-1584) DAVENPORT HOTEL HOLIDAY LUNCHEON Enjoy a lunch in the hotel, elborately decorated for the holiday season. Dec. 6 from 11:30 am-1 pm. $25. Davenport Hotel, 10 S. Post St. davenporthotelcollection.com (789-6819) GLOBAL BUBBLY Sparkling wine tasting class, featuring nine wines from around the world. Dec. 6 at 7 pm. $20, reservations required. Rocket Market, 726 E. 43rd. (343-2253) WINE & CHEESE TASTING Sample cheeses and wine from around the world and discover new wine and cheese pairings. Dec. 7 at TBA. Huckleberry’s Natural Market, 926 S. Monroe. (624-1349) SMALL VINEYARDS OF SPAIN Wine tasting class featuring direct import Spanish wines. Classes now offered both Fri and Sat, Dec. 13-14, at 7 pm. $20, reservations required. Rocket Market, 726 E. 43rd Ave. rocketmarket. com (343-2253) MUSIC CELTIC THUNDER World music concert. Nov. 29-30 at 7 pm. $45-$60. Northern Quest Casino, 100 N. Hayford Rd. northernquest.com (481-6700) PAUL ABNER GUITAR SERIES Concerts every Saturday by the local Grammy-hopeful soloist Paul Abner. Saturdays at 2 pm. Free. Rocket Bakery, 157 S. Howard. (838-3887) AVÉ! HOLIDAY CONCERT Holiday concert featuring music from the 16th Century to the modern era, including the premier performance of a composition by William H. Mays, of Spokane. Dec. 1 at 3 pm. Free, donations accepted. Convent of the Holy Names, 2911 W. Fort George Wright Dr. (326-9516) VIVACE ACCORDION ORCHESTRA OF SPOKANE Concert showcasing the versatility of the accordion featuring local performers. Dec. 1 at 3 pm. $10. Bing Crosby Theater, 901 W. Sprague Ave. (227-7404) SFCC ORCHESTRA HOLIDAY CONCERT Featuring music by Brahms, Bach and Beethoven, directed by Shelley Rotz. Dec. 2 at 7 pm. $2-$5. Spokane Falls Community College, 3410 W. Fort George Wright Dr. ) SPIRIT OF SPOKANE CHORUS Local women’s chorus specializing in fourpart a capella harmony in a barbershop style. Meets on Tuesdays at 6:45 pm. Opportunity Presbyterian Church, 202 N. Pines Rd. (218-4799) COEUR D’ALENE SYMPHONY “Christmas at the Kroc” holiday concert. Dec. 4 and Dec. 6 at 7:30 pm. $8-$20. Kroc Center, 1765 W. Golf Course Rd. cdasymphony.org (208-765-3833) SFCC JAZZ NIGHT HOLIDAY CONCERT Directed by Kevin Woods and Danny McCollim, featuring a holidaythemed jazz program. Dec. 4 at 7 pm. $2-$5. Spokane Falls Community College, 3410 W. Fort George Wright Dr. spokanefalls.edu (533-3720) EWU SYMPHONY ORCHESTRA Also features the EWU Wind Ensemble. Dec. 5 at 5 pm. $3-$5. Eastern Washington University, Showalter Auditorium, 526 Fifth St. ewu.edu/music (359-7078) THE JUBILEE CHRISTMAS TOUR Southern-style gospel Christmas music concert featuring The Booth Brothers, Greater Vision and Legacy Five. Dec. 5 at 7 pm. Lake City Community Church, 6000 N. Ramsey Rd., CdA (208-676-0632) PERFORMANCE NUTCRACKER MINI PERFORMANCES Local children perform scenes from the classic holiday tale. Nov. 29-Dec. 1 from 1-3 pm. Performances held on the first level, outside of Nordstrom. Free. River Park Square, 808 W. Main Ave. riverparksquare.com (624-3945) NORTHSIDE SPOKANE VALLEY 9719 N. Division St. 509-455-8290 15110 E. Indiana Ave. 509-924-8187 THE AREA’S BIGGEST HARDWOOD SELECTION! INVENTORY INVENTORY BLOWOUT SALE! Save on the on the latest floor 12/30/13. We hope to see you soon. SAVE 50 % UP TO STOREWIDE PLUS SPECIAL FINANCING AVAILABLE* Sincerely,. 100 $ OFF Now available with See store for details. Any Purchase of $1,499 or More! NOVEMBER 28, 2013 INLANDER 47 RELATIONSHIPS Advice Goddess TOOK comAMY ALKON puter, ‘em and dump ‘em ‘bout we put stale bread cubes on sticks and dunk ‘em..” n ©2013, Amy Alkon, all rights reserved. • Got a problem? Write Amy Alkon, 171 Pier Ave, #280, Santa Monica, CA 90405 or email AdviceAmy@aol.com () 48 INLANDER NOVEMBER 28, 2013 EVENTS | CALENDAR TOY SHELF A family-oriented holiday show about toys in a workshop. Nov. 30 at 2 pm and 7 pm. $12. Bing Crosby Theater, 901 W. Sprague Ave. spokaneelitedance.com (509-227-7404) LIVING WINDOW DISPLAY Festival Dance Academy students ages 4-14 pose and perform in costume for a “living window” display, with holiday music and hot cocoa. Dec. 4 from 6-8 pm. Free. Downtown Moscow. festivaldance. org (208-883-3267) THE NUTCRACKER Ballet performed by the State Street Ballet, and musical score by the Spokane Symphony. Dec. 5-8, times vary. $25-$75. The Fox, 1001 W. Sprague. (624-1200) SPORTS SPOKANE BADMINTON CLUB Meets Sundays from 4:30-7 pm and Wednesdays from 7-10 pm. $6/visit. West Central Community Center, 1603 N. Belt St. wccc.myspokane.net (448-5694) SPOKANE TABLE TENNIS Ping-pong club meets Mon and Wed from 7-9:30 pm; Sat from 1-4 pm. $2/visit. North Park Racquet Club, 8121 N. Division St. spokanetabletennis.com (768-1780) SPOKANE TABLE TENNIS CLUB Pingpong club meets Wed from 6:30-9 pm and Sun from 1:30-4 pm. $2/visit. Southside Senior & Community Center, 3151 E. 27th Ave. sssac.org (456-3581) BRRC TURKEY TROT A fun run/walk to raise money and food donations for Second Harvest Food Bank. Nov. 28 at 9 am. Entry by donation. Manito Park, 1800 S. Grand Blvd. (868-6433) SKI INSTRUCTOR CLINIC Aspiring instructors can partcipate in a two-day clinic taught by professionals. Nov. 2930. Lookout Pass Ski & Recreation Area, I-90. skilookout.com (208-774-1301) VILLAGE LIGHTING CEREMONY The holiday season begins with a visit from Santa, hot cider, Christmas carols, a craft bazaar and more. A toy drive benefiting Toys for Tots also takes place. Nov. 30. Silver Mountain Ski Resort, 610 Bunker Ave., Kellogg, Idaho. silvermt. com (866-344-2675) SNOW STOMP First annual snowshoe event. Dec. 7 at 9 am. $40-$110. Mt. Spokane State Park, 26107 N. Mt. Spokane Park Dr. parks.wa.gov (922-6080) WWE LIVE Wrestling matches featuring CM Punk, Randy Orton, Daniel Bryan and others. Dec. 8 at 6 pm. $15-$95. Spokane Arena, 720 W. Mallon Ave. spokanearena.com (279-7000). interplayerstheatre.org (455-7529) THE CHRISTMAS SCHOONER Holiday family musical. Through Dec. 22, ThuSat at 7:30 pm, Sun at 2 pm. $22-$30. Spokane Civic Theatre, 1020 N. Howard St. spokanecivictheatre.com (3252507) A CHRISTMAS CABARET Featuring Ellen Travolta with Mark Cotter and Jack Bannon. Nov. 29-Dec. 21, Thurs-Sat at 7:30 pm, Sun at 5 pm. $20-$25. The Coeur d’Alene Resort, 115 S. Second Ave. achristmascabaret.com (208-4354000) THE CHRISTMAS TOY SHOP Holidaythemed play. Through Dec. 15, show times vary. $10-$12. Spokane Children’s Theatre, 2727 N. Madelia. spokanechildrenstheatre.org (325-4886) A CHRISTMAS CAROL Performance of the classic holiday tale, a collaboration between the U of Idaho Theatre Dept. and the Idaho Repertory Theatre. Dec. 4-7 and 11-14 at 7:30 pm, Dec. 8 and 1415 at 2 pm. $6-$8. University of Idaho Hartung Theater, 709 Deakin Ave., Moscow. (208-885-6111) STAGE II SHORTS Performance of short student-written plays. Dec. 4-5 at 7 pm. Whitworth Cowles Auditorium, 300 W. Hawthorne Ave. whitworth.edu/theatre (777-3707) THOROUGHLY MODERN MILLIE Musical performed by the Lewis & Clark High School Drama Dept. Dec. 5-14, ThursSat at 7 pm. $10. Lewis and Clark High School, 521 W. Fourth Ave. tigerdrama. com (354-7000) VISUAL ARTS GREG ROTH PHOTOGRAPHY “Photography as a Philosophical Question” featuring the SFCC instructor’s work. Through Dec. 11. Free. Spokane Falls Community College, 3410 W. Fort George Wright Dr. (533-3725) HANDMADE ORNAMENT SHOW The annual show features handmade tree ornaments by local artists. Nov. 29-Dec. 1, Fri-Sat from 10 am-6 pm, Sun from 10 am-3 pm. Fridays, Saturdays, 10 am-6 pm and Dec. 1, 10 am-3 pm through Nov. 30 Tinman Gallery, 811 W. Garland Ave. tinmanartworks.com (325-1500) WEST CENTRAL FESTIVAL OF THE ARTS Gallery showcase featuring a variety of Spokane artists’ work including paintings, wood crafts, pottery, jewelry, photography, quilts and more. Dec. 4-20, dates and hours vary. Free. Salem Lutheran Church, 1428 W. Broadway Ave. (328-6260) SMALL ARTWORKS INVITATIONAL The 15th annual exhibition features 39 local/regional artists, and more than 200 new works. Opening reception Dec. 6 from 5-8 pm, show runs through Dec. 31. Free admission. The Art Spirit Gallery, 415 Sherman Ave., CdA. theartspiritgallery.com (208-765-6006) 30-30-30 30 participating artists created 30 works of art over 30 days, with each piece selling for $30 during a oneday exhibition. View art before the sale Dec. 5 from noon-5 pm and Dec. 6 from 8 am-3 pm. Sale on Dec. 6 from 4-7 pm. Third Street Gallery, City Hall, 206 E. Third St., Moscow. (208-883-7036) ART & ARCHITECTURE FACULTY EXHIBIT Annual exhibition featuring work by faculty of the University of Idaho’s College of Art & Architecture in all media and taking all forms. Reception Dec. 6 from 5-8 pm. Runs Dec. 6-Jan. 18, 2014. Prichard Art Gallery, 414 S. Main St., Moscow. (208-885-3586) FIRST FRIDAY Local galleries and businesses display new artwork for the month of December. Dec. 6, most receptions from 5-8 pm. Locations throughout downtown Spokane and beyond. See Inlander.com/FirstFriday for complete listings. WORDS BOOTSLAM All-ages competitive performance poetry. Poets have three minutes per round to present one original poem without the use of costumes, props, or musical accompaniment. Dec. 1 at 7:30 pm. $5. Boots Bakery & Lounge, 24 W. Main. spokanepoetryslam.org AUTHOR JANE CODY The author of “Birthing Eternity” reads from and signs copies of her work. Dec. 3 at 7 pm. Free. Auntie’s, 402 W. Main. (838-0206) AUTHOR KAREN SPEARS ZACHARIAS Reading and signing of the novel “Mother of Rain.” Dec. 5 at 7 pm. Free. Auntie’s, 402 W. Main Ave. (838-0206) AUTHOR PAULA MARIE COOMER The Clarkston, Wash.-based writer and cook will sample dessert recipes from her new cookbook “Blue Moon Vegetarian.” Also featuring music by the Palouse Choral Society. Dec. 5 from 5-8 pm/ Free. BookPeople, 521 S. Main St., Moscow. (208-882-2669) JESS STEVEN HUGHES Book signing by the author of “The Sign of the Eagle.” Dec. 6 from 3-8 pm. Free. Hastings, 1704 W. Wellesley Ave. (327-6008) THREE MINUTE MIC Open mic poetry night hosted by Spokane Poetry Slam’s Isaac Grambo. Dec. 6 at 7 pm. Free. Auntie’s, 402 W. Main. (838-0206) ETC. ARGENTINE TANGO LESSONS Lessons for beginning to advanced dancers. Thursdays, lessons from 7-8 pm, dancing from 8-9 pm. $5. Spokane Women’s Club, 1428 W. 9th Ave. (534-4617) ARTS ANONYMOUS 12-step program for artists to explore, expand and receive support for their work in any media and at all skill levels. Meets Saturdays from 3-4:30 pm. Free. St. Luke’s Rehab Center, 711 S. Cowley. (280-0325) ARGENTINE TANGO LESSONS No experience or partner necessary. Mondays from 7-9 pm $5. Spokane Tango, 2117 E. 37th. spokanetango.com (688-4587) SPOKANE MAGNUSON CLUB MEETING December meeting on the topic of police accountability, including a discussion by local social justice leaders Tim Connor, Liz Moore and Breean Beggs. Dec. 2, 11:30 am. $15. Red Lion Hotel River Inn, 700 North Division Street. (328-9526) ADULTS WITH AUTISM A panel of local adults present their struggles, aspirations and insights into the adult autistic experience. Dec. 3 at 8:30 am. $40. Mukogawa Institute, 4000 W. Randolph Rd. (939-7621) COMPASS CLUB CHRISTMAS LUNCHEON Catered luncheon featuring entertainment by pianist Diane Copeland. Reservations requested. Dec. 3 at 11 am. $20. Manito Country Club, 5303 S. Hatch Rd. (455-7789) SPOKANE MOVES TO AMEND THE CONSTITUTION The local activist group meets on the first Tuesdays of the month (Dec. 3) at 6:30 pm. Donations accepted. Liberty Park Methodist Church, 1526 E. 11th Ave. (844-1776) LIGHTENING THE LOAD OPEN HOUSE The local faith-based hoarding remediation program will open its doors to the public. Dec. 4 at 11:30 am. Free. Lightening the Load, 2702 N. Perry St. lighteningtheload.org (850-3905) HOLIDAY VINTAGE FASHION TEA Holiday-themed tea event featuring a live fashion show of 100 years of Spokane’s vintage fashion history. Dec. 7 at 1 pm. $20. Spokane Woman’s Club, 1428 W. 9th Ave. (466-6677) n Ce rti fic at es M ost Im porta nt person in ! my life - the Greate st Gift of All Lo ve, you r Pe rso na l Sa nta Gi ft To: the . 2607 N. MONROE ST 325-2607 Lenore’s Dream Retro, Vintage, & Mid-Century Modern Furniture, Houshold, Clothing & Jewelry Visit us for - Nov 30th SMALL BUSINESS SATURDAY ANTIQUES & MODERN MID CENTURY GIFTS Furniture to Furs - All you could wish for this Holiday Season 5021 N. Market • 509.241.3651 /lenoresvintagedream for one low price! ONLY $1197 3 P IE C ES FREE DELIVEE T RY IN SPOK BONDED LEATHER! ANE & SPOKANE VALLEY Best Prices in Town!! BUY - SELL - CONSIGN - LOCALLY & ON-LINE • 8511 E. Sprague • 509-851-9321 CONSIGNMENT buy • sell • consign FURNITURE ART GIFTS COLLECTIBLES ANTIQUES JEWELRY TOYS New Owner! Gift Certificates & Layaway 509.290.6569 | 7104 N. Division | Spokane On a Budget? Shop Here first for clothes A COMPLETE LEATHER LIVING ROOM New Rocker Recliner $299 GRAND ESTATE nds Thousas on of itemvery sale e ! day & gifts this Holiday Season! tue-fri 1pm-6pm • sat 12pm-5pm A Neighborhood Ministry of St. John’s Cathedral Service League TUESDAYS ALL SHOES 99¢ Free Coffee! 902 W. Indiana > 509.868.0001 < Mon-Sat 10 - 6pm Global-Neighborhood.org Like us on Facebook! A LOCAL NON-PROFIT ORGANIZATION 1024 S. Perry St, Spokane 534-3888 Antiques, Collectibles, Thrift, Vintage and Consignment Shops Vintage Rabbit Antique Mall Repurposed Items * Antiques and Collectibles Gifts at Reasonable Prices North Idaho’s Consignment Shop for babies, tots, tweens & moms-to-be We have Lots of Vintage Christmas Items! 2317 N. Monroe * 509-326-1884 * Open Daily SMALL BUSINESS SATURDAY NOVEMBER 30TH 740 N Cecil Rd Suite 104, Post Falls, ID (208) 773-7506 | /TraderTots Fashion Recycling 5016 N. Market St. | Spokane 509-483-2647 7 Collectible Cookie Jars 7 Die Cast Cars & Trucks 7 Pins & Broaches 7 Vintage Clothing 7 Creative Gift Ideas Tuesday - Saturday Closed Sun & Mon 9019 E. Euclid Millwood, WA 509.343.3187 @MaggieBreens Tues-Fri: 11am-6pm Sat: 11am-5pm .COM/MAGGIEBREENS NOVEMBER 28, 2013 INLANDER 49 IT’S ALMOST Christmas! SHOP E BLOCK & COME TO TH 0pm] 0am - 5:3 :3 8 [ i. r F Mon. (509) 444-7355 Inlander.com PHONE: BulletinBoard@ it Parkway E-MAIL: 1227 West Summ 1 20 N: IN PERSO Spokane, WA 99 CHAIR FOR LEASE Downtown · Est. 7yrs Fun, Funky, Urban Inspired, Relaxed Professional Atmosphere... Be creative... Express yourself... at Koi Contact Kim at 509.747.3263 or Kimberlee.Douglas@gmail.com Smokers Wanting to Quit Needed The WSU Spokane Sleep Center needs smokers 22-40 willing to quit cold turkey. Earn up to $285. 509-358-7756 for more info. IRB#13177 Christian Science He aling Theodo ra Sallee, Pra 509-481-8585 or 509 ctitioner -723-4671 Psychic Parties Looking for a different and unique theme for your next party? Individual or group readings Tʼs Recyclery House Coeur Coffee MA & Fitness Sovereign M oks Giant Nerd Bo llectibles Time Bomb Co N. The 700 Block of Monroe Street unique, fun and perfectly practical children’s gifts... /Gigglesngifts gigglesngifts.com Apply INLANDER15 for 15% off your first purchase! BUYING Estate contents / household goods. See abesdiscount.com or 509-939-9996 STOREWIDE HOLIDAY SALE Thru Dec 31 E LOOK FOR TH Shop Online And See What’s New! Your guests will be talking about your party for years 509.721.1109 talk2vicki@yahoo.com GET YOUR SIDE INLANDER IN AXELS.COM 509-535-2251 3301 E. Sprague Gift Cards Available presented by Kilgore’s Country Kringle’s Featuring vintage & antique finds, Santas, wreaths, furniture, gifts & more! December 6th, 7th, & 8th Open Daily from 10 - 6 30815 N. Liz Lane, Deer Park, WA ACROSS 1. Get back to 5. Rainy day planner? 9. Seven-time French Open winner Chris 14. Crate & Barrel rival 15. Small: Suffix 16. Where one’s name might go, on a form 17. HBO’s “Real Time” host 19. Gives up 20. ____ bargain 21. Sweet-talk 22. A high concentration of volcanoes allows Iceland to produce a lot of it 27. “I gotta hand ____ ya ...” 28. Number of weeks per annum 29. ‘60s teach-in organizer: Abbr. 30. Vowel sound in “puzzle” 33. Bank nos. 35. Ubiquitous 2013 Internet meme 50 50 INLANDER INLANDER NOVEMBER NOVEMBER 28, 28, 2013 2013 THIS ANSW WEEK’S E PAGE RS ON 53 ... and a hint to each set of circled letters 38. “The Man in the Crow’s Nest” poet T.E. ____ 39. Brief online messages 42. Welcome ____ 45. Sra.’s French counterpart 46. “Don’t go!” 47. Negative result that can’t be undone 53. Get a rise out of? 54. One guilty of pseudologia 55. Loaf on the job 56. She played Hope on “thirtysomething” 61. 1% group 62. Van Halen’s “Live Without ____” 63. Jessica of “Sin City” 64. Darted 65. “The Lucy-____ Comedy Hour” 66. Inits. of warning on an office computer DOWN 1. Bone that’s part of a “cage” 2. Word with jump or bunny 3. Speed: Abbr. 4. Buddy 5. Novelist Zora ____ Hurston 6. Alternative 7. Starting squad 8. ____ Majesty 9. Yosemite peak 10. Old: Sp. 11. Provides funds for 12. Staggered 13. Law enforcement weapons 18. The “60” in “going 60”: Abbr. 21. Overused expression 22. USO audience “HARLEM” 23. Addis Ababa is its capital: Abbr. 24. Texter’s “However ...” 25. Bar mitzvah scroll 26. Part of MLB’s postseason 31. Proclaimed loudly 32. Tracey of sketch comedy 33. Letters in some church names 34. Tad 36. Matter of life and death: Abbr. 37. “At Last” singer James 40. Maestro’s gift 41. One of Beethoven’s nine: Abbr. 42. Not so spicy 43. Pupil surrounder 44. Like “King Lear” 48. Modern party aid 49. Coeur d’____, Idaho 50. 1980s Houston Oilers coach Ed 51. Christine of “Chicago Hope” 52. History text unit 56. Foaming at the mouth 57. Hightailed it 58. “Treasure Island” author’s monogram 59. Org. with a pair of gloves in its logo 60. Witnessed Best Products - Best Prices Ye Olde Optical Shoppe 509-326-3459 RECORD STORE DAY BLACK FRIDAY NOVEMBER 29TH Available at more than 1,000 locations throughout the Inland Northwest. PHONE: (509) 444-SELL EMAIL: sales@inlander.com IN PERSON OR BY MAIL: 1227 West Summit Parkway, Spokane WA 99201 Fall Clean Up - Leaf Weed whacking, shrubRaking, pru snow removal, hauli ning, ng 999-1545 4,000 Holes 11aM-6pM CASH FOR OLD STEREOS 1610 N. Monroe St. 509-868-9022 Pre 1980 Only. Call Today! Cindy Gardner GIVE BLOOD SAVE LIVES Win 4 Tickets $ & 50 Gift Card to Mentoring Coaching Counseling Psychic Readings 509-468-9001 CDA MASSAGE SCHOOL STUDENT MASSAGES 1 HR Swedish - $25 1 HR Deep Tissue - $35 1625 N. 4TH ST. CDA 208.765.1075 cdamassageschool.com with FREE parking INBCSAVES.ORG December 12 - 15 Center INB Performing Arts ane.com BestofBroadwaySpok 1(800)423-0151 Year Round Skinny Dipping (208) 686-8686 GO TO inlander.com/milliondollarquartet Tickets for opening night (Friday, December 12th, 2013), non exchangeable, & not redeemable for cash 2-60 Min/$80 Specializing in: • Deep Tissue • Swedish • Sports • Trigger Point Therapy OFFERING SERVICES FOR: • D.O.T. Physicals • Sports Physicals • Weight Loss • Alternative Herbal Medical Treatment Options Roger Vasquez LMP Feel Like The Luckiest Person in the world. HighlightsSalonAndSpa.com 1414 W. Garland #102 509.280.2161 to advertise: Lic #602890076 BEST MEDICAL CONSULTATION Exp. 12/18/13 CALL TODAy TO SeT uP yOur APPOinTMenT WiTH Our CLiniC. 509-467-1990 bmcmmj.com 624 W. Hastings #18 • Spokane, WA 444-SELL 3004 E FAIRVIEW Lee Apartments BELIEVE IN A CURE FOR CANCER Proceeds from the Believe Shirts support cancer research, treatment, & awareness. visit: CVCTEE.COM Browne's Addition 2 Blks from Cd'A Park/Art Museum, Quiet Ngbrhd, groomed front/back yrds,clean, well maint & managed 1940's bldg. Gar/parking/strg avail.,lndry rm onsite,cats ok! 1br $535 Studio $485 747-1414 3 bdrm 1 & 1/2 bth townhome, water/ sewer/trash paid, dishwasher, w/d, Gar/Fenced backyard, smoking ok outside, but not in apt. No pets, $830, + $700 dep., application fee $35. Call 509-534-4147 Dezana Aman, LMP. Landlords: We’re Here To Help. Not already a member? call (509) 535-1018 or visit our website. Roosevelt Apts Spacious 2br w City View & Super Closet Space $835. Large 1br w City View $685, 1br w Park View $640-$650 Call 747-1414 “Serving Landlords for over 40 years” Specializing in Ashiatsu Oriental Bar Therapy Deep Tissue :: Hot Rock :: Sports :: Relaxation Online Scheduling :: Located Near Huckleberry’s 509.998.0255 ArtOfMassage-Spokane.com MA 60016914 NOVEMBER 28, 2013 INLANDER 51 “Spokane’s Original Gourmet Cupcake Shop” Check out our fall inspired flavors!.com Someone cut you off? Time to let off some steam. You can really let them have it. Place a FREE ad in the Jeers section. I Saw You • You Saw Me • Cheers & Jeers • ISawYou@Inlander.com I Saw You For an upcoming issue, we’re looking for personal stories of real-life experiences involving the I Saw You listings in the Inlander. True love, mishap, missed opportunity — whatever your story, send it to ChrisB@inlander.com with the best way to get in touch. 12 12/31 ARLAND Gtattoo and piercing • LASER TATTOO REMOVAL • TATTOO & BODY PIERCING • BRANDING HOSPITAL GRADE STERILIZATION CALL 509-327-2333 602 w. garland • 52 INLANDER NOVEMBER 28, 2013 I Saw You You Saw Me Cheers Cheers Hayden Super One Foods Me: Black man, you with your 2 kids going through the cheeses and then the yogurt section, couldn’t help but notice how beautiful you are, I said something like “that’s a great idea, some yogurt” You agreed. You seem nice and a patient Mom. I said to one of your daughters “pick the Peach Mango” You said something to them about going to their Fathers on Wednesday. Coffee possible? 54555music@ gmail.com way lets connect and do coffee with cream. cowboydownsouth@ yahoo.com every week I write a cheers to you because you blow me away my love. Every moment, good and bad, has been made infinitely better since you became part of my life. I have fallen so madly in love with every moment we spend together. You are my rock, the one person I can count on to hold my hand and be my friend through the sunny days and the stormy weather. I am so proud of you baby, you have worked so hard to get to where you are in life and I am truly inspired every day by your strength. You make my world such a wonderful place and I am honestly in awe of you. I never knew I could love and be loved so much until you came into my life and changed it forever, true story, for real life lol. I love you honey, dottie mo people actually used this to try and meet others. About a month later, I’m in the breakroom and my coworker grabs the new Inlander and goes straight to the I Saw You section. Suddenly she says, “”Hey, Hank. This sounds like you.”” Sure enough, the description of me standing at the bus stop where I caught the bus every day after work and carrying the violin I played during lunch a couple days a week, was undoubtedly me. The post ended with, “”Let’s make beautiful music together.”” Oh my gosh. I had no idea who it could be, but that’s part of the deal, right? Worse, word spread around not just work, but the entire nine-story building, and soon everybody was asking me questions like, “”Who are you making music with today, Hank?”” I was not about to reply to the post, but the riddle was killing me. In the meantime, the teasing at work is non stop--even from the security guards. I talked about it at home and kept puzzling over it. And then after a few days I remembered something. A couple weeks before the article was posted, I saw the mail sitting on the kitchen counter and there was an envelope from the Inlander. But I was preoccupied at the time and didn’t give it any more thought. Suddenly it all made sense to me. I confronted Kathy and accused her of sending in the post. She laughed, “”Oh, I got you good, didn’t I?”” I had to admit that she did. What a relief to be able to explain to my coworkers that my wife had pranked me. And we’ve been making beautiful music together ever since. McHottie I saw you working at the new McDonald’s on Division. 16 year old maybe, tall, blue eyes, and a cute half smile. Just before I went to order, you left the register to go refill the napkins, and some old guy took my usual oreo McFlurry order. Even though I didn’t need a napkin, I asked you for one and you flashed that gorgeous smile of yours. I would share a McFlurry with you any day. Mr. Skier When I saw you, you took me off my feet. Literally. You took off your helmet and shook that gorgous blond hair of yours. When I made eye contact with those beautiful blue eyes, I lost all control of my snowboard. When I looked up from the icy cold ground, you were staring right at me holding back your laughter. That’s when I realized I actually do know you, Mr. Par 3 boy. Let’s go snowboarding together! Satellite Waiter with the uncommon name. I see you quite often. I try to flirt with you, but I’m not very good at it... Interested in me or not, I think you are marvelous. You Lost Your Cell Phone no lost and found here at the Inlander. Look at Craigs list November 22 listing title is “You lost your smart phone”. Volcano I saw you at the Volcano E-Cig Shop on E. Sprague Ave. on Wednesday, November 21, 2013 at 3:30 pm. You were like a cat. A cat in the hat. You’re not too short, you’re not to tall, but you were by far the fairest of them all! Your long blonde hair and heavenly smile put Jenny McCarthy to shame. I said hi and you smiled. Next time I will go for it and ask for your first name. Sandpoint Yokes Yokes French Vanilla connection. She followed me and I followed her to the creamer section in Yokes in Sandpoint, we took turns flirting with each other until I mentioned I had seen our brand a lot cheaper at another store and you turned and left. I stood there thinking how much I wanted to share everything French with you, creamer, fries, wine, kisses. Thinking you felt the same Taco Del Mar Ok, I’ve seen you working downtown, at Taco Del Mar. You came in from the back, and our eyes met. You had an amazing smile, with perfect eyes, and a calmness to your voice. I felt like, I had known you, for a life time. You are so, my type of girl. You caught me, looking at you several times, and smiled at me. Wish, I had the guts, to do something, other than admire you from a distance. I wish, I knew, everything about you. Frank’s Diner You: striking blonde, nice shape and classy. You move like you know what you’re doing. Me: just a guy whose heart beats TO CONNECT Put a non-identifying email address in your message, like “petals327@yahoo.com” — not “j.smith@comcast.net.” a great deal faster at breakfast. Dinner? Movie? Coffee date? Are you in a relationship now? Do you date? Valley Walmart The girl with long dark brown hair, blue eyes, and black puffy jacket. I work there and was monitoring the self check out one day, you were buying Thanksgiving decorations and salad mixings. Our eyes met and we shared a moment. Are you celebrating the holiday with someone special? Charlie Where are you? I have talked to you a few times, I have been looking for you! Your never home. Let’s talk some more over coffee or drinks. You know where to find me. Cheers Happy Thanksgiving to find a way into your arms would be my wish for this hoilday season. Please know, I love you !! Time Can’t Erase “Mylady” Two years ago the light that is you beamed in to my life. Out of fear on so many levels I pushed you away as hard as I could. You are the most amazing woman I have ever met. I don’t think there has been a day since, that I haven’t regretted the way things turned out or thought of you. I so wish we could, “put the past away”. Either way, I wish you nothing but love and happiness!! My Polka Dotted Love Almost Nickleback! Cheers to Nickle! The things I REALLY love about them are Good music. Good lyrics, even the dirty stuff! They put on a fantastic live show. They have a (roughly) 20 minute drum solo at said live show. I love how much their songs sound alike to me and the lyrics are not that complex, I don't have to think that Not Your Typical Cheers It has been hard when I listen to them. Tight about 8 years I have lived in this Black Shirts! Ryan Peake is cute! town and at times I feel it is 8 years :) I REALLY, REALLY, REALLY want too many. With all of the negativity them to come back to Spokane!! I splashed across headlines, honestly feel that Nickleback has taking over the mindset of most more talent than the Beatles and of us, I feel it may be overdue for some positivity and genuine Rolling Stones combined!! But you know what I love more gratitude. This is a cheers to the than Nickleback? I love the stories community that had my back when that are in this I SAW YOU section I was just starting out my modeling of the Inlander every week. I love career. Years later, national ads, the stories of missed connections international exposure, dozens of that could have been amazing. The magazine prints and covers, and people who are bordering stalkers now VOGUE RUSSIA, you were (it's a fine line). Those people who pay it forward! and the people who have nothing better to do than type a huge rant to get your attention! If you have any amazing stories from the I SAW YOU section, send them to ChrisB@inlander.com because they are going to be doing a story about them. Thanks! Sheri J. is this week’s winner WINNER!! Sweet Music “One summer day a few years, I was reading The Inlander at home when I reached the I Saw You section. I told Kathy, my wife, that one woman I worked with read and commented on these posts during lunch and I couldn’t believe of the “Say it Sweet” promotion! Send in your CHEERS so you too can be entered to win 1 dozen all there to not just lend helping hands, but loving hearts. Ronnie Ryno at Glamarita, Mary Tafuri of Tafuri Studios, Douglas and Amy Mccoy, Bobby Wilkins, Renee OrNay (Parkins), Sonny Moeckel, Sonna Brado, Zoe Boysen, Nick Henderson, the lovely people at Spokane CDA Women’s magazine, Jen Harvey, Alexi Sage, The Inlander (for my cover SO many thanks to you for going above and beyond the call of duty when my second family- family members, Amy and Douglas, had the unfortunate event of being robbed and having their hearts broken. You have restored my faith in humanity. My heart swells with joy when I think about all you did for them and cannot thank you enough. They share a place in my heart that cannot be touched by anyone else. Thank you, also, for the privilege for allowing us to use your salon for channeling our artistic energies in the form of photo shoots and videos! Thank you to the USAF, the members of education and financial aid at Fairchild: my dream of returning to school to pursue my Master’s in Nursing has finally become a reality. There are no words. There are so many more to thank, but mostly, just the communities here, fashion, music, and art, for being an inspiration when the clouds are grey. My dreams may be larger than this city, but now this city has a part of my heart all it’s own. Lack of Manners You: 5’9” man, dark hair, late 30’s in business attire. Me: 5’3” woman, late 50’s, crippled hunched stature with a cane. Last Tuesday afternoon around 4:00pm while both exiting the 5-Mile Numerica branch, you fell in right behind me and let me get the door for you. When we reached the second door of the vapor lock exit, I had much difficulty opening that door, rocking it back and forth, finally I turned around to push with my back side, using all of my weight and cane for leverage. I said to you “It’ll take a sec, but I should be able to get it,” and you replied, “NOOOOOO problem,” and waited until I was finally able to push open that door for us. Fortunately for you, you must have never been injured, diminished or put into a disability condition to know how hard it may be just to take care of yourself. Unfortunately for you, that if that time may come for you, and you find yourself in a situation that the easiest of tasks become quite difficult, I hope you can still say “NOOOOOO problem”, and mean it, because I may not be around to open your doors for you that day. law enforcement know and ticket will be written. Protecting our children is always a persons first adult thought. More parents should raise cain. RE: Disgusting To the person complaining on students standing in school buses. My wife was a school bus driver and it is against the rules/laws. My wife says to get the bus number and times and let Picture Taking Shame on the employee at Spokane Arena last night, ejected for taking pictures at the concert last night. Because I was in a wheelchair and couldn’t run and hide, while everyone around me is doing the same thing! This is the 21st century, everyone has a cell and is recording (the Knitting Factory does not care nor any other venue that I know of) I am not going to post it or sell it. Almost everyone there was recording or taking snaps. But people can smoke cigarettes and weed in a non smoking building, but I can’t take pics of the concert? (and no I was not using a flash) I recorded the entire incident, so if there is an attorney out there hit me up! Because there is nothing on the ticket, nothing posted, nothing said over the intercom about this. Dude! Ya it was a good idea to buy my husband a rocket for his birthday. But dude, really? You go into such detail about what engine to buy and which rocket to choose, but you left out the 9 volt battery WTF? To donate: Visit us at or call 328-8100 Valley - 509.922.5052 11618 E. Sprague Ave. North - 509.465.5052 7015 N. Division St. FlaminJoesWings.com HOME OF THE 2 FOR $20 SPECIAL When you see this icon you’ll know you’re supporting a local business. HARLEM Hours: Mon-Sat 9am-7pm "You gave me butterflies. floors, ceramic tile. New carpet, granite counter tops, charming wood burning fireplace. I dream of opening the French doors that lead to the deck where we will be entertaining friends, the private backyard & hot tub for those quiet nights. Meet me by the community pool and we will connect." ’S THIS WEEK! S R E ANSW 1-800-720-6008 EXT 2459 509-868-9181 NOVEMBER 28, 2013 INLANDER 53 The Case for Being Alone Keep in mind: Alone doesn’t mean lonely BY SCOTT A. LEADINGHAM 54 INLANDER NOVEMBER 28, 2013. n NOVEMBER 28, 2013 INLANDER 55 NOVEMBER 30 TH 4:30 PM • DOORS OPEN & FLUTE MUSIC BY DALE YOUNG 5 PM • WINTER BLESSING BEGINS Join us for an evening of friendship and sharing CEO Welcome: Dave Matheson Winter Blessing: Story & Prayer Traditional Native American Performances $10,000 Charity Giveaway Complimentary Fry Bread and Huckleberry Jam Fireworks | http://issuu.com/theinlander/docs/inlander_11-28-2013 | CC-MAIN-2015-40 | refinedweb | 35,508 | 65.83 |
Many apps today need to store data locally on the device they are running on in order to allow the user to continue to perform useful functions while offline or when network connectivity is unreliable.
SQLite is an ideal solution for both simple and complex local data storage requirements. Whether you are storing small sets of data such as user preferences, or large volumes of relational data, SQLite can work for you.
In this article, I am going to cover how to simplify your local data storage using the SQLite-net library.
Choosing the right storage solution
When choosing a solution for storing data locally on a device there are a number of considerations that you’ll need to make.
For a start, your options are usually somewhat constrained by the type of application you are developing and what operating systems you intend to support, amongst other things.
For an enterprise .NET desktop app, a replicated SQL Server instance may be best. For a web app that has simple data requirements, Session Storage or Local Storage may be the most sensible choice.
If your application is running natively on a mobile device as a Xamarin app you have a number of options such as the Preferences API or your own local data files. However, I believe that SQLite is one of the best choices that you can make.
SQLite is a full relational database and is appropriate for storing large amounts of data.
It works really nicely for local data storage as it is lightweight, platform-independent, and no server process is needed. SQLite works directly with local database files and doesn’t require a centralised server.
I think that the official SQLite website sums it up very well in the following words.
Small. Fast. Reliable.
Choose any three.
Given the aforementioned advantages, SQLite can be a great local data storage solution for a wide variety of scenarios.
Choosing the right library
Once you’re settled that SQLite is the most appropriate local data storage choice for your project, the next thing to consider is the library that you will use to interact with the SQLite database.
There are many SQLite libraries available for all of the most popular programming languages, including Python, Java, JavaScript, and C#. In short, regardless of your chosen language or development environment, you’ll find that there are SQLite libraries available to you.
In this section, I am focusing on the available methods for interacting with SQLite using .NET specifically.
System.Data.SQLite
System.Data.SQLite is one of the oldest, most mature .NET SQLite libraries.
It was originally created by Robert Simpson back in 2005. However, since 2010, the SQLite team have taken over the development and maintenance of the project and it is still actively maintained.
New versions of System.Data.SQLite are usually released within 2-3 weeks of the core SQLite library, so it’s comforting to know that you’re using a library that is always up to date.
In my experience, I have found the System.Data.SQLite library to be a very robust, fast library and it feels very familiar if you’ve ever used the System.Data.SqlClient library for interacting with SQL Server.
Microsoft.Data.SQLite
Microsoft.Data.SQLite is a more recent SQLite library developed by Microsoft.
It was created by the Entity Framework team and the initial version was released in 2016. The library is regularly updated by Microsoft with version 6 of the library being worked on at the time of writing.
Microsoft.Data.SQLite was designed to be a lightweight implementation that aligns with the goals of .NET Core and the reunification of .NET into a modern, cross-platform set of libraries. However, it is important to note that System.Data.SQLite has since been ported over to work with .NET Core/Standard. Despite this, the original goal of Microsoft.Data.SQLite remains, which is to offer a lightweight, modern implementation.
Microsoft.Data.SQLite is a nicely designed library in my estimation. However, I have previously found that System.Data.SQLite offers better performance compared to Microsoft.Data.SQLite (despite Microsoft.Data.SQLite supposedly being more lightweight) which dissuaded me from considering it at the time.
Note that the performance situation may have changed so it may still be worth checking out Microsoft.Data.SQLite as improvements have been made in more recent versions.
SQLite-net
SQLite-net is a modern, cross-platform SQLite library developed by Frank A. Krueger.
The original PCL version of SQLite-net was first released in 2015 and is regularly updated, both by the original author and by a sizable number of community contributions.
SQLite-net is a minimalistic library that provides basic ORM (Object-Relation Mapping) features for .NET and Mono application developers.
The library is recommended by the Xamarin team for accessing SQLite databases on mobile devices.
I think that the following bullet points which are taken from the SQLite-net GitHub ReadMe sum up the key benefits of the library very well.
-
Very easy to integrate with existing projects and runs on all the .NET platforms.
-
Thin wrapper over SQLite that is fast and efficient. .)
Having used the library myself I can vouch for how nice it is to use and I have found it to be highly performant.
It also has a number of really cool features that I will cover in the following sections.
Using SQLite-net
To get started you’ll need to install the SQLite-net-pcl NuGet package into your project.
Don’t let the fact that the NuGet package has ‘PCL’ in the name cause any confusion. The library is platform-independent and works across a variety of project types, including .NET Core/Standard libraries.
Note that you will need to install the NuGet package into both the library containing your data layer logic, as well as the host project that calls into said library.
Making a connection
After installing SQLite-net into your project/projects you can start off by setting up a connection to a SQLite database file.
Below is an example of how to do this.
string baseDataDirectory = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "JC", "LocalDataStorage", "Data"); string databaseName = "TodosAppDb"; var database = new SQLiteConnection(Path.Combine(baseDataDirectory, databaseName));
The
SQLiteConnection constructor takes the path to the database file as an argument.
The database file itself doesn’t necessarily need to exist at this point, however, the directory containing the database does need to be present on the file system. If the database file doesn’t currently exist, it will be created automatically after the
SQLiteConnection constructor has executed.
Note that alternatively, you can create a
SQLiteAsyncConnection object which exposes an asynchronous API. The asynchronous methods use the Task Parallel Library (TPL) underneath and can improve performance when you need to scale things up.
Creating tables
If you don’t already have an existing SQLite database to work with, you can use SQLite-net to create the tables needed to store your local data.
One of the really cool things about SQLite-net is its ability to migrate your database schema for you.
All of this happens automatically without you having to think about the individual migrations.
As part of its ORM capabilities, SQLite-net is able to bind app models to database tables. Below is an example of a C# model class that can be mapped to a SQLite database table by SQLite-net.
/// <summary> /// Represents a local 'Todo' item. /// </summary> [Table("Todos")] public class LocalTodo { #region Properties /// <summary> /// The unique ID of the Todo item. /// </summary> [PrimaryKey, AutoIncrement] public int Id { get; set; } /// <summary> /// The ID of the User the Todo item is assigned to. /// </summary> public int UserId { get; set; } /// <summary> /// The Title/Description of the Todo item. /// </summary> public string Title { get; set; } /// <summary> /// Whether or not the Todo item has been completed. /// </summary> public bool Completed { get; set; } #endregion #region Methods /// <summary> /// Overrides the standard 'ToString' method with the Title of the Todo. /// </summary> /// <returns>The Title of the Todo with a prefix</returns> public override string ToString() => $"Title: {Title}"; #endregion }
The above class is just a plain old C# class with some attributes that are specific to SQLite-net.
Note that all of the get/set properties will be automatically mapped. You can use the
Ignore attribute if you want to exclude a specific property from being mapped as a column.
The
Table attribute is used to specify a custom name for the database table.
The
PrimaryKey and
AutoIncrement attributes configure the
Id column to be the primary key for the table and automatically increment the value of the column whenever a new row is inserted into the table.
Given the above
LocalTodo class, the following line of code will automatically create a ‘Todos’ table in the SQLite database if it doesn’t already exist.
database.CreateTable<LocalTodo>();
The creation of database tables can be centralised into a method, as follows.
/// <summary> /// Static method to allow local data services to initialise their associated database conveniently. /// </summary> /// <param name="database">The SQLite database connection</param> /// <param name="databaseName">The SQLite database name</param> /// <param name="tables">The SQLite database tables to create (if required)</param> /// <returns>An initialised SQLite database connection</returns> public static SQLiteConnection InitializeLocalDatabase(SQLiteConnection database, string databaseName, params Type[] tables) { if (database == null) { if (!Directory.Exists(BaseDataDirectory)) Directory.CreateDirectory(BaseDataDirectory); database = new SQLiteConnection(Path.Combine(BaseDataDirectory, databaseName)); } database.CreateTables(CreateFlags.None, tables); return database; }
Note that in the above example,
BaseDataDirectory is a class-level read-only/constant value.
This method can then be called as follows.
_database = InitializeLocalDatabase(_database, LocalDatabaseName, typeof(LocalTodo), typeof(LocalUser));
Note that in the above example,
_database is a class-level field.
As you can see from the above code samples, the
InitializeLocalDatabase method takes care of checking if the database has already been initialised and also creates the directory for the database file, if required.
The
CreateTables method is used to create multiple database tables at the same time.
I recommend that you initialise your local database connection as soon as possible after your app starts up so that the database will be available to any code that needs to access it.
Inserting records
Now that your database and tables have been initialised, you’re now ready to begin inserting records.
SQLite-net makes it really easy to insert records using entities.
Here’s a quick example.
var newTodo = new LocalTodo { Title = "Buy milk", UserId = 1 }; database.Insert(newTodo);
As you can see from the above code, SQLite-net provides a very simple to understand abstraction over SQLite and will automatically create the necessary SQLite command required to insert the appropriate record into the database.
Getting records
Querying a database to retrieve records based on specified criteria is typically where an ORM becomes really useful and this is where SQLite-net really shines.
The
Table method returns a queryable interface that is able to translate
Where,
OrderBy, and
Take queries into the native SQL that the SQLite database engine understands.
Here is an example that gets a collection of Todo records from the database.
var todos = database.Table<LocalTodo>() .OrderBy(t => t.Title) .ToList();
The above code gets all of the records from the ‘Todos’ table ordered by the ‘Title’ column and then uses LINQ to convert the records into a list of
LocalTodo objects that we can work with.
Getting an individual record
To get an individual record we can use the
Find method and either pass in the primary key value or a predicate, as per the following code sample.
int id = 1; var myTodo = database.Find<LocalTodo>(id);
int userId = 1;
var buyTodo = database.Find<LocalTodo>(t => t.Title.StartsWith("Buy") && t.UserId == userId);
Note that I recommend you always use the
Find method when looking for an individual record. You could instead use the
Where method in combination with
FirstOrDefault, however, this will potentially return multiple rows from the SQLite database which then have to be filtered in-memory using LINQ.
Updating records
Updating records is similar to inserting records.
Following on from the previous code sample, let’s update a property of the
myTodo object and then use the
Update method to update the associated record in the database.
myTodo.Completed = true; database.Update(myTodo);
Note that the database table must have a primary key in order to update records in this way.
Deleting records
You can pass in either the primary key or the object to delete to the
Delete method in order to remove a record from the database.
Below is an example of how to do this.
int rowsDeleted = database.Delete(myTodo);
The
DeleteAll method can also be used to remove all records from a specific database table.
Custom queries
One of the things I love about SQLite-net is that it not only provides a really neat set of methods for interacting with database records at a high level, but it also gives you the ability to issue raw SQL queries and commands in a safe way using parameters whenever you need to.
Below is an example of a simply SELECT query.
var filteredTodos = database.Query<LocalTodo>( "SELECT * FROM Todos WHERE UserId = ? ORDER BY Title", userId);
SQLite-net is still able to help us out here by automatically mapping the results to the custom query to the
LocalTodo object.
Question mark characters are used to represent positional SQL parameter values and you can specify as many as needed to fulfill the query requirements.
Custom commands
In addition to custom SQL queries to retrieve records, you can also execute ad-hoc queries to insert or update records, and you can issue SQLite-specific commands too.
Below are a couple of examples for reference.
int modifiedRows = database.Execute("UPDATE Todos SET Completed = 1 WHERE UserId = ?", userId); var shrinkCommand = database.CreateCommand("vacuum"); shrinkCommand.ExecuteNonQuery();
The first line of code updates all Todo records to ‘Completed’ for the specified User ID.
The second part of the code executes the ‘vacuum’ command which is a SQLite-specific command which shrinks the database file to free up unused space.
Transactions
SQLite supports database transactions and SQLite-net provides a really neat way to implement these.
See the code sample below.
database.RunInTransaction(() => { database.DeleteAll<LocalTodo>(); database.InsertAll(todos); });
Any database commands that are issued within the Action that is executed by the
RunInTransaction method are all run in the context of a SQLite transaction. This means that all of the database commands will either be committed or they will all be rolled back if one of them fails for any reason.
Creating a service layer
When implementing local data storage for your app, it’s usually a good idea to introduce a layer of abstraction.
I recommend creating an interface similar to the following.
public interface ILocalDataServices { void Initialize(); LocalTodo CreateTodo(LocalTodo todo); LocalTodo GetTodo(int id); }
You can then implement a concrete implementation class e.g.
SQLiteDataServices and implement the methods you need for your specific project.
With an abstraction like this in place, you can separate your local data access logic from the rest of your application and potentially swap out the underlying implementation to use a different SQLite library, or even a different local data storage system, if required.
Of course, using an interface also helps with unit testing and with dependency injection.
If you are developing a .NET desktop app or Xamarin app, I recommend using TinyIoC – “an easy to use, hassle free, Inversion of Control Container” (as per the GitHub ReadMe).
Typical scenarios
As stated near the beginning of the article, allowing the user to work offline or when network connectivity is poor are typical examples of why you would employ a local data storage solution for your app.
In these situations, your software will either operate offline by default and upload data to a server whenever a network connection is available, or the code will fall back to local database access if an API call fails due to a poor connection.
As an example, for a Xamarin project, you can use code that is similar to the following to check if you have a network connection.
if (Connectivity.NetworkAccess == NetworkAccess.None) { // Use local cache. }
Note that for native Android apps your app will need the ACCESS_WIFI_STATE permission in order for the above code to work.
Caching is another common reason to use local data storage. If you can avoid expensive API calls and provide a faster experience for your users you are sure to get better feedback from your user base.
A simple implementation of caching would be to store a cache expiration date/time value after retrieving data from an API and then use data from the local database (i.e. cache) until the cache period has expired.
if (_cacheExpiration == null || _cacheExpiration.Value < DateTime.UtcNow.AddMinutes(-1)) { // Cache period expired - call API. }
Of course, you can make this more sophisticated according to your requirements and potentially use a caching framework should your requirements become more complex.
Tools
While in the process of developing an app that connects to a SQLite database, it can be very useful to view the schema and contents of the database visually as you go along.
I highly recommend SQLite Browser. It is free and works on both Windows and Mac.
SQLite Browser allows you to create new databases and open existing databases.
It allows you to create and amend your database schema and you can view and edit data quickly and easily.
You can also execute SQL queries and view the results and it comes with a number of other features which you will find useful while developing your app.
Summary
In this article, I have covered how to implement local data storage for your app using SQLite.
I’ve utilised the SQLite-net library via the SQLite-net-pcl NuGet package to simplify the interaction with the local database and I’ve demonstrated how to get started with its usage.
In the final sections, I have made some recommendations regarding how to abstract your local data storage code and typical scenarios where having a local data storage system proves to be useful.
Lastly, I’ve introduced you to SQLite Browser which is an invaluable tool that helps you to view and edit your local data in a visual manner.
I hope you enjoyed this post! Comments are always welcome and I respond to all questions.
If you like my content and it helped you out, please check out the button below 🙂 | https://jonathancrozier.com/blog/simplify-your-local-data-storage-with-sqlite-net | CC-MAIN-2021-49 | refinedweb | 3,086 | 54.32 |
GDSL Awesomeness – Delegating Closure Calls
hi,
Very often we use delegates in our closure calls. It would be great if we could get code-hinting in the closure via the delegates.
Now let us take a very simple scenario, where we made a method “with” which delegates the delegate objet to closure and runs it.
[java]
class Delegator {
static def runWith(obj, Closure cl) {
cl.delegate = obj
cl.call()
}
}
Delegator.runWith(new MyDelegate()) {
myDelegateMethod()
def prop = myDlegateProperty
// And so on we can access delegate’s assets
}
[/java]
Now we want out IDE to give us syntax-hint inside the closure for delegate’s methods and properties,
This can be achieved by using the following GDSL script:
[java]
//Get the context for all closures
def ctx = context(scope: closureScope())
contributor(ctx, {
//See if closure is called within method "runWith"
def call = enclosingCall("runWith")
if (call) {
//Get the method object of the closure call
def method = call.bind()
//Get class containing that calling method.
def clazz = method?.containingClass
if ("Delegator".equals(clazz?.qualName)) {
//Delegate the closure to the object passed as the first argument.
delegatesTo(call.arguments[0])
}
}
})
[/java]
Hurray! now we have syntax completion for delegate’s assets in our closure.
Thanks for sharing, this is a fantastic blog. Much obliged.
Some genuinely interesting details you have written.Helped me a lot, just what I was looking for : D. | https://www.tothenew.com/blog/gdsl-awesomeness-delegating-closure-calls | CC-MAIN-2022-21 | refinedweb | 228 | 57.57 |
This Cyber Monday Tuts+ courses will be reduced to just $3 (usually $15). Don't miss out.
The web development community received some big news recently. While not yet in the nightlies, experimentations are, once again, underway, which will, if successful, provide us with native support for CSS variables, mixins, and modules in browsers. The question is, though, is this a good thing?
Pros
- Maintain projects easier
- Write less "code"
- More streamlined integration with JavaScript
- Update site-wide settings and params with a single value change
Cons
- Should CSS be complicated?
- Higher barrier of entry for designers
- The current proposed syntax will seem too confusing for some
How Does it Work?
Before we progress, keep in mind that these developments are still only in the experimental stages. They have not been implemented in any browser just yet.
If you're modestly familiar with CSS preprocessors, like Less or SASS, you'll have a basic understand of what to expect from these additions. (That said, the proposed syntax unfortunately is a bit different.) In the future, you'll have the ability to create variables (global and local), and mixins, which you can think of as a collection of stylings that can easily be referenced.
What Took So Long?
As long as I can remember, the community has been clamoring for CSS variables; so what was the hold-up? In a word: disagreement. In fact, back in 2008, webkit was toying around with this feature -- even to the point of implementing it into the nightlies -- though, the proposal stalled not long after. Many felt that morphing CSS into a more programmer-like language would only introduce frustration; some even felt that it might confuse designers. For example, if the primary color in your project is stored within a variable -- presumably at the top of your stylesheet -- it would then require the designer to refer to two locations.
@myColor : red;
/* Less syntax */ #someElem { color: @myColor; }
While this argument is valid to some extent, it doesn't hold much weight. Most designers maintain a set of site-colors at the top of their stylesheet, which they use for reference. Introducing variables to contain these values is a logical solution.
The Proposed Syntax
Less or SASS fans will be accustomed to defining variables like so:
/* Less */ @primary_color : red; /* SASS */ $primary_color : red;
The proposed syntax complicates things a bit by making variables typed. For instance:
/* Declaration */ @var primary_color color red; /* Usage */ body { color: var(primary_color); }
Worth Noting
- All variables are prefaced with
@var
- Variables are typed. Note the use of the
colorkeyword in the code above.
- To access the value of this variable, we use the
varfunction, and pass in the variable name.
I must admit: it does seems a bit redundant to use the
@var directive. The syntax that SASS and Less uses seems more appropriate and cleaner.
@myVar is more succinct than
@var myVar.
Variables types are a welcomed addition, on the other hand.
Variables are typed. Every primitive value type, every property, and a few extra convenience types exist. This lets us expose the new CSSOM stuff on them:
document.styleSheets[0].vars['primary_color'].alpha = .5;
-- xanthir.com
Local Variables
Variables will also have the ability to be scoped to a declaration box, via the use of the
@local directive. This can be useful when a variable only needs to be used once or twice within a project.
.box { /* Declaration */ @local box_gradient background linear-gradient(top, black, white); /* Usage */ background: var(box_gradient); }
Mix-ins
Mix-ins can be incredibly helpful. In fact, we covered the process of creating a class file of mix-ins not long ago on Nettuts+. You can read about it here -- though keep in mind that the technique(s) presented in that article rely on on the Less preprocessor. The new experiments, again, use a slightly different syntax.
/* Less */ .border-radius( @radius: 3px ) { -webkit-border-radius: @radius; -moz-border-radius: @radius; border-radius: @radius; } /* SASS */ @mixin border-radius($radius: 3px) { -webkit-border-radius: $radius; -moz-border-radius: $radius; border-radius: $radius; } /* And possibly the native solution?? */ @mixin border-radius(radius length 3px) { -webkit-border-radius: var(radius); -moz-border-radius: var(radius); border-radius: var(radius); }
Note the similarities between SASS and the proposed native solution for mixins. This is due to the fact that members of the SASS team are serving as advisors.
Nesting
As you may be aware, Less and SASS allow you to nest selectors. This can drastically reduce the size of your stylesheets, as it's removes the need to the same selector repeatedly.
/* The current way */ #content { ... } #content p { ... } #content p a { ... } #content p a:hover { ... } /* Less and SASS */ #content { ... p { ... a { ... &:hover { ... } } } } /* And natively?? */ #content { ... @this > p { ... @this > a { ... @this:hover { ... } } } }
While the proposed syntax is more wordy, to its credit, it does have a nice OO-like syntax, which will make plenty of developers feel right at home.
But remember - not all designers are developers.
Namespacing
By default in Less, all variables are -- for all intents and purposes -- global. As a result, it becomes difficult to distribute code, as existing variable names can be over-written. The potential native solution will be to implement modules, or namespaces. They can then be included in a block by adding the
@use directive.
@module Site { @var primary_color color #292929; @var secondary_color color blue; @mixin border-radius(radius length 3px) { ... border-radius: 3px; } } /* Incorrect Usage */ body { color: var(primary_color); // Variable name is undefined } /* Correct */ body { @use Site; color: var(primary_color); // #292929 (Works) }
Conclusion
As noted at the beginning of this article, the documentation listed above is still in the experimental stages. It's possible -- likely even -- that the syntax will change, based upon your feedback. So let's have it. Does the idea of native variables in mixins in your CSS excite you...or scare you?
Me? Well I'm for it. I think the proposed syntax could use a bit of work, as it will no doubt scare away the designers among us. That said, if the syntax was simplified a bit, I'm 100% on board. How about you?
| http://code.tutsplus.com/articles/native-css-variables-welcomed-addition-or-huge-mistake--net-17617 | CC-MAIN-2014-49 | refinedweb | 1,015 | 56.15 |
Why).
I’ve seen a lot of technologies come and go over the years so I’m always a little skeptical when a major shift is announced by a company. After many years of seeing promises made and later broken in the technology world (think back to Longhorn for a fairly recent example), I’ve become a bit hardened and generally view new announcements with an air of suspicion. The exception would be the announcement of the .NET framework and C# language that I heard about while attending an author’s summit at Microsoft back in 2000 and the releases of a few key technologies such as ASP.NET MVC, LINQ, and Silverlight. Aside from those technologies, there hasn’t been anything earth shattering or exciting released (in my opinion) especially when it comes to consumers.
With the announcement of Windows 8 I’m excited and so are a lot of other developers that I talked with at the BUILD conference. Do I know how it will all play out and if it’ll be successful? Since my crystal ball broke the obvious answer is “no”. But, I think the story is compelling from a consumer and developer standpoint and that things are moving in the right direction overall. Before BUILD started I was hoping that a fraction of the rumors floating around about Windows 8 were true and that’d I’d be pleasantly surprised with the direction Microsoft was going. I was really excited when .NET first came out and was hoping to feel that way again. I’ve been happy with Microsoft’s enterprise story to this point but have definitely been worried about their consumer adoption story. I was really looking forward to what Steven Sinofsky had to say at the keynote (I had breakfast with friends and arrived right before it started – the cheap seats weren’t bad though):
There was definitely a buzz in the room as the keynote started. Although things started out a little slow, excitement really picked up steam once Steven Sinofsky introduced Antoine Leblonde who showed how Windows 8 Metro applications could be built, and Mike Anguilo who walked through different hardware options. The different demos and devices they showed got me excited all over again about what the future holds and not because they gave everyone a new Samsung tablet (although that helped :-)):
I came away from BUILD feeling good about things so I thought I’d write about the specific things that get me excited about the future of Windows 8.
What’s all the Excitement About?
So why am I excited about Windows 8? Those who follow me on Twitter or read my blog may be surprised to know that it’s not just about the technology Microsoft announced. There are a few different reasons I’m excited including the simplicity Windows 8 offers for consumers, Metro application development options, support for different form factors, support for traditional Windows applications and the upcoming Metro app store. Let me walk through some of these points in more detail starting with why I think the new Metro interface provides much needed simplicity for consumers.
Consumers Like Simplicity
I have a general benchmark I follow called the “Mom Test”. If my Mom can’t pick up a new consumer technology quickly then it should be thought out better. Windows 8 represents the first time Microsoft has announced a technology that I think even my Mom can get excited about and understand immediately with little to no training. She navigates around traditional Windows applications fine, but tends to avoid things she’s unsure of. Those of us who grew up with computers don’t feel intimidated when a lot of menus and options are shown on a screen, but that’s not the case for a lot of people and something we as developers need to keep in mind. The popularity of the iPad really highlights the “Mom Test” since my Mom was able to pick one up and use it immediately without having to ask a lot of questions. It’s intuitive by default.
Windows 8 Metro-style applications eliminate much of the complexity associated with traditional Windows applications by focusing on what the user wants to see using intuitive interface concepts. Metro applications even avoid forcing users to think about closing applications when they’re done. Due to the life-cycle management features of Windows 8, applications can automatically be frozen as a user leaves them and be thawed when they revisit the app. This is extremely important and critical for consumer adoption, especially in today’s world. An example of a Metro application that displays weather information is shown next. Although it’s very simple, it highlights the important data people want to see and adds appealing visuals.
Here’s an example of the Metro browser in action. Notice that there are no toolbars, status bars, tabs, etc. While I do think it’ll take users a little time to get used to that type of interface (since the traditional Windows approach is so engrained in many people’s minds), I think it’ll be embraced by people over time.
If a user wants to get to a different tab, type a URL, or perform another action they can right-click on the interface (on a PC) or swipe their finger if they’re on a touch device. Here’s an example of the Metro browser after that type of action has been performed:
This is all the functionality that people need in order to browse. Most people don’t care about getting to Internet Options or accessing other menus to perform more advanced tasks. The full version of the browser is available on the Windows 8 desktop of course. In addition to the simplicity offered by the Metro browser, picking files has been greatly simplified and optimized for touch devices as well:
The tiles in the Windows 8 Metro interface bring a lot to the table as well and go a step above what other platforms offer. Each tile is more than just a simple icon – it can convey information to the end user without forcing them to load the application. Windows Phone 7 first introduced this concept but I like how Windows 8 is keeping the tile format. An example of the Metro tiles in action is shown next:
I think that Metro-style applications and tiles will go a long way toward helping consumer adoption once Windows 8 is released. Although I haven’t shown her yet, I’m confident my Mom will like the new interface and find it easy to use.
Side Note: I’m an Enterprise Developer – Why Should I Care?
The simplicity that Metro applications and tiles bring to the table is really good in my opinion especially since Microsoft is getting hammered in the consumer market right now (and that should concern every Microsoft-centric developer). But, if you only build enterprise applications that won’t be using the Metro framework (WinRT) then why should you care? I tend to build enterprise solutions that target browsers (ASP.NET, HTML5/jQuery, Silverlight, SharePoint) so the client OS doesn’t really matter (Linux, Windows, iOS, etc.) in many cases. Regardless of what happens in the consumer and enterprise markets I can still use ASP.NET and other technologies such as jQuery to build applications. However, consumer preferences tend to find their way into the enterprise environment since most consumers have jobs. Students will eventually get jobs and influence decisions in the enterprise as well. I don’t think it’s hard to come to the conclusion that if consumers continue to move to other technologies that it could impact adoption of Microsoft technologies in the enterprise down the road (especially when it comes to desktop applications). It’s not anything that will happen overnight, but I’d rather have consumers excited to use Microsoft technologies again than continue to flock to other technologies. Whether or not they will be excited about what Windows 8 offers remains to be seen (it’s extremely early at this point), but I’m optimistic and think that Windows 8 is a good thing to “get a little mojo back in Microsoft” as my good friend Ward Bell told me.
Metro Development Options
In addition to what I hope will be positive consumer adoption, Windows 8 provides a developer friendly way to built Metro-style applications that can target a variety of devices through the Windows Runtime (WinRT). Here’s an slide shown at the conference that shows how WinRT fits into the mix:
Whether you’re building Metro applications for the desktop or the variety of Windows 8 tablets that will be released, you’ll be able to build an application once and have it load and display properly. That’s a huge deal and something we simply couldn’t do before without a tremendous amount of work. The Metro interface is also much cleaner, consistent, and consumer friendly and it obviously lends itself well to touch devices.
What’s very exciting is that I can use HTML with JavaScript/CSS or XAML with C#/VB/C++ to build Metro applications. Since I’m heavily invested in both HTML and XAML technologies this means that my existing skills transfer over without having to learn another language. I've heard several people complain about the HTML/JavaScript strategy but I personally think it's genius on Microsoft's part. The entire world knows those technologies so why not allow them to build applications without having to learn a new language? It will hopefully lead to a large number of Metro applications being released which makes the overall Windows 8 OS even more attractive to people since apps are where it's at now days. On a related note, my C++ friends are extremely excited to see that their preferred language is now a major player in the framework and key in specific situations (DirectX integration for example). I’ll blog about the technical side of WinRT soon, but you can read more about it here in the meantime. Several different samples can be downloaded here and run directly on the Windows 8 developer preview.
Device Support
I’m definitely excited about the ability for Metro applications to scale to different resolutions and device sizes. This was an important move Microsoft had to make to get caught up with all of the different tablets and alternative devices that have been released over the past 2 years. As a developer, I can provide different tile sizes, backgrounds, and more and know that my application (if designed using the recommended guidance) will work across many different Windows 8 devices without having to maintain different code bases. I’m hoping Windows Phone 8 will support this development model as well so that a Metro application can be written once and scale to a variety of devices including the phone. Wishful thinking on my part but being able to write an application that would run (and display properly) on the desktop, tablet, and phone would be an amazing development story (although the phone certainly presents some size challenges).
The tools talk given on day 1 of BUILD highlighted the device emulator and tools that Metro application developers will have in Visual Studio and Expression Blend. One of my favorite features was the ability to remotely debug an application on a device such as a tablet. During the talk given by Kieran Mockford and Chris Sells (I had the chance to have dinner with Chris at BUILD - great guy) they showed that feature in action (an example of the emulator is shown below):
The App Store
Building Metro applications is one thing, but getting people to download and install them is another thing entirely. If you’re involved in selling software then you know that marketing and sales are the name of the game if you want to make money. With the installation base Windows has (over 450 million PCs are running Windows 7 according to Microsoft), there’s a massive opportunity for developers to build Metro applications since each Windows 8 machine will have a built-in App Store. It’s hard to say how well developers will do financially building Metro apps (the store isn’t available at this point), but I like the odds given the current number of Windows installations out there.
Support for Traditional Apps
Although I’m excited about the opportunity that Metro applications offer, my business is centered around building traditional Web or Windows applications for enterprise scenarios right now. Windows 8 will support traditional Windows applications built using WPF, support Silverlight applications, Windows Forms, native C++ applications, and more. For business workers, this means that they can continue to use existing line of business (LOB) applications.
I have no idea what the future of WPF or Silverlight is long-term (WPF 4.5 was announced at BUILD and Silverlight 5 is about to be released), but I know that I can still use the same languages and skills that I know now on Windows 8 including .NET and all of its associated technologies. Traditional applications can even call back into the WinRT Metro framework if needed by simply referencing the proper namespace. For other operating systems such as Windows XP, Windows Vista, and Windows 7 it’s business as usual with ASP.NET, Silverlight, WPF or another technology. Telerik’s Todd Anglin (another great guy I met at BUILD) has a nice decision chart that walks through the different options.
Conclusion
I’m excited to see what Microsoft is doing with Windows 8. Although I don't consider myself a "fanboy", I really like what's happening with Windows 8. By supporting Metro and traditional applications with a single operating system it opens up a lot of opportunities and allows support for different devices to become a reality. The new app store should allow individual developers to compete with large development shops just as they do now on other platforms. The future’s bright and I’m looking forward to updated builds that are released by the Windows 8 team. In the near future I’ll dive into WinRT more here on my blog and walk through how Metro applications can be built using HTML and XAML. Until then, follow the steps Scott Hanselman provides to get Windows 8 up and running quickly and easily so that you can start building applications for it. | https://weblogs.asp.net/dwahlin/why-i-m-excited-about-windows-8 | CC-MAIN-2022-05 | refinedweb | 2,419 | 56.29 |
Talk:Osu!
Revision as of 20:32, 23 September 2019 by Svito (talk | contribs) (→On the removal consideration: re, close)
On the removal consideration
Please don't remove this page for the time being.
- Many people run osu! on Linux and there is a lock of proper documentation as most of the information on running it smoothly is scattered over the internet. This page is still a work-in-progress and I planned on adding more information later.
- There are efforts in the AUR to maintain a runnable version of osu!. Of all places, wouldn't it be best to place it here?
- There even is an open source version, which could also be added to make it more like RuneScape, focusing it away from Windows if that's your problem.
Furthermore, given how this game tends to require a more sophisticated setup compared to the average game, the Arch Wiki is an excellent resource to reference those resources. Irunarchbtw (talk) 06:23, 9 September 2019 (UTC)
- You are helping to scatter this information over the internet, see AppDB page regarding Osu! for yourself. Most of stuff there applies to Arch Linux and even has pacman commands.
- It is not a problem that you haven't added more information to article. Problem is you create another source of information that is equally incomplete instead of contribution to AppDB page. If you consider AppDB page incomplete, then help work on it.
- This article does not document open source version, and even if some part of it did, Wine version should have been documented on AppDB.
- This article is most likely will get out of date as soon as you lose interest in it and AppDB will be more complete and up-to-date, like already happened with all Windows software documented on ArchWiki. I doubt anybody is interested in fixing style issues in article that is effectively going away sooner than later. AppDB has no style requirements and will be more fitting. I want to point out again that AppDB exists primarily for purpose of documenting every little bit of running Windows software on Linux. It has test reports, comments, HowTO/Guides. Please just use it.
- I'm going to archive this article according to procedure after week (page content will be accessible anyway from page history), or if you want you can move(rename) it to your user namespace as User:Irunarchbtw/Osu! and do whatever you want with it there.
- -- Svito (talk) 12:37, 9 September 2019 (UTC)
- Ok, I will move the information elsewhere. Irunarchbtw (talk) 21:20, 9 September 2019 (UTC) | https://wiki.archlinux.org/index.php?title=Talk:Osu!&oldid=583762&printable=yes | CC-MAIN-2019-51 | refinedweb | 434 | 62.38 |
I am trying to develop a basic program that takes your name and provides the output in standard format. The problem is that I want the user to have an option of not adding the middle name.
For Example: Carl Mia Austin gives me C. M. Austin but I want that even if the Input is Carl Austin it should give me C. Austin without asking the user if they have a middle name or not.
So, Is there a way or function which could automatically detect that??
#include <stdio.h>
int main(void) {
char first[32], middle[20], last[20];
printf("Enter full name: ");
scanf("%s %s %s", first, middle, last);
printf("Standard name: ");
printf("%c. %c. %s\n", first[0], middle[0], last);
return 0;
}
As currently written,
scanf("%s %s %s", first, middle, last); expects 3 parts to be typed and will wait until the user types them.
You want to read a line of input with
fgets() and scan that for name parts with
sscanf and count how many parts were converted:
#include <stdio.h> int main(void) { char first[32], middle[32], last[32]; char line[32]; printf("Enter full name: "); fflush(stdout); // make sure prompt is output if (fgets(line, sizeof line, stdin)) { // split the line into parts. // all buffers have the same length, no need to protect the `%s` formats *first = *middle = *last = '\0'; switch (sscanf(line, "%s %s %[^\n]", first, middle, last)) { case EOF: // empty line, unlikely but possible if stdin contains '\0' case 0: // no name was input printf("No name\n"); break; case 1: // name has a single part, like Superman printf("Standard name: %s\n", first); strcpy(last, first); *first = '\0'; break; case 2: // name has 2 parts printf("Standard name: %c. %s\n", first[0], middle); strcpy(last, middle); *middle = '\0'; break; case 3: // name has 3 or more parts printf("Standard name: %c. %c. %s\n", first[0], middle[0], last); break; } } return 0; }
Note that names can be a bit more versatile in real life: think of foreign names with multibyte characters, or even simply
William Henry Gates III, also known as Bill Gates. The above code handles the latter, but not this one:
Éléonore de Provence, the young wife of Henry III, King of England, 1223 - 1291. | https://codedump.io/share/eDvPY1PnVE59/1/printing-a-name-in-standard-format | CC-MAIN-2017-34 | refinedweb | 382 | 71.78 |
I was going through some codes for views and noticed the following a lot:
public class FooPanel extends JPanel { private JCheckBox checkBox = null; private JComboBox comboBox = null; ... protected void initView() { checkBox = new JCheckBox(); comboBox = new JComboBox(); } }
Are there any problems associated with initializing fields to null even though they are null w/o you declaring it?
One thing I saw was that 2 instances of an object are created if you initialize to null as follows:
public class FooPanel extends JPanel { private JPanel innerPanel = null; ... protected void initView() { add.(getInnerPanel()); } private JPanel getInnerPanel() { if(innerPanel == null) { innerPanel = new JPanel(); } return innerPanel; } }
In this case, I get 2 innerPanels. Also, what is the convention? Should you write a getWidget() for each widget in a panel? I think those were generated by WindowsBuilder plugin in Eclipse.
Thanks!!
There is no difference whether you assign a field to
null or leave it untouched. The two cases compile to exactly the same thing (see bottom of answer for bytecode).
As for 2 instances being created: I don't see how two would be created. If
innerPanel hasn't been set and is
null, a
JPanel is constructed and stored. If it does exist, it is returned without touching anything. Whatever you do with that is your choice.
Bytecode:
$ cat TestNull.java public class TestNull { public Object obj = null; } $ cat TestBlank.java public class TestBlank { public Object obj; } $ javap -c TestNull Compiled from "TestNull.java" public class TestNull { public java.lang.Object obj; public TestNull(); Code: 0: aload_0 1: invokespecial #1 // super() 4: aload_0 5: aconst_null 6: putfield #2 // obj = null 9: return } $ javap -c TestBlank Compiled from "TestBlank.java" public class TestBlank { public java.lang.Object obj; public TestBlank(); Code: 0: aload_0 1: invokespecial #1 // super() 4: aload_0 5: aconst_null 6: putfield #2 // obj = null 9: return }
null:
There aren't going to be any problems associated with assigning the value
null to a member during declaration (or at times other than declaration). One advantage to this type of assignment is that it makes the code explicit and makes your intention very clear to anyone reading the code later. When a member variable is not assigned a value during declaration, it isn't clear whether the author intended the value to be
null or simply forgot to write the assignment code.
innerPanelinstances
The initial assignment to
null, followed by assigning a value at time of need (as it is done in your code), won't cause 2 instances to be created. It's not clear from the code shown exactly how your
getInnerPanel method is being used, but you may be running into a multi-threaded scenario where 2 threads may be calling
getInnerPanel at about the same time.
In this scenario, you could end up with multiple
innerPanel member assignments (and duplicate construction). It is possible for the first thread to check the value of
innerPanel, find that it is currently
null (thereby entering the associated code within the
if condition), and then run the
JPanel construction and assignment code. If a different thread runs the same code, at about the same time, the second thread may perform the same
innerPanel value check, find that the value is still
null (because the code within the
if condition has not yet performed the construction and assignment), and enter the same construction and assignment code, resulting in multiple construction occurrences.
You could make the
innerPanel access
synchronized, within the
getInnerPanel method, to prevent this from happe | http://www.devsplanet.com/question/35281615 | CC-MAIN-2017-04 | refinedweb | 581 | 51.78 |
NAME
sys/select.h - select types
SYNOPSIS
#include <sys/select.h>
DESCRIPTION
The <sys/select.h> header shall define the timeval structure that includes at least the following members: time_t tv_sec Seconds. suseconds_t tv_usec Microseconds. The time_t and suseconds_t types shall be defined as described in <sys/types.h> . The sigset_t type shall be defined as described in <signal.h> . The timespec structure shall be defined as described in <time.h> . The <sys/select.h> header shall define the fd_set type as a structure.izes the file descriptor set fdset to have zero bits for all file descriptors. If implemented as macros, these may evaluate their arguments more than once, so applications should ensure that the arguments they supply are never expressions with side effects. The following shall be defined as a macro: FD_SETSIZE Maximum number of file descriptors in an fd_set structure. The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided. int pselect(int, fd_set *restrict, fd_set *restrict, fd_set *restrict, const struct timespec *restrict, const sigset_t *restrict); int select(int, fd_set *restrict, fd_set *restrict, fd_set *restrict, struct timeval *restrict); Inclusion of the <sys/select.h> header may make visible all symbols from the headers <signal.h>, <sys/time.h>, and <time.h>. The following sections are informative.
APPLICATION USAGE
None.
RATIONALE
None.
FUTURE DIRECTIONS
None.
SEE ALSO
<signal.h> , <sys/time.h> , <sys/types.h> , <time.h> , the System Interfaces volume of IEEE Std 1003.1-2001, pselect(), . | http://manpages.ubuntu.com/manpages/karmic/man7/sys_select.h.7posix.html | CC-MAIN-2015-11 | refinedweb | 249 | 60.82 |
Note: This article was created based on Flex 2. Minor changes in the description and code may be necessary before it can be applied to Flex 3.
So you've been a Java developer for most, if not all, of your career. You've been writing business logic in your Java classes and you've been creating application interfaces using JSP pages. More recently you may have used JSF (Java Server Faces) and/or Struts to improve things. But have you really succeeded? You are still writing JavaScript code to bring more life to your interface and to make it dynamic. JavaScript also helps you load XML data from the server without a round trip (otherwise known as AJAX). But don't you get the feeling that it's all the same, that nothing is better for you, the developer, or for the end user? Well, if you are asking yourself these questions, then you are in the same state of mind as I was back in the summer of 2004..
So why should any Java developer be interested in integrating Flex into an application? There are several reasons, and I will take a look at them one by one in this article.
One challenge in introducing a developer to a new technology is the learning curve: No one wants to spend hours or days understanding the basics of a new technology. Learning Flex boils down to two things: MXML and ActionScript. If you know JavaScript, and if you know Java, then you know ActionScript. There are minor differences in the syntax, but you won't get stuck. See for example the following ActionScript code:
package demo { public class Person { // class fields private var firstName:String; private var lastName:String; /** * Constructor with parameters */ public function Person(fn:String, ln:String) { firstName = fn; lastName = ln; } /** * Returns the full name of the person, * exposed as a property on the class. * @return the full name */ public function get fullName():String { return firstName + " " + lastName; } } }
With MXML, if you have worked with HTML or any kind of XML document, once again you know MXML. You just have get familiar with the properties of the components; there is great reference documentation for that. I'll let the following example demonstrate the simplicity of MXML:
<?xml version="1.0" encoding="utf-8"?> <mx:Panel xmlns: <mx:FormItem <mx:TextInput </mx:FormItem> <mx:FormItem <mx:TextInput </mx:FormItem> <mx:FormItem <mx:TextInput </mx:FormItem> <mx:ControlBar <mx:Button <mx:Button </mx:ControlBar> </mx:Panel>
From looking at the code, you can see that it's a panel with standard buttons and a form for a typical registration page. Don't forget about CSS! Flex can load and use any CSS file you provide, either at compile-time or runtime.
The languages that Flex uses will be familiar to anyone coming from a Java background. This way, you don't waste everything you have learned over the years, you are only applying it a little differently. It comes down to the old proverb: Everything old is new again.: | http://www.adobe.com/devnet/flex/articles/flex_and_java.html | crawl-002 | refinedweb | 509 | 61.46 |
XMLOpen 2004 took place September 21-23 in Cambridge, England. It brought together a group of XML experts, most from the UK, but others from Europe, the US, Australia, Japan, and elsewhere. The theme, which I set forth in my keynote address was XML and its intersection with open standards and open source. This conference saw an extraordinary amount of smart work and food for thought, and in this article I shall discuss conference proceedings related to topics already discussed in my other developerWorks articles.
Later on in this article I shall offer final observations on topics in XML Hacks, continuing the coverage in my last article in this column.
XML upon the Cam, by punt
Punts are simple, gondola-like boats for navigating the Cam, the calm and stately stream that flows through the campus of one of the world's foremost universities. Those who took a three-day pass on punting to come to the XMLOpen conference (see Resources) heard a lot of doubts expressed about the merits of W3C XML Schema (WXS) and Web services, ambivalence about XPath 2.0 and XQuery, enthusiasm for RELAX NG and ISO DSDL, and advocacy of XML processing through programming languages and frameworks that fall somewhat outside the mainstream. This confluence of concerns was a natural product of the fact that the speakers were drawn from those working at the vanguard of XML tools and techniques.
Rick Jelliffe, creator of Schematron, opened his session by announcing that the XML schema and reporting language had gained enough votes to be ratified as an ISO committee draft standard as part 3 of ISO Document Schema Definition Languages (DSDL): "Rule-based validation" (see Resources). My recent tutorial on Schematron offers an introduction to that useful, soon-to-be standard. With a growing list of implementations, and public realization of the versatility of the language, Schematron was a consistent buzzword at the conference..
A URI scheme for the Semantic Web?
In earlier installments of this column, and in particular "Basic XML and RDF techniques for knowledge management, Part 7", I discussed topics related to the Semantic Web, the W3C's ambitious plan for a next-generation Web where documents are well annotated for meaning and context. Semantic Web technologies use URIs as the basic identifiers of all things being discussed, whether they're computer records, real world objects, or even abstractions. One of the challenges of Semantic Web research is creating a URI that reliably identifies a thing rather than some accidental aspect of it. For example, sometimes when people describe a person in Semantic Web languages, they use the URL of the person's Web home page as a stand-in. But this introduces confusion between descriptions of the actual home page itself and descriptions of the person.
Henry Thompson, a developer, researcher, W3C staffer, and well-known member of the XSL and Schema working groups, proposes to address this problem using a new URI scheme called Web Proper Names. With WPNs, the URI is constructed based on the results of a search on a well-known engine such as Google; the URI includes details of the engine and search terms used, the date and language in which the search was made, the extent to which search results were checked for relevance by a person, and, crucially, the owner or "baptiser" as Thompson calls it -- the person or entity responsible for the name. The baptiser is usually the same as the person who performs the search and checks results.
Here's an example of a WPN. If you wanted to make assertions about a person, you would perform a search on that person's name, and use appropriate terms to narrow down the results so that most are about the person in question. So, if one "Ralph Parker" works in materials engineering and another in medicine, and you wanted to describe the latter, you might specify search terms to omit pages where the word "materials" occurs. One of the search engine results might be the home page of Ralph Parker, which you might have considered using as a URI to represent the person. However, by using a WPN instead you make it clear that what you're describing is not that Web page (nor any of the Web pages returned by your search results), but rather the object that is the main subject of those Web pages. WPNs can be rather long. The following is Thompson's example WPN for the Eiffel Tower:
Note: In the preceding code example, the code normally appears as a single continuous line. In this instance, the lines of code are split into multiple lines for ease of formatting and printing.
As I opined in the Q&A for the talk, the Semantic Web, based on some proponents' claims, may not be a reasonably-sized undertaking, tools that have open source options and are easy enough to learn a proponent of RDF or topic maps.
In the end, Thompson's idea is a very clever one, and I plan to make use of it in less ambitious ways. It seems like a nice way to define and describe topics of interest in a Web log, for example, especially since WPNs can be translated to HTTP URLs that should resolve to Resource Directory Description Language (RDDL) -- see my article on the topic, "Use RDDL with your XML and Web services namespaces."
Sean McGrath has been a longtime advocate of XML pipelines, which he describes as "a way of thinking about systems focusing on dataflows rather than object APIs." XML pipelines are a way of breaking down XML processing projects into small tasks performed by independent and reusable processing stages. For example, you could run an XML file through one stage that renames certain elements, another that adds new lines to text according to a word-wrapping routine, and finally a stage that transforms the document to plain text output. Pipelining is in part the classic divide and conquer approach to problem solving that almost all programmers are familiar with, but rather than thinking of decomposing algorithms into manageable chunks, McGrath and other pipelining proponents advocate focusing on the data and data transforms. He invokes the idea of pioneering software engineer Michael Jackson that all data processing can be boiled down to data flows with respect to time. McGrath argues that Web services and many other established XML processing practices revolve around the shoehorning of the data into fashionable programming techniques of the day, introducing unnecessary complexity. Pipelining restores the very simplicity and versatility that are the hallmarks of XML's success.
McGrath discussed many properties of pipelines, including the relative ease of auditing and debugging, the value of pipeline stage reuse, and the fact that each pipeline stage can be written using whatever programming tools are most practical -- some might use SAX, others DOM, and still others XSLT. He also discussed techniques such as merges and splits between pipeline data flows, and delta schemata -- the practice of using a schema to account for the intermediate data between each pipeline stage. Pipelines have emerged in many different ways in the XML universe, including ISO's DSDL, which uses a pipeline approach to break down the many aspects of XML schema into smaller, independent specifications. XML best practices are still emerging, but many experts agree that pipelines in one form or another are the future of XML processing practice.
Rich and extensible data types
The WXS data types specification (part 2 of WXS overall) is often referenced in other specifications, especially W3C specs, but it is also held up for criticism as an arbitrary and complex set of data types that too often don't align with the specific needs of real-world applications. Jeni Tennison has been working on this problem for some time and has developed Data Type Library Language (DTLL -- see Resources) as a means of specifying custom data types for XML. She was inspired by her observation that data in real XML tends more towards human readability, for presentation rather than processing. This point of view dovetails neatly with that of RELAX NG, and in fact the primary goal of DTLL is to be a means for defining data type libraries for use with RELAX NG. RELAX NG is part 3 of ISO DSDL, and DTLL is the current candidate for "Part 5: Data types."
DTLL allows you to tell the processor how to parse data types by defining regular expressions for breaking them down into important components (for example, the red, blue, and green parts of an RGB color value). You can then express how data types are tested for equality, or their sort order. This allows them to be used naturally in XSLT's
xsl:for-each and other processing settings. DTLL supports inheritance of type components (supertypes) and other features to support modularization and reuse of data type libraries. Overall, this feature set is based on a very thorough analysis of existing uses of data types in common XML vocabularies, including DocBook, XHTML, SVG, MathML, and more -- all covered in my "Survey of XML standards." Tennison has thought through many of the very difficult problems that revolve around binding a textual format such as XML to the many types and systems of often non-textual data that need to be processed (and she admits that some problems remain to be solved). DTLL is still quite new, but given its merits and the backing of ISO, you soon might put it to use for data types that closely fit your processing needs.
I have one more observation to make regarding the book XML Hacks. Hack #92, "Use Elements Instead of Entities to Avoid the 'amp Explosion Problem'",discusses a problem where careless processing leads to unnecessary and confusing text such as "&". This happens when one escapes text that has already been escaped. The solution for the problem given in the book is to use special elements to represent these entities instead, and then replace these with the necessary entities at the end of the processing stage (presumably using pipelines as discussed above). I doubt such a measure is ever necessary. It's important for XML systems to know the source and state of each chunk of text being processed. In particular, systems must keep track of whether or not text has been escaped for XML representation. If they lose track of this, the potential increases for much greater mischief than just redundant entity escaping. If the system does track the source and state of each chunk of text, then the problem described in this hack simply does not occur. I don't agree with the solution given in this section because it complicates processing as a way to compensate for bugs in the processing. It's better to just fix the bugs. If you're using processing pipelines, then the key is in establishing contracts for pipeline inputs and outputs as to whether the data is escaped.
It is gratifying to watch the discipline of XML processing mature, as manifested by the emergence of books such as I've covered in the past few articles, and the quality of conferences such as XMLOpen. The professional conventions and standards being developed in these important times are key to gaining the benefits that have attracted so many to XML. I highly recommend that you participate in this process, and one way is by posting your thoughts and experiences on the Thinking XML discussion forum.
- Participate in the discussion forum.
- Learn more about the XMLOpen Conference, which took place September 21-23, 2004 in Cambridge, UK.
- Check out ISO Document Schema Definition Languages (DSDL). But first browse this article, an overview of the collection of standards that make up DSDL, with some discussion of the progress of each part.
- Read the paper "Web Proper Names: Naming Referents on the Web", by Harry Halpin and Henry S. Thompson, both of the University of Edinburgh.
- Visit the Home page for XML Hacks (edited by Michael Fitzgerald; O'Reilly and Associates, 2004) for a table of contents, 11 sample hacks available freely online, and an errata. You can also order the book at the developerWorks Developer Bookstore.
- Learn more about data types in Part 2 of the W3C XML Schema Recommendation. These are sometimes criticized as being an arbitrary and complex set of data types that too often don't align with the specific needs of real-world applications.
- Take a closer look at Jeni Tennison's Data Type Library Language (DTLL), which specifies custom data types for XML.
- Look around the Schematron home page and resource directory. You can also get a solid background on Schematron with this tutorial by Uche Ogbuji (developerWorks, September 2004).
- Read "Basic XML and RDF techniques for knowledge management, Part 7" (developerWorks, July 2002), an earlier installment of this column that covers the Semantic Web, the W3C's ambitious plan for a next-generation Web where documents are well annotated for meaning and context.
- Read more about Resource Directory Description Language (RDDL) in the author's developerWorks article "Use RDDL with your XML and Web services namespaces" (May 2004).
- standards
- Find more XML resources on the developerWorks XML zone, including previous installments of the Thinking XML column.
-. | http://www.ibm.com/developerworks/xml/library/x-think27.html | crawl-002 | refinedweb | 2,211 | 54.36 |
_out.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/trek/check_out.c,v 1.4 1999/11/30 03:49:44 billf Exp $ * $DragonFly: src/games/trek/check_out.c,v 1.3 2006/09/07 21:19:44 pavalos Exp $ */ # include "trek.h" /* ** CHECK IF A DEVICE IS OUT ** ** The indicated device is checked to see if it is disabled. If ** it is, an attempt is made to use the starbase device. If both ** of these fails, it returns non-zero (device is REALLY out), ** otherwise it returns zero (I can get to it somehow). ** ** It prints appropriate messages too. */ bool check_out(int device) { int dev; dev = device; /* check for device ok */ if (!damaged(dev)) return (0); /* report it as being dead */ out(dev); /* but if we are docked, we can go ahead anyhow */ if (Ship.cond != DOCKED) return (1); printf(" Using starbase %s\n", Device[dev].name); return (0); } | http://www.dragonflybsd.org/cvsweb/src/games/trek/check_out.c?rev=1.3 | CC-MAIN-2014-42 | refinedweb | 152 | 77.43 |
Hey Codeforces!
We’d like to invite you to take part in our AIM Tech Mini Marathon 1 to be held this Thursday on the 1st of February at 7 pm MSK.
This is unrated competition. All the participants will be challenged with only one problem, which doesn’t have a fast and full solution and 3 hours to solve it. Solutions will be evaluated independently on each test. The exact formula of points per test will be given in the problem statement. The score for the contest is a sum of scores for each test. You can participate in contest as a team, 3 members maximum.
All the tests will be released at the very beginning of the competition. They will be used both for preliminary and final testing. You will be also provided with a checker and a visualizer, written in Python3. You can find environment setup instruction below. Local checker and vizualizer run is optional, but could help finding the solution. Your solution can be written in any language that is supported by codeforces.
AIM Tech Mini Marathon 1 will take place during the Petrozavodsk training camp, which is traditionally sponsored by AIM Tech. At the end of the competition first five teams will be awarded with AIM Tech T-shirts.
The Marathon was prepared by AIM Tech team: ArtDitel, Kostroma, SirShokoladina, zeliboba, Edvard, zloyplace35.
Special thanks to Mike Mirzayanov MikeMirzayanov for Codeforces and Polygon and to the problems coordinator Nickolay Kalinin KAN for his help with the competition arrangements.
AIM Tech is a high frequency trading company based in Moscow. The key words that describe the essence of our work are big data, low latency and HFT. Effective C++ coding, algorithmic mindset and the mathematical intuition are all very handy in our work. That’s why most of our employees are the winners of different programming and math contests. At free time AIM Tech team usually takes part in various programming competitions as well as challenges itself at hiking and mountaineering.
For more information on AIM Tech follow us on aimtech.com, facebook or instagram. Also feel free to write us any time via CF, VK, FB, Telegram or simply e-mail us. We are open to answer any of your questions including job openings.
We wish you all luck and high rating!
To run visualizer you need python3 with ‘pillow’ library. You can download Python3 here:. To install pillow simply run
pip3 install pillow on Linux, Windows or MacOs. To check that everything works properly create a script file
test.py:
from PIL import Image, ImageDraw im = Image.new("RGB", (128, 128)) draw = ImageDraw.Draw(im) draw.line((0, 0) + im.size, fill=128) draw.line((0, im.size[1], im.size[0], 0), fill=128) del draw im.show()
and run it:
python test.py. You will see a red cross with black background.
Please feel free to write a comment below.
UDP. There is no limit on a number of PCs in this contest, you may use up to one PC per participant
TCP. Every test will have it's own separate task, so every task will have only one test
IGMP. You can download the password-protected archive with tests and checked by any of the given links:
aimtechiscool. Please you only one of these links, not all
HTTP. Contest is over, congratulations for the winners:
- ИТМО 1: SpyCheese, izban, Belonogov 1191.717
- sdya 1188.534
- Moscow IPT: Shock Content: amethyst0, AndreySergunin 1179.33
- UW3: znirzej, tabasz, Proszek_na_ludka 1157.526
- Warsaw U: KMR: Errichto, Radewoosh, mareksom 1152.257
- Helsinki U: Ukkonen Fan Club: Hansuzu, mango_lassi, kllp 1152.007
- admarkov 1145.181
- MS TSV: grphil, voidmax, Egor.Lifar 1115.304
- Vilnius University #1: AllSubmissionsMatter: JustasK, Darius0021, jDomantas 1112.618
- Ural FU: Dandelion: Um_nik, Merkurev 1112.112
Please write your opinions in comments | https://codeforces.com/blog/ArtDitel | CC-MAIN-2021-43 | refinedweb | 639 | 68.67 |
Intro
Electron.JS, in its main purpose - is for creating desktop applications using Javascript. Most popular way of doing so is using React & Node.js.
I will introduce a code architecture for building scalable Electron application - and on the fly - compile the code on chosen OS platform.
I am not going to focus on implementing it with an Electron application because there is no need for this tutorial, but you should know that the best application of this tutorial resides in Electron applications.
We are going to code the application to both Darwin and Windows platforms in one workspace - but as we'll see, in compilation we will be compiling only one (chosen by us) platform code. Because in most cases, you will need to code a code for 2 (at-least) platforms. But, we of-course don't want any Darwin code for example to exist in Windows application (just an application size side-effect).
Design patterns
When working in a team, design patterns become more and more important. Not only for well-structured code, but also for "easy-to-understand" code and scalability.
Thus, we will be using the following: Provider, Singleton, Factory.
Code
When building such Electron application, splitting the code is important.
This is the code architecture I reckon on implementing:
Very basic one, not that advanced.
Short brief:
You want to catch the IPC events coming from your Renderer process via the Routers. Then, send the event, by reading the "channel" name, to the proper controller. A controller is a function to handle messages from the Renderer process. Then, heavy workload should be coded in the Providers. A provider is the one to implement the underlying OS logic for example. This is the module I am going to focus on, because all the rest modules are irrelevant with this tutorial.
Code preparation
So we are creating a dummy project, non-Electron one by the way. Simply create a folder for the project. Run
npm init -y.
We are going to use Typescript, Webpack in this project. So please install the following:
npm i -D typescript webpack webpack-cli ts-node ts-loader @types/webpack @types/node.
Next, init a
tsconfig.json file by running
tsc --init. We want to change it to the following:
{ "compilerOptions": { "outDir": "./dist/", "noImplicitAny": true, "module": "commonjs", "target": "es5", "jsx": "react", "allowJs": true, "moduleResolution": "node", "esModuleInterop": true, "allowSyntheticDefaultImports": true, } }
Now we want to utilize Webpack in our project, because this is a compilation tool for Javascript. So create the following file
webpack.config.ts:
import webpack from 'webpack'; const config: webpack.Configuration = { resolve: { extensions: [".ts", ".js"], }, module: { rules: [ { test: /\.ts$/, use: 'ts-loader' }, ], }, entry: './src/main.ts', output: { filename: 'bundle.js', clean: true, }, plugins: [ new webpack.NormalModuleReplacementPlugin( /darwin/, function (resource) { resource.request = resource.request.replace( /darwin/, 'darwin', ); } ), ], mode: 'production', }; export default config;
The important thing to node is that we are using the
NormalModuleReplacementPlugin plugin. It is a plugin which reads your
import statements and replace it with whatever you want.
At the moment, we are simply replacing any
import statement with
darwin string with the same string. Later we'll change it.
Provider Code
Let's start. In the root folder, create a
.src folder, and another one inside
src called
factories. The last will hold your factories classes. Each should be dedicated to well-defined big task. We create 1, so create a folder called
example and create inside 4 files:
example.ts (the factory),
example-provider.ts (the provider),
example.darwin.ts (code dedicated to the Darwin application),
example.windows.ts ( code dedicated to the Windows application).
The factory purpose is to returns us a Provider, which either instance of the Windows one or the Darwin one. That's because in the most cases the Darwin code is definitely different from the Windows one. So the factory purpose is to retrieve us the correct one, depending on the platform the code is actually being running.
However, sometimes the underlying platforms may share some code. This is why we are going to define an abstract Provider.
Begin with the factory:
import ExampleProvider from './example-provider'; import UnderlyingProvider from './example.darwin'; export default class ExampleFactory { private static _instance: ExampleFactory; private _provider: ExampleProvider; private constructor() { this._provider = new UnderlyingProvider(); } static get instance() { if (this.instance) { return this._instance; } return this._instance = new ExampleFactory(); } public get provider() { return this._provider; } }
This is our singleton factory class. This is a class to be used with the same instance wide-application. You may want to allow\disable this feature, but in this tutorial I chose to implement is as a Singleton one.
As you can see, it holds the provider. Currently, I import the provider from Darwin one. But later, we'll see how to change to the Windows one.
Let's take a look in the abstract Provider:
export default abstract class ExampleProvider { protected abstract executeCodeImpl(): void; public executeCode() { console.log('Hello world - I am shared code'); this.executeCodeImpl(); } }
The reason we have this classes is important:
1. To have a shared platforms code. In this example the
console.log is shared code which will be executed in both platforms.
2. To FORCE the developers to have same "idea" regarding the code. Think- obviously we want the 2 implementations (Windows and Darwin) to do the same task, but in the platform specific ways.
Using abstract class is great way to accomplish these 2 missions.
Let's take a look at the Windows provider:
import ExampleProvider from './example-provider'; export default class ExampleWindows extends ExampleProvider { protected executeCodeImpl() { console.log('Hello from Windows..'); } }
And the Darwin one:
import ExampleProvider from './example-provider'; export default class ExampleDarwin extends ExampleProvider { protected executeCodeImpl() { console.log('Hello from Darwin..'); } }
That's all. Now, wherever you want to execute the platform specific code anywhere outside of the
factories folder, like in some arbitrary file
try.ts just code:
import ExampleFactory from './factories/example/example'; ExampleFactory.instance.provider.executeCode();
What about compiling to the correct platform?
That's easy. You want Darwin? go to the
webpack.config.ts and make sure, via the
NormalModuleReplacementPlugin plugin, you chose the
darwin imports. Same for Windows. Just change to replace all
darwin imports statements with Windows ones by changing the replaced string to
winodws in the example up above I've provided.
npm run build and have fun. You have a bundle file compiled to whatever platform code you want, Without the second platform code.
References:
Discussion (0) | https://practicaldev-herokuapp-com.global.ssl.fastly.net/talr98/compiling-an-electron-application-to-pre-defined-os-446e | CC-MAIN-2022-05 | refinedweb | 1,074 | 52.05 |
json-glib: 0.6 is out! please: download it, test it, use it. as far as I know, it has been packaged for Debian unstable, and has entered the
NEW queue (kudos to Rob Bradford, esquire and fine gentleman).
debian: with the release of Hardy I decided to switch back to Debian after three years of Ubuntu. even though there are still some rough edges in Lenny, the support for laptops has definitely improved a lot and so I got back to my old love. starting from Gutsy, I found myself increasingly at odds with Ubuntu decisions and even though I upgraded my wife’s laptop to Hardy, I’m really glad I got back to Debian.
clutter/1: apparently, I’ll give a lightning talk about our reference toolkit for Clutter at this year’s GUADEC, in Istanbul. Øyvind proposed it for me because, regardless of being on the paper committee, I actually forgot the deadline for the CFP — whoops, maybe I shouldn’t have said that. :-) with the Tidy lightning talk and the Clutter guts talk given by Matthew, we decided for a high-level/low-level approach, instead of going for the usual this is teh Clutter, look at teh bling kind of talk. if you want to understand Clutter, Matthew’s talk is definitely where you want to be; as we all know:
Clutter = Clean and nice API + Performance + Portability + Integration = ♥
from my Clutter talk at FOSDEM
so, if you want to know how Clutter creates love, get to Istanbul this July. :-)
tweet: I started eating my own dogfood. Tweet is by no means complete or even guaranteed not to turn you into a goat and eat your breakfast — but now it works well enough for reading your own timeline and sending new statuses; and it doesn’t require
trunk of anything any more, thanks to a Tidy transplant. I’m using Tweet as a way to see what kind of API is needed to properly integrate a Clutter canvas into a GTK+ application: colors, fonts, etc. if you want to try it out, contribute or just mock my insanity:
git clone git://github.com/ebassi/tweet.git
clutter/2: we’re really close to a 0.7 release, which will mark the beginning of the slushy phase of the API; as far as documentation goes, we’re in pretty good shape already, at 93% for the Clutter namespace, and another 80% for the Cogl namespace. bindings will need to be updated — but the amount of new API is not that big, so it’s not going to be a long wait. I’m making a note here: huge success.
Hi Mr. Bassi,
I tried out your bling-tastic Twitter client. It’s looking very nice.
Just thought I’d let you know I had a bit of pain trying to get json-glib working. When I tried to build it complained about json-glib-1.0.vapi being missing. Maybe it’s getting missed out of the tarball somehow?
Also when building tweet it complained that it couldn’t find json-scanner.h. It looks like it’s included by json-glib.h but isn’t actually installed?
@neil: yeah, I messed up a bit the tarball. I’m going to release 0.6.2 asap to fix these issues. | http://blogs.gnome.org/ebassi/2008/05/19/some-things-come-from-nothing/comment-page-1/ | CC-MAIN-2015-06 | refinedweb | 557 | 71.04 |
Hi,
I have two issues with the API:
- I'm trying to access my deployment's logs but the return is empty.
- The ReadLiveAlgorithm function returns only the last ~25 minutes worth of a chart, since it (probably) defaults to the highest resolution. It should be possible to get a lower resolution and hence get more data.
using System;
using QuantConnect.Api;
namespace LeanApiTool
{
class Program
{
static void Main( string[] args )
{
// Create and initialise connection
var qc = new Api();
qc.Initialize( redacted, "redacted", "notused" );
// Check for successful connection
if ( !qc.Connected )
throw new Exception( "API connection unsuccessful!" );
// Read live algo
var liveResult = qc.ReadLiveAlgorithm( 2543382, "6ae060032eaa51b16a1ac8871f538c26" );
// Read logs
var logs = qc.ReadLiveLogs( 2543382, "6ae060032eaa51b16a1ac8871f538c26", DateTime.Parse( "14 Apr 2019" ), DateTime.Parse( "20 Apr 2019" ) );
}
}
}
There's definitely logs between these two dates - I have also tried to run that function without any date range - same empty result. The deploy ID and hash are correct as the ReadLiveAlgorithm returns a correct set of data. | https://www.quantconnect.com/forum/discussion/5655/1-unable-to-access-logs-and-2-charting-should-return-full-range-via-api/ | CC-MAIN-2021-17 | refinedweb | 163 | 59.5 |
using matplotlib, executed the script, only to not have the figure displayed to my screen.
My script executed just fine. No error messages. No warnings. But there was still no plot to be found!
This is actually a common problem I’ve ran into over the past few months, especially when working with Debian based operating systems such as Ubuntu and Raspbian. This issue is only further compounded when utilizing virtual environments via the virtualenv and virtualenvwrapper packages.
The issue actually stems from the matplotlib backend not being properly set, or from a missing dependency when compiling and installing matplotlib. Luckily, after a lot of trial and error (and spending an entire day trying to come up with a solution), I have been able to resolve the problem and get matplotlib figures to show up and display on my screen on both the Ubuntu and Raspbian operating systems (and when using Python virtual environments).
While this post is not exactly related to computer vision or OpenCV, I still want to share my experience and solution with other PyImageSearch readers. Matplotlib is a heavily used package in the Python scientific community and I hope that this article helps other readers resolve this strange and hard to pinpoint issue.
Setting the stage
Let’s go ahead and set the stage.
- We’re using a Debian based operating system such as Ubuntu or Raspbian.
- We’re (optionally) utilizing Python virtual environments via virtualenv and virtualenvwrapper.
- And our goal is to take the following image (left) and compute a grayscale pixel intensity histogram for it using matplotlib (right):
Figure 1: Our end goal is to utilize matplotlib to display a grayscale pixel intensity for the image on the left.
Since we are using matplotlib, let’s create a new virtual environment called plotting :
Now that we’re in the plotting environment, let’s install numpy , scipy , and matplotlib :
Awesome — all of our Python dependencies are installed. Now, let’s write a few lines of code to load the image, convert it to grayscale, compute a histogram over the grayscale image, and finally display it to our screen. I’ll throw all this code into a file named grayscale_histogram.py :
The code here is fairly straightforward. Lines 1 and 2 import matplotlib and cv2 . We then load our image and convert it to grayscale (Lines 4-9). From there the cv2.calcHist function is used to compute a histogram over the grayscale pixel intensities. Finally, Lines 14-22 plot the histogram using matplotlib .
To execute our script, all we need to do is fire up and shell and issue the following command:
When I execute the code on my OSX machine in the plotting virtual environment, the histogram is computed and both the grayscale image and histogram are displayed to my screen:
However, when I go over to my Ubuntu 14.04 machine and execute the exact same code all I see are my images:
Figure 3: I have executed the exact same code on my Ubuntu system in the plotting virtual environment. All I see are my images — where did my histogram go? Why is there no error message?
Which leads to the question: “Where is the histogram?”
As we can see from the terminal output, the script executed just fine. No errors were displayed. No warning messages printed to my console. But yet there is not plot!
Resolved: Matplotlib figures not showing up or displaying_backend() :
On my Ubuntu machine this gives me a value of agg ; however, through my testing and debugging, this value needs to be TkAgg for the TkInter windowing system (at least when using Ubuntu and Raspbian).
Luckily, we can resolve this issue by using apt-get to install a few libraries:
But we’re not quite done yet. In order to get matplotlib to recognize the TkInter GUI library, we need to:
- Step 1: Access our plotting virtual environment via workon plotting .
- Step 2: Use pip to uninstall matplotlib (since we installed it via pip earlier in this article).
- Step 3: Pull down matplotlib from the GitHub repo.
- Step 4: Install matplotlib from source using setup.py .
I can accomplish these steps using the following commands:
Again, you’ll want to ensure that you have installed TkInter via apt-get before performing these steps.
After matplotlib has been installed via source, let’s execute the get_backend() function again:
Sure enough, we now see the TkAgg is being used as the matplotlib backend.
Note: You can explicitly instruct matplotlib to use the TkAgg backend by making a call to matplotlib.use("TkAgg") ; however, this won’t do you much good if the TkInter dependencies are not installed.
And now when we execute our grayscale_histogram.py script, just like above:
We should now see both our grayscale image along with our histogram:
Figure 4: Success! Our matplotlib figure is now showing up! All we need to do was change the matplotlib backend.
We have now fixed our issue — matplotlib figures are successfully being displayed on our screen!
Granted, this solution is a bit of a pain in the ass, but it’s fairly straightforward and gets the job done. If you have any other suggestions or comments, please feel free to leave them in the comments section.
What about the Raspberry Pi?
The Raspbian operating system, which many Raspberry Pi’s run, is Debian based just like Ubuntu. If you are having the same problems with matplotlib figures not displaying on your Raspberry Pi, the fix detailed in this blog post will resolve your plotting woes.
Can’t you just install matplotlib via apt-get?
The astute Debian user may be wondering why I didn’t simply install matplotlib via apt-get , like this:
The reason is because I’m a heavy user of Python virtual environments and strictly believe in keeping my Python environments sequestered and independent of each other. If you use apt-get to install matplotlib you lose control over what version of matplotlib you want to install — you simply have to use with whatever version is in the apt-get repository. This also muddles your system install of Python which I try to keep as clean as possible.
All that said, every time I have installed matplotlib via apt-get all of my dependencies were correctly installed and I was able to display my figures without a problem, so if you do not care about Python virtual environments, then the apt-get solution is a good way to go. But again, I really recommend using virtual environments.
Summary
In this blog post I detailed how to resolve a pesky issue where matplotlib figures are not displayed to your screen. Symptoms of this problem include clean script execution (i.e. no error messages and no warnings) printed to your terminal, and yet your plot is not displayed. I have regularly encountered this problem when using Debian based operating systems such as Ubuntu and Raspbian. The problem is only further compounded when using Python virtual environments.
Resolving this matplotlib issue involves manually installing dependencies via apt-get and adjusting the matplotlib backend to use TkAgg , followed by compiling and installing matplotlib from source. Afterwards, the issue seems to be resolved.
While this post wasn’t related to computer vision, the matplotlib library is heavily used in the scientific Python community, so not having your matplotlib figures displayed can be extremely frustrating and annoying. I hope this post helps other readers who encounter a similar problem.
I’ll be back next week with more computer vision posts!
You can control which backend is used via the
matplotlibrcfile and you should not need to install from source to get the TkAgg backend to work in a venv.
Interestingly, this is the inverse of the perennial SO question of ‘how do I make plots without opening a gui window’
You can control the backend via the
.matplotlibfile and the
matplotlib.use()function. However, that will not help if the backend is not actually installed. The most important step is to grab the dependencies via
apt-get, at which point you could just set the backend manually, but a re-compile from source will automatically pick them up, which I find preferable.
Hey Adrian. A little question.
I am on Mac El Capitan, when I entered
“$ sudo apt-get install tcl-dev tk-dev python-tk python3-tk”
into the command line, I got “sudo: apt-get: command not found” message. What should I do?
This blog post is for Ubuntu, not OSX — hence the
apt-getcommand is not part of OSX. Are you having trouble displaying matplotlib plots on OSX?
Yes. I believe it is because of the virtual environment has some conflicts with the matplotlib.
Indeed, there are some issues with the latest version of matplotlib and Python virtual environments. There are a few workarounds, but by far the easiest is to use an earlier version of matplotlib:
The key step here is to to checkout the
1.4.3version before installing.
Hey Adrian, I’ve done as above (except I am in cv environment). I got this output:
‘* The following required packages can not be built:
* freetype’
What should I do?
Thanks in advance.
Can you share your full output using GitHub Gists or PasteBin? It’s hard to diagnose what the error message is without seeing the full trace.
Like this? :
Yes, that helps with the formatting a lot. I did a quick search and it seems like this might be an open issue with matplotlib. I would suggest posting your error message + steps taken to reach the error message in this GitHub Issue.
Hi Adrian, I would thank you, I also spent long hours searching in forums why images were not displayed on my Raspberry, then discovered the problem but didn’t find solution, unto I returned to this blog, and everything works now fine.
5 stars blogpost,
very usefull
thanks!!
Thanks Matt! 🙂
Adrian, pyimagesearch and your tutorials totally rock. Absolutely awesome stuff. Python and OpenCV are incredible, and your guidance is such a valuable asset.
I am confused as to why you put numpy, scipy, and matplotlib in the plotting virtual environment. When I did that it could not find the cv2 module. Which I expected based on my understanding of virtual environments (which is very little). I installed them all in virt env cv3 (OpenCV v3.1.0) and everything works great so far. Am I missing something? Why did your python interpreter find cv2 in the plotting virt env?
I tend to create different virtual environments for each of my projects. Since this blog post was not 100% specific to OpenCV (and users not using OpenCV could have the same problem), I didn’t use the
cvvirtual environment.
In reality, you can create and name a virtual environment whatever you want. To get the OpenCV bindings into a name virtual environment, just sym-link the
cv2.so(and optionally
cv.py) files into the
site-packagesof the virtual environment — in fact, this is exactly what I did for the plotting virtual environment.
Hi, I’m doing a python project and I’m having a similar issue.
First of all I was doing this project on a PC-Duino (SO ubuntu 12.04), my code ran fine all the time and my core functions are imread() to read a png image, plt.show() to display this image, and after adding some patches on runtime finally use plt.draw() to see these patches in ‘real-time’.
Now I need to run this code on a computer.. the image keep displaying after doing plt.show() but it seems that plt.draw has no effect (without warning nor error).. it just does nothing. I have been trying first on my windows10, then i’ve downloaded and installed an ubuntu16 partition with no results..
I guest it could be a version issue, so i checked my matplotlib version on PC-Duino which is 1.1.1 and the one installed on my computer is 1.5.1, so I downgrade matplotlib to 1.1.1 and then a new issue appears which brings me straightforward to this post: this time the image doesn’t display anymore by doing plt.show().
Finally I fixed this last issue thanks to you (i was using Agg backend instead of TkAgg) and now restored my matplotlib to 1.5.1 version but i’m unable to make plt.draw() working fine on my computer. This is annoying.
Any idea?
Thanks!
That is quite the strange error! I’m honestly not sure as I don’t use the
plt.draw()function, but if I come across anything, I’ll let you know.
I may be too late to reply to this already resolved issue, but I believe that people like me really appreciate your efforts Adrian and would eventually, come here for a similar issue related to “Unable to plot using matplotlib on windows 10”
This is how I worked it out …
In my case (Windows 10 + python 3.7), just after
import matplotlib
I had to change the environment from ‘Agg’ to ‘TkAgg’ using
matplotlib.use(‘TKAgg’,warn=False, force=True)
right before the code where I actually plotted, i.e,
import matplotlib.pyplot as plt
fig = plt.figure()
# AND SO ON….
Thanks for sharing!
Hi Adrian,
Thanks for this solution.
However, It only works for grayscale histogram to me. It doesn’t work for color histograms.
This code only computes grayscale histograms. Computing color histograms requires different code. If you haven’t taken a look at Practical Python and OpenCV, I detail how to compute and visualize color histograms in there.
thanks a lot man, i passed a whole afternoon look for a solution to get a display plot, now your explanation, i got it, thanks.
Congrats Rafael! 🙂
on a Raspberry Pi 3 I tried to run this in the python interpreter in (cv); got no errors, but the command:
plt.figure()
responses with
nothing on the screen, so I think it plots beyond the vga memory.
What to do?
Very strange, I haven’t ran into that issue before. Can you run
matplotlib.get_backend()and see which backend you are using?
hi adrian i am using raspberry pi 3 in that cv is a virtual environment, in that environment i can not able to import matplotlib in python how can i solve this?
I created plotting virtual environment but it doesn’t solve it
If you are using the
cvvirtual environment, then follow the same steps detailed in this tutorial. Just use:
$ workon cv
To access the
cvvirtual environment instead of the
plottingvirtual environment.
hi Adrian i follow this tutorial in cv environment.so plotting environment is running so that can we use cv and matplotlib in plotting environment?
Correct, you just need to install matplotlib into the
cvvirtual environment (or whatever virtual environment name you are using).
You saved the day Adrian,
I wasn’t able to see the plot at first but remembered reading this post after which the plot showed up nicely.. Thanks!
Fantastic, I’m happy to hear it Bert!
Hello, it is posible to include image near histogram in Tkinter ? Thank you.
Hi Dumitru — can you elaborate on what you mean by “include image near histogram in TKinter”? Are you trying to display an image inside a matplotlib plot?
When i install matplotlib in opencv
Collecting matplotlib
Downloading matplotlib-2.0.0.tar.gz (53.2MB)
…
MemoryError
Try using the
--no-cache-diroption:
$ pip install matplotlib --no-cache-dir
hi adrian i am using raspberry pi 3, opencv3, and python 2.7.9
>>> matplotlib.get_backend()
u’TkAgg’
bu i still cant showing histogram
What should i do??
How are you accessing your Raspberry Pi? Over SSH and VNC? Or via a connected keyboard + HDMI monitor?
Hi adrian,im using same setup and backend GTk3Agg and figure is white but when i go over with cursos,i can see x,y values. im on monitor via hdmi on Raspberry 3 Pi
Hi Zaso — that is indeed strange, I’m sorry to hear about the matplotlib issue. However, I must admit that I’m not sure what the exact error is. I would suggest posting on the GitHub Issues page for the matplotlib repo.
Hi Adrian, first of all I would like to congratulate with you for this useful blog.
I have an issue about visualising image and related histogram:
I can’t see them simultaneously, I mean histogram window pops up only when I have closed the images window.
Do you know how can I solve it and show them together as your tutorial does?
Thanks in advance
The matplotlib call will block execution of the script until you close the window. Call
cv2.imshowbefore
plt.showand it should resolve the issue.
Thanks for your post, It saves me a lot of time.
Thanks Rogeri, I’m glad to hear it 🙂
Hi Dr.Adrian Rosebrock
I have succeeded to install OpenCV3 into RasPi3 according to your instruction.
And also succeeded to execute the grayscale_histogram.py.
But unfortunately I haven’t succeeded to install scipy until now.
Monitor show only “Runnig setup.py bdist_wheel for scipy” for long time.
Would you help me how to install scipy into my RasPi3?
Installing SciPy on the Raspberry Pi will take quite a bit of time. I would suggest starting the install and letting it run overnight.
Thanks a lot for the post – very helpful! I ended up simply needing to change the backend by using rcParams.update(), but until I saw this post I had no idea where to start to make my figure appear!
Congrats on resolving the matplotlib issue, Alex!
Thanks for your great tutorials! I followed the instructions, but I am getting an error/warning after installing matplotlib from Github on the Raspberry Pi 3 Model B+. In the cv virtualenv I type
python
>>> import matplotlib
The result is
“UserWarning: could not find rc file; returning defaults.”
Now I am trying
>>> matplotlib.get_backend()
‘agg’
The matplotlibrc file seems to be not created at installation, because there is no file in ‘/home/pi/.config/matplotlib/’. Do you know how to fix this problem? I tried to copy the matplotlibrc.template file from the Git to this directory but without success.
Thank you for your answer.
I solved the problem by copying the matplotlibrc.template file to ‘/home/pi/.virtualenvs/cv/lib/python3.5/site-packages/matplotlib-2.2.2+1059.g8a29c4059-py3.5-linux-armv7l.egg/matplotlib/mpl-data’ which was the result of
>>> matplotlib.matplotlib_fname()
.
Furthermore I had to change the filename to ‘matplotlibrc’ and line 40 (in my case) of its code to
backend : TkAgg
Nevertheless it would be interesting why there is no rc file added automatically.
Thanks for sharing the solution, Elias! 🙂
hi, Adrian.
When I run mkvirtualenv cv2 this command , it’s point that command can not found. so I use pip to install virtualenv and virtualenvwrapper , it didn’t successful, and it’s also point that matplotlib 2.2.2 has requirement numpy >=1.7.1, but you’ll have numpy 1.6.1 which is incompatible . I failed to upgrade numpy1.6.1 to 1.7.1.
Can you give me some advice ? Thank you
Hey Liujie — you mentioned that both virtualenv and virtualenvwrapper failed to install. I would suggest starting there and resolving that issue before you move forward..
Which version of matplotlib do you have installed currently?.
matplotlib.__version__ gives version as ‘2.2.2+1330.gaf7a74b’
Can you try using an older version of matplotlib and see if that resolves the issue?
Hi Adrain! Thanks alot for helping us with our questions. I have the same issue has Sruthi and installing the older version of matplotlib didn’t help. Also, I’m trying to run cocoapi and the pycocotools im using requires matplotlib>2.0. May I ask what other options I have? Thanks!
I don’t have a lot of experience with the pycocotools library so I’m honestly not sure what their dependencies are or what they are trying to do with matplotlib. I would suggest posting on their GitHub issues page.
Hi Adrain,
Thanks alot for this article! My issue is, I have this line: pycocotools.coco import COCO. And from terminal:
The backend was *originally* set to ‘agg’ by the following code:
File “coco0309.py”, line 3, in
from pycocotools.coco import COCO
I tried inserting the line matplotlib.use(“TkAgg”) before that line and then after that line as well but both didn’t work.
When I:
print(plt.get_backend())
print(matplotlib.get_backend())
I get:
agg
agg
Is it possible to do this without using TkAgg? Thanks alot for doing this for us!!!
Hello Adrain,
Thanks for the tutorial,
Here I would like to share a different experience here I had, the ran the above script on my Windows system and didn’t get the display of histogram and
first I thought the problem is similar to Linux system, but after making the gray scale image and tapping some key, the histogram window displayed, then I realized that the reason is because of the waitKey(0) command , which did not
allow the execution of the code further down till I tap some key. And I was laughing out myself for my first thoughts ( ie ,thinking some issues similar to Linux and I am going to have a tough time to resolve, thank God , nothing like that required ).
I really appreciate your time effort in making such wonderful tutorials and making me to think for next system (third one) to be a Linux. By the way
right now, I work on both Windows and Mac Pro systems and shortly a Linux system will added and this is going to be used only for ML and DL projects on the domains like CV, NLP, Speech and Data Analytics.
And you are the main inspiration to enter in to this field of AI, especially
DLforCV.
Thanks a lot again.
Thanks for sharing! I also really appreciate your kind words. Keep up the great work! 🙂
How did you ever track this down. Great job.
Thanks a lot for posting this.
You are welcome! | https://www.pyimagesearch.com/2015/08/24/resolved-matplotlib-figures-not-showing-up-or-displaying/ | CC-MAIN-2019-43 | refinedweb | 3,705 | 65.42 |
everyones information, a brief summary of the new stuff in C++ since the ARM see and in particular
If your compiler has them, you should be using <bitset> not <bitset.h> and <string> not <string.h>. You can get weird problems with the .h versions which are outdated. When you use the non.h versions, though the classes are all defined in the "std" namespace, so you must use that namespace with a
using namespace std;
or you must specify "std::" before the class names.
string s = bs.to_string<string>();
Be seen. Boost your question’s priority for more expert views and faster solutions
#include <condefs.h>
#include <bitset>
#include <string>
#pragma hdrstop
using namespace std;
int main()
{
bitset<32> bs;
string s = bs.to_string();
return 0;
}
Attempt to compile produces:
[C++ Error] experiment.cpp(9): E2285 Could not find a match for 'bitset<32>::to_string<cha
**************************
changing last line to:
string s = bs.to_string<string>();
results in:
[C++ Error] experiment.cpp(9): E2299 Cannot generate template specialization from 'bitset<32>::to_string<cha
[C++ Error] experiment.cpp(9): E2285 Could not find a match for 'bitset<32>::to_string<cha
string s = bs.to_string<char>();
or maybe
string s = bs.to_string<char,char_tra
Both
string s = bs.to_string<char>();
and
string s = bs.to_string<char,char_tra
had the same results as
string s = bs.to_string<string>();
Online help shows the syntax of to_string() as:
template<class charT, class traits, class Allocator>
basic_string<charT, traits, Allocator>
to_string();
Typically, there's nothing resembling an example of using to_string() anywhere else in the "help" system. Nor is Stroustrop's C++ Programming explanation any more helpful.
#include <bitset>
#include <string>
using namespace std;
int main()
{
bitset<32> bs;
string s = bs.template to_string<char, char_traits<char>, allocator<char> >();
return 0;
}
I can imagine you don't like this, a utility function couldl help a bit:
template<typename CharT, typename Traits, typename Alloc, typename BitSet>
inline void
get_bitset_as_string(basic
{
s = bs.template to_string<CharT, Traits, Alloc>();
}
template<typename String, typename BitSet>
inline String
bitset_to_string(const BitSet& bs)
{
String tmp;
get_bitset_as_string(tmp, bs);
return tmp;
}
which can be used as:
string g = bitset_to_string<string, bitset<32> >(bs);
struct Foo
{
template<typename T> void bar();
};
f()
{
Foo foo;
foo.template bar<int>(); // Note the keyword 'template' behind the member-dot!
}
I thought that gcc was very close to the standard and I thought that was one that you used.
I doubt however wether BC or VC will compile this, and the message shadow66 showed does not look like it is from gcc, since that would be something like: test.cpp:9: parse error before `('
I don't doubt it at all. I know it won't. VC uses a non-template form that allways returns a "string" and BC probably does the same.
>> the message shadow66 showed does
>> not look like it is from gcc
I didn't know what he was using, just that it really did support (to some extent) member template functions so I figured you would have a better chance of helping him than me. I just had to guess at stuff, you try compiles. Though if either of the compilers don't behave perfectly....
string s = bs.template to_string<char, char_traits<char>, allocator<char> >();
works like a champ. I saw that in Stroustrop's book, but I thought, "that's gotta be some kind of syntax definition, not actual code." Yikes! KangaRoo's suggested utility is *very* appreciated!
Thanks to nietod for bringing in KangaRoo. That's a level of service I wasn't expecting from EE!
Sorry for not telling you sooner that I'm using Borland C++ Builder 4.0. Didn't mean to withhold that info and hope it didn't make resolution more difficult.
As for equitable payment, how about this: I'll give my 50 points to KangaRoo for the answer and then post another "shell question" for nietod for a 25 point "finder's fee".
I really appreciate your efforts. As a workaround, I had written a short function to do the conversion manually, but I really did want to know how to use the bitset member (template) function. I'm hoping it's faster!
Wish I had known. That I actually have. I didn't realize that they supported templates so well. (I knew they were better than VC's, but I didn't know they were that good. BCB 3 was actually very poor in this area.) | https://www.experts-exchange.com/questions/10301971/Using-bitset-to-string.html | CC-MAIN-2018-22 | refinedweb | 742 | 66.64 |
08 September 2009 10:31 [Source: ICIS news]
By Chow Bee Lin
SINGAPORE (ICIS news)--?xml:namespace>
“July sales almost doubled especially for PP, PE, polyvinyl chloride (PVC) and styrene monomer against July last year, so we think many Japanese suppliers will prepare much export quantity for a few more months,” a source at Mitsui & Co said.
“We have been getting more PE from Japanese producers for export, mainly film, yarn and blow moulding grades of high density PE (HDPE). The export volume in the October-December quarter may not be as much as that in February and March this year, but it should be more than in the July-September quarter,” a source at Marubeni said.
In the first half of the year,
Its HDPE exports soared 131% at 125,200 tonnes, while its PP exports jumped 40% to 174,800 tonnes, based on the same data.
“Our LDPE/ethylene vinyl acetate (EVA) plants have been focusing on EVA production to meet domestic demand, so our LDPE output has already been reduced, and hence we don’t have extra LDPE for export,” the major LDPE producer said.
“LDPE supply in
“
The inventories would be considered too high when they hit three to four months of production, he added.
The data also showed the country produced 117,600 tonnes of LDPE and LLDPE and 198,800 tonnes of PP in the same month.
Its inventories hit the year’s peak levels in January with 472,000 tonnes of LDPE and LLDPE, 264,000 tonnes of HDPE and 734,000 tonnes of PP, latest data from JPIA showed.
One local PE producer said it believed
“If the yen and naphtha price strengthen further, I think | http://www.icis.com/Articles/2009/09/08/9245802/japan-may-increase-pe-pp-exports-in-q4-industry-sources.html | CC-MAIN-2015-11 | refinedweb | 284 | 69.55 |
Windows Forms Application Basics (Visual Basic)
An important part of Visual Basic is the ability to create Windows Forms applications that run locally on users' computers. You can use Visual Studio to create the application and user interface using Windows Forms. A Windows Forms application is built on classes from the System.Windows.Forms namespace.
You can create Windows Forms and Windows service applications with Visual Studio. For more information, see the following topics:
Getting Started with Windows Forms . Provides information on how to create and program Windows Forms.
Windows Forms Walkthroughs . Lists topics that provide a step-by-step development of commonly created Windows Forms applications based on Windows Forms.
Windows Forms Controls . Collection of topics detailing the use of Windows Forms controls.
Developing Windows Service Applications . Lists topics that explain how to create Windows services..
When a user does something to your form or one of its controls, it generates an event. Your application reacts to these events by using code, and processes the events when they occur. For more information, see Creating Event Handlers in Windows Forms.
Windows Forms contains a variety of controls that you can place.
Finally, if you must create your own custom UI elements, the System.Drawing namespace contains all of the classes you need to render lines, circles, and other shapes directly on a form.
For step-by-step information about using these features, see the following Help topics. using the Data Sources window, which. Once defined using either Visual Studio or a code editor, these settings are persisted as XML and automatically read back into memory at run time.
For step-by-step information about using these features, see the following Help topics.: | http://msdn.microsoft.com/en-us/library/vstudio/ms172749(v=vs.110) | CC-MAIN-2014-35 | refinedweb | 282 | 50.43 |
When coding in front of a computer all day, I prefer to don my Sennheiser HD 280 pro headphones and enter alpha wave flow by listening to melodic instrumental music or SomaFM streams like Groove Salad or Space Station Soma. Unfortunately, that means I can't hear when my Android phone is alerting me to a text message, Hangout invite, or a personal email. I solved this inconvenience by sending notifications received on my phone to a tiny Web server running on my computer, then rendering the message to audio via the operating system's default text-to-speech engine.
With just a few lines of Python code and a terrific little Android workflow utility called Tasker, I'll show you how you can do this with your Mac or PC as well.
Setting Up the Server
If you're running Linux or OSX on your desktop, you already have Python installed. If you're running Windows, download your preferred version of Python from python.org.
When creating Python-based Web applications, I typically opt for the Django framework. But for the minimal capabilities required for this project, I don't need the heavy lifting that Django provides. I avoid its bulky overhead by using a popular and lightweight Python Web micro framework called Bottle. Install Bottle using the usual Python third-party library installation routine. I use the pip (which supposedly stands for "python install python"), but you can also use easy_install on the Mac if you haven't configured pip on your computer. You can also install the package manually by downloading the bottle package, unzipping it, and running "python setup.py install" at the command prompt or terminal within the unzipped folder. Here's what my Bottle install session looked like on OSX using pip:
$ sudo pip install bottle Downloading/unpacking bottle Downloading bottle-0.11.6-py2.py3-none-any.whl (77kB): 77kB downloaded Installing collected packages: bottle Successfully installed bottle Cleaning up...
In order for my computer to speak incoming messages sent by an Android phone, I had to import a cross-platform Python speech library called pyttsx. Just as with Bottle, run either easy_install, pip (sudo easy_install pyttsx on OSX), or manually install the library. If you are using Microsoft Windows, you will need to install an additional dependency called pywin32. This library exposes Windows-specific function calls for use in Python scripts. Here's a sample install session using pip on OSX:
$ sudo pip install pyttsx Downloading/unpacking pyttsx Downloading pyttsx-1.1.tar.gz Running setup.py (path:/private/tmp/pip_build_root/pyttsx/setup.py) egg_info for package pyttsx Installing collected packages: pyttsx Running setup.py install for pyttsx Successfully installed pyttsx Cleaning up...
Be aware that if you're running a 64-bit version of Windows (such as Windows 8 or higher), you will need to manually install the 64-bit version of the pywin32 package. You can download this package from the "Python for Windows" extensions page on SourceForge. Make sure to download the build for the Windows version of Python that you're running.
With the Bottle Web micro-framework and the pyttsx cross-platform text to speech library installed, you're ready to code your server.
Coding the Server
Create a new file called "desknotify.py" using your favorite text editor (I prefer using the Python-friendly cross-platform Sublime Text editor). Then write the following code:
from bottle import Bottle, post, request, run import pyttsx app = Bottle() engine = pyttsx.init() @app.post('/say') def notify(): engine.say(request.forms.message) engine.runAndWait() return run(app, host='0.0.0.0', port=8224, reloader=True)
The first two lines import the Bottle and pyttsx libraries. I then create a bottle object and assign it to
app. I also initialize pyttsx and assign it to
engine. Next, I define a function called
notify() that will respond to Web
POST requests delivering a string assigned to the variable
message. When the string is received, it is passed to the
say function of the
engine object. Then I tell the
engine object to speak the string via the
runAndWait() function. Finally, I call Bottle's
run method to tell it to spin up its built-in WSGI-compliant Web server and listen for local and external inbound requests on port 8224 (this just happens to be the arbitrarily assigned port number). The final parameter in the
run() method allows Bottle to reload any changes made to the desknotify.py file even if the server is running. This can be helpful if you want to iteratively enhance the application without having to constantly stop and restart the script.
Open up a terminal or command-prompt window, enter to the directory where you saved the desknotify.py file, and run the script. If no syntax errors or missing library dependencies are encountered, your script's execution should look similar to the following output.
$ python desknotify.py Bottle v0.11.6 server starting up (using WSGIRefServer())... Listening on Hit Ctrl-C to quit.
If you're running this script on Windows, approve any firewall permissions that might pop up asking to allow the script to listen for inbound requests. If you encounter any errors, analyze the output, address any syntax or dependency issues, and try again.
Now that the server is ready for action, let's use Tasker for Android to send messages received and displayed within Android's notification area to the Bottle Web application. | http://www.drdobbs.com/tools/voice-throwing-with-python-and-android/240166232?cid=SBX_ddj_related_commentary_default_tools&itc=SBX_ddj_related_commentary_default_tools | CC-MAIN-2015-14 | refinedweb | 911 | 54.93 |
What an amazing trip.
We enjoyed every minute of the experience and have not stopped raving about it since our return (February 28)
The guides and staff: Robert, Chris, Dave, Diana, Mike, Claire and Dixon were all a pleasure to meet and work with.
From my first contact with Robert, to the last minute changes made for us-- everything was handled professionally and nothing was a bother.
Chris was very welcoming in Nairobi
Dave was a great guide in Amboseli and an ace driver getting us back to the airport in time, over the horrific road from Amboseli! (thank him for the adventure and his concern!)
Mike did everything possible to ensure we saw the most we could in the time we had. He was knowledgeable, informative and quite witty.
As mentioned in other posts, we were a bit hesitant to book via email and pay cash in Nairobi. But, all was as promised (and more so!). Robert and company run a first class operation.
Our accommodations were beautiful, our guides professional and informative.
We decided to stay longer in Masai Mara and forego another stop. We added a flight back to Nairobi to forego another road trip. Robert made the changes we requested within a few hours, without question or complaint.
I would highly recommend Go Kenya and their amazing staff! Our thanks
If you own or manage Go Kenya Tours and Safaris Day Trips, register now for free tools to enhance your listing, attract new reviews, and respond to reviewers. | http://www.tripadvisor.com/ShowUserReviews-g294207-d1918770-r198586018-Go_Kenya_Tours_and_Safaris_Day_Trips-Nairobi.html | CC-MAIN-2014-52 | refinedweb | 252 | 72.36 |
Mapbox Android SDK
An open source alternative for native maps on Android. This library lets you use Mapbox, OpenStreetMap, and other tile sources in your app, as well as overlays like GeoJSON data and interactive tooltips.
This is a fork of osmdroid, so the entire core is open source: it doesn't depend on the Google Maps SDK or any components outside of AOSP that would require the Google Play Store.
Installation
We recommend using the Mapbox Android SDK with Gradle: this will automatically install the necessary dependencies and pull the SDK binaries from the Maven Central repository ( Mapbox Android SDK on Maven Central ).
To install the current stable version add this to your
build.gradle:
repositories { mavenCentral() } dependencies { compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:[email protected]'){ transitive=true } compile ('com.cocoahero.android:geojson:[email protected]'){ transitive=true } }
To install the current SNAPSHOT version add this to your
build.gradle:
repositories { mavenCentral() maven { url "" } } dependencies { compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:[email protected]'){ transitive=true } }
For a full example Android project incorporating the SDK in this manner, please see the Mapbox Dev Preview app.
- Source:
- Free download to your Android device from Google Play:
NOTE: SDK Versions
At any given time there will be 3 different versions of the SDK to use. You're welcome to use whichever one makes the most sense for your project, just be aware that each comes with a different level of stability.
- Stable / Supported
- Currently
0.5.1
- SNAPSHOT
- Currently
0.6.0-SNAPSHOT
- Source
Manually / Hardcoding In Project
Download and include the mapbox-android-sdk.aar file and all
artifacts (.aar, .jar files, and Android support / compatibility libraries listed) listed in
MapboxAndroidSDK / build.gradle. For those new to Gradle the artifacts are listed in the
dependencies block.
These will change over time so please check back regularly.
Legacy Support (Eclipse) - Experimental
The Mapbox Android SDK is also packaged as a
.apklib file. This allows integration with older tools (Eclipse) that don't support the
.aar format yet. In order to make this work the project will need to make use of Maven, and it the case of Eclipse the M2Eclipse Maven plugin. From there configure the Maven
pom.xml to include the following dependency:
<dependency> <groupId>com.mapbox.mapboxsdk</groupId> <artifactId>mapbox-android-sdk</artifactId> <version>0.5.1</version> <type>apklib</type> </dependency>
For more information on how to use Maven and Eclipse together please see Sonatype's Developing with Eclipse and Maven tutorial.
Eclipse Hardcoding - NOT Recommended
The best way to make sure that the Mapbox Android SDK is setup properly (as well as updated as new versions are released) is to make use of Gradle or Maven as documented above. However, if that's not possible the Mapbox Android SDK can also be added to the project by hardcoding it in. Please note that this is extremely brittle and not scalable. Here's the steps:
- Download the mapbox-android-sdk-0.5.1.apk.
- Extract the source code and import it directly into the Eclipse project
jar xf mapbox-android-sdk-0.5.1.apk
- Download all
.jardependencies from build.gradle and add to the Eclipse project as libaries. Do NOT extract the content of these files.
- Download all
.javafiles from Cocoahero's GeoJSON library and add to the Eclipse project's source code.
Building From Source
Building from source means you get the very latest version of our code. The first step is to clone the repository to a directory in your system
git clone
We use Gradle as a configuration and build tool: to use it with your IDE,
import the project by selecting
build.gradle in the project root directory
as the project file.
Don't worry about installing Gradle on your system if you don't already have
it: the project makes use of Gradle Wrapper, so a correct & current project
version of Gradle will automatically be installed and used to run the builds.
To use the Gradle wrapper just look for
gradlew or
gradlew.bat (Windows)
in the project's main directory. For example:
cd <PROJECT_ROOT> ./gradlew --version
which will produce something like:
------------------------------------------------------------_40 (Oracle Corporation 24.0-b56) OS: Mac OS X 10.9.2 x86_64
See the Gradle Wrapper documentation for more details.
Then you can build an archive:
./gradlew clean assembleRelease # The archive (mapbox-android-sdk-<VERSION>.aar) will be found in <PROJECTHOME>/MapboxAndroidSDK/build/libs
Don't forget to then also include the dependencies from
MapboxAndroidSDK / build.gradle in your classpath!
Changes from OSMDroid
This project is a fork of OSMDroid, but is significantly different as the result of major refactoring and rethinking.
- GeoJSON and TileJSON support added.
- The Mapbox Android SDK is Apache 2.0 licensed, and does not include any GPL or copyleft add-ons.
- Mapbox Android SDK is a small core design. OSMDroid's semi-related utilities like GPX uploading, UI zoom buttons, GEM & Zip file support, Scale Bar, Compass Overlay, and more have been removed. These requirements will be better served by separate modules that do one thing well.
- Interfaces and abstract classes are only defined when suitable: most single-use interfaces are removed for simplicity.
- Data objects like points and lines use
doubles instead of the
E6int convention. This simplifies implementations. The
reusepattern is also deemphasized, since it's less necessary with newer JITs.
- Instead of supporting specific tile layers with hardcoded paths, Mapbox Android SDK provides an easy-to-configure
TileLayerclass.
- Small modules are used in place of local implementations - DiskLRUCache for caching, OkHttp for connection niceties, and android-geojson for GeoJSON parsing.
- Markers can optionally use the Mapbox marker API for customized images.
- Code style follows the Sun conventions
- Automated tests are included.
- slf4j dependency is removed
Contributors Note (aka, Where's the
master branch?)
The project's
master branch is actually
mb-pages. There is no branch named
master nor will there be. The reason for it is that it allows some automatic processing and publishing of documentation behind the scenes. In practice this shouldn't affect anybody wanting to contribute, but is something that will probably seem a bit "different" to newcomers. Anyway, that's what's going on. If you'd like more information please see #404 . | https://devhub.io/repos/spatialdev-mapbox-android-sdk | CC-MAIN-2020-10 | refinedweb | 1,038 | 58.48 |
Hello everyone, I am new to this forum and programming in general and had a quick question.
In the code below, I was wondering why it was necessary to initialize the variables. I understand the general purpose of initialization(no garbage data) but I don't see what the point is here because we declare the variable and we ask the user to tell us what the variable represents before we ever use the variable.
#include <stdio.h> int main(void) { int base, power, index; long answer; base = 0; power = 0; answer = 1.00; printf("Enter a base number: "); scanf("%d", &base); printf("Enter a power to raise the base to: "); scanf("%d", &power); for(index = 1; index <= power; index++) answer = answer * base; printf("%d raised to the power of %d is %ld.", base, power, answer); getchar(); getchar(); return 0; } | https://www.daniweb.com/programming/software-development/threads/346166/question-about-initializing-variables | CC-MAIN-2020-40 | refinedweb | 140 | 58.11 |
Holy cow, I wrote a.?"
There are various ways of getting a monitor.
You can get the monitor from a point,
from a rectangle,
or from a window.
But how do you get the primary monitor?
The primary monitor is defined to be the one
which has (0, 0) as its origin.
Therefore,
one solution
is
HMONITOR GetPrimaryMonitor()
{
POINT ptZero = { 0, 0 };
return MonitorFromPoint(ptZero,
MONITOR_DEFAULTTOPRIMARY);
}
The desktop window by convention is deemed to reside
primarily on the primary monitor,
so you could also use this:
HMONITOR GetPrimaryMonitor()
{
return MonitorFromWindow(GetDesktopWindow(),
MONITOR_DEFAULTTOPRIMARY);
}
Or you could just pass the null window handle.
This is technically an illegal parameter,
but by specifying
MONITOR_DEFAULTTOPRIMARY,
you are saying,
"If anything goes wrong,
give me the primary monitor."
MONITOR_DEFAULTTOPRIMARY
HMONITOR GetPrimaryMonitor()
{
return MonitorFromWindow(nullptr,
MONITOR_DEFAULTTOPRIMARY);
}
In this case, we are intentionally going astray
because we want to kick in the
MONITOR_DEFAULTTOPRIMARY
behavior.
A customer asked a somewhat strange question:
"We are calling SetEvent but passing the handle
to a waitable timer.
Application Verifier reports,
"Incorrect object type for handle."
But the code works well.
We want to know
the risks of passing the wrong object type to
SetEvent.
Is the recommendation only to pass handles of type "Event"
to
SetEvent?
SetEvent
Let's answer those questions in reverse order.
Yes, the recommendation is only to pass handles of type "Event"
to SetEvent,
just as the recommendation is only to pass handles of type
"Semaphore" to ReleaseSemaphore,
and more generally, only to pass valid parameters to functions.
ReleaseSemaphore
What is the risk of passing the wrong object type?
You're lucky that the kernel does object type validation
before proceeding,
so your error is caught during parameter validation and the
function fails with the error
ERROR_INVALID_HANDLE
(or status code
STATUS_OBJECT_TYPE_MISMATCH,
if the function returns status codes instead of error codes).
ERROR_INVALID_HANDLE
STATUS_OBJECT_TYPE_MISMATCH
Of course,
if you are encountering this problem only because you are
using a handle after closing it (and then the handle got recycled
as a timer handle),
then you merely got lucky.
Maybe tomorrow you won't be so lucky,
and the handle will get recycled as another unrelated event.
Tomorrow, your
SetEvent
call will succeed and
set some other guy's event.
This will probably cause that other guy to get really confused.
"This event is set when the modulator has finished calibrating.
But the event is getting signaled before the calibration is complete,
so my code ends up using an uncalibrated modulator!
I set a breakpoint on my SetEvent call, and it never
fires, yet the event is set.
Help me debug this.
I've spent a week trying to figure out what's wrong!"
As to the final remark,
"But the code works well,"
it's not clear what the customer meant by that.
What does "works well" mean in this context?
Do they mean,
"The event is successfully set even though it's not an event"?
How can you successfully
perform an event operation on something that isn't an event?
Or perhaps they mean,
"Our code seems to work okay in spite of this mistake."
The operative phrase there is "seems to".
It may seem to work well,
but someday it won't, and at the most inconvenient time.
I first encountered this term in a meeting I attended.
Q: We would like to be able to reverse the polarity of the
neutron flow without requiring a reboot.
A: Yes, that is something we've been thinking about, but
we don't have line of sight to having that feature
before the end of the month.
Q: We would like to be able to reverse the polarity of the
neutron flow without requiring a reboot.
A: Yes, that is something we've been thinking about, but
we don't have line of sight to having that feature
before the end of the month.
From context, having line of sight to a result
means something like
"Have made it part of our immediate plans to achieve that result."
This appears to be extending the idiom
on the horizon.
Literally, something
on the horizon.
is at the edge
of what can be seen.
Figuratively, then, something that is
on the horizon
is at the edge
of what can be predicted.
And if something can be seen,
then you have line of sight to it.
There is another aspect of line of sight:
The view to the object must be unobstructed.
Taking the analogy further, then,
having line of sight to a result
means that there is a plan for achieving that result
that is not dependent on work from another team.
Note that
I don't know if the "unobstructed" part of the analogy
was intended by the speaker.
All I have to work from is that one snippet of conversation.
In an attempt to obtain better insight into the phrase
line of sight,
I searched the intranet,
and the hits fell into a few categories.
One category was people using the term literally,
usually in the context of
wireless communications.
Another category appeared to use the phrase as a synonym for
"insight obtained from information":
Monthly
tear sheets are improving line of sight.
Teams were empowered to reallocate expenses within
discretionary line items,
but there was a lack of transparency into these changes.
Forecasting was a challenge because we did not have
line of sight into these reallocation decisions.
We will address this by developing a
pivot tool
that provides management a consolidated
line of sight into spend by resource.
Note also the business jargony use of spend as a noun,
meaning expenditure.
The third category appears to be what I heard in that meeting,
where it means something like "a path to a result":
XYZ was impacted by ABC and DEF.
We have line of sight to get back on track.
And then I think I hit the jackpot:
Somebody defined the term, sort of.
Line of sight to ending year $XX under budget
XYZ is at 99% pass, with line of sight to ending
the year at 100% pass.
ABC is $YY under budget, and is on track to end the year
at $XX under budget.
Line of sight to ending year $XX under budget
XYZ is at 99% pass, with line of sight to ending
the year at 100% pass.
ABC is $YY under budget, and is on track to end the year
at $XX under budget.
I therefore conclude that the two are roughly synonyms.
Line of sight to X means on track to X.
Though this means that one of the citations above translates
to "We are on track to get back on track,"
which sounds kind of eerily meta.
The preferred emphatic form of line of sight
appears to be
clear line of sight.
Today's Little Program hosts an Explorer Browser but filters
the contents to remove DLL files.
You can, of course, substitute your own filter.
(For example, maybe you want to show only files that changed
since the last time the user ran your program,
or you might want a view of My Computer but filtered to show
only removable drives.)
Remember that Little Programs do little to no error checking,
and they don't necessarily demonstrate the best programming style.
They're just quick demonstrations.
Today's smart pointer library is… (rolls dice) … WRL!
Start with
our minimal explorer browser program
and make these changes.
#include <shlwapi.h> // PathFindExtensionW
#include <wrl\client.h>
#include <wrl\implements.h>
using namespace Microsoft::WRL;
class FolderFilterNoDLLs :
public RuntimeClass<RuntimeClassFlags<ClassicCom>,
IFolderFilter>
{
// *** IFolderFilter ***
IFACEMETHODIMP GetEnumFlags(IShellFolder *psf,
PCIDLIST_ABSOLUTE pidlFolder, HWND *phwnd,
DWORD *pgrfFlags) { return S_OK; }
IFACEMETHODIMP ShouldShow(IShellFolder *psf,
PCIDLIST_ABSOLUTE pidlFolder,
PCUITEMID_CHILD pidlItem)
{
BOOL fShow = TRUE;
ComPtr<IShellItem> spsi;
HRESULT hr = SHCreateItemWithParent(pidlFolder, psf, pidlItem,
IID_PPV_ARGS(&spsi));
if (SUCCEEDED(hr)) {
SFGAOF sfgaof;
hr = spsi->GetAttributes(SFGAO_FILESYSTEM | SFGAO_FOLDER,
&sfgaof);
if (SUCCEEDED(hr) && sfgaof == SFGAO_FILESYSTEM) {
LPWSTR pszName;
hr = spsi->GetDisplayName(SIGDN_PARENTRELATIVEPARSING,
&pszName);
if (SUCCEEDED(hr))
{
fShow = CompareStringOrdinal(
PathFindExtensionW(pszName), -1,
L".dll", -1, TRUE) != CSTR_EQUAL;
CoTaskMemFree(pszName);
}
}
}
if (SUCCEEDED(hr)) hr = fShow ? S_OK : S_FALSE;
return hr;
}
};
The real work happens in the
ShouldShow method.
ShouldShow
IShellItem
SFGAO_FILESYSTEM
SFGAO_FOLDER
.dll
All that's left is to plug this into the Explorer Browser.
BOOL
OnCreate(HWND hwnd, LPCREATESTRUCT lpcs)
{
BOOL fSuccess = FALSE;
RECT rc;
PIDLIST_ABSOLUTE pidl = NULL;
ComPtr<IFolderFilter> spff;
ComPtr<IFolderFilterSite> spffs;
if (SUCCEEDED(CoCreateInstance(CLSID_ExplorerBrowser, NULL,
CLSCTX_INPROC, IID_PPV_ARGS(&g_peb))) &&
GetClientRect(hwnd, &rc) &&
SUCCEEDED(g_peb->Initialize(hwnd, &rc, NULL)) &&
SUCCEEDED(g_peb->SetOptions(EBO_NAVIGATEONCE)) &&
SUCCEEDED(MakeAndInitialize<FolderFilterNoDLLs>(&spff)) &&
SUCCEEDED(g_peb->QueryInterface(IID_PPV_ARGS(&spffs))) &&
SUCCEEDED(spffs->SetFilter(spff.Get())) &&
SUCCEEDED(SHParseDisplayName(
L"C:\\Program Files\\Internet Explorer",
NULL, &pidl, 0, NULL)) &&
SUCCEEDED(g_peb->BrowseToIDList(pidl, SBSP_ABSOLUTE))) {
fSuccess = TRUE;
}
ILFree(pidl);
return fSuccess;
}
We apply the filter to the
IExplorerBrowser
by querying for IFolderFilterSite
and using
IFolderFilterSite::SetFilter
to attach our "no DLLs" filter.
IExplorerBrowser
IFolderFilterSite
IFolderFilterSite::SetFilter
A customer reported that they had a file that was "haunted"
on their machine:
Explorer was unable to copy the file.
If you did a copy/paste, the copy dialog displayed an error.
Invalid file handle
Okay, time to roll up your sleeves and get to work.
This investigation took several hours, but you'll be able to read
it in ten minutes
because I'm deleting all the dead ends and red herrings,
and because I'm skipping over a lot of horrible grunt work,
like tracing a variable in memory backward in time to see where
it came from.¹
The Invalid file handle error was most likely coming from
the error code
ERROR_INVALID_HANDLE.
Some tracing of handle operations
showed that a call to
GetFileInformationByHandle
was being passed INVALID_FILE_HANDLE
as the file handle,
and as you might expect,
that results in the invalid handle error code.
GetFileInformationByHandle
INVALID_FILE_HANDLE
Okay, but why was Explorer's file copying code getting confused
and trying to get information from an invalid handle?
Code inspection showed that the handle in question is normally
set to a valid handle during the file copying operation.
So the new question is,
"Why wasn't this variable set to a valid handle?"
Debugging why something didn't happen is harder than debugging
why it did happen,
because you can't set a breakpoint of the form
"Break when X doesn't happen."
Instead
you have to set a breakpoint in the code that you're
pretty sure is being executed,
then trace forward to see where execution strays from the intended path.
The heavy lifting of the file copy is done by the
CopyFile2 function.
Explorer uses the
CopyFile2ProgressRoutine callback
to get information about the copy operation.
In particular, it gets a handle to the destination file by
making a duplicate of the
hDestinationFile in the
COPYFILE2_MESSAGE structure.
The question is now,
"Why wasn't Explorer told about the destination file that
was the destination of the file copy?"
CopyFile2
CopyFile2ProgressRoutine
hDestinationFile
COPYFILE2_MESSAGE
Tracing through the file copy operation showed that the file
copy operation actually failed
because the destination file already exists.
The failure would normally be reported as
ERROR_FILE_EXISTS,
and the offending
GetFileInformationByHandle
would never have taken place.
Somehow the file copy was being treated as having succeeded
even though it failed.
That's why we're using an invalid handle.
ERROR_FILE_EXISTS
The CopyFile2 function goes roughly like this:
HRESULT CopyFile2()
{
BOOL fSuccess = FALSE;
HANDLE hSource = OpenTheSourceFile(); // calls SetLastError() on failure
if (hSource != INVALID_HANDLE_VALUE)
{
HANDLE hDest = CreateTheDestinationFile(); // calls SetLastError() on failure
if (m_hDest != INVALID_HANDLE_VALUE)
{
if (CopyTheStuff(hSource, hDest)) // calls SetLastError() on failure
{
fSuccess = TRUE;
}
CloseHandle(hDest);
}
CloseHandle(hSource);
}
return fSuccess ? S_OK : HRESULT_FROM_WIN32(GetLastError());
}
Note: This is not the actual code,
so don't go whining about the coding style or the inefficiencies.
But it gets the point across for the purpose of this story.
The CreateTheDestinationFile function
failed because the file already existed,
and it called SetLastError to set the
error code to
ERROR_FILE_EXISTS,
expecting the error code to be picked up when it returned to the
CopyFile2 function.
CreateTheDestinationFile
SetLastError
On the way out,
the CopyFile2 function
makes two calls to CloseHandle.
CloseHandle on a valid handle is not supposed
to modify the thread error state,
but somehow stepping over the CloseHandle
call showed that the error code set by
CreateTheDestinationFile was
being reset back to ERROR_SUCCESS.
(Mind you, this was a poor design on the part of the
CopyFile2 function to leave the error code
lying around for an extended period,
since the error code is highly volatile, and you would be best
served to get it while it's still there.)
CloseHandle
ERROR_SUCCESS
Closer inspection showed that the
CloseHandle function
had been hooked by some random DLL that had been
injected into Explorer.
The hook function was somewhat complicated
(more time spent trying to reverse-engineer the hook function),
but in simplified form, it went something like this:
BOOL Hook_CloseHandle(HANDLE h)
{
HookState *state = (HookState*)TlsGetValue(g_tlsHookState);
if (!state || !state->someCrazyFlag) {
return Original_CloseHandle(h);
}
... crazy code that runs if the flag is set ...
}
Whatever that crazy flag was for,
it wasn't set on the current thread,
so the intent of the hook was to have no effect in that case.
But it did have an effect.
The
TlsGetValue function
modifies the thread error state,
even on success.
Specifically, if it successfully retrieves the thread local storage,
it sets the thread error state to
ERROR_SUCCESS.
TlsGetValue
Okay, now you can put the pieces together.
SetLastError(ERROR_FILE_EXISTS)
An injected DLL that patched a system call
resulted in Explorer looking like an idiot.
(As Alex and Gaurav well know,
Explorer is perfectly capable of looking like an idiot without any help.)
We were quite fortunate that the error
manifested itself as a failure to copy the file.
Imagine if Explorer didn't use
GetFileInformationByHandle
to get information about the file that was copied.
The CopyFile2 function returns S_OK
even though it actually failed and no file was copied.
Explorer would have happily reported,
"Congratulations, your file was copied successfully!"
S_OK
Stop and think about that for a second.
A rogue DLL injected into Explorer patches a system call incorrectly
and ends up causing all calls to
CopyFile2 to report success even if they failed.
The user then deletes the original, thinking that the file was safely
at the destination,
then later discovers that, oops, looks like the file was not copied
after all.
Sorry, it looks like that rogue DLL (which I'm sure had the best
of intentions) had a subtle bug that caused you to lose all your data.
This is why, as a general rule,
Windows considers DLL injection and API hooking to be unsupported.
If you hook an API, you not only have to emulate all the documented
behavior, you also have to emulate all the undocumented behavior
that applications unwittingly rely on.
(Yes, we contacted the vendor of the rogue DLL.
Ideally, they would get rid of their crazy DLL injection and API hooking
because, y'know, unsupported.
But my guess is that they are going to stick with it.
At least we can try to get them to fix their bug.)
¹
To do this, you identify the variable
and set a breakpoint when that variable is allocated.
(This can be tricky if the variable belongs to a class with
hundreds of instances;
you have to set the breakpoint on the correct instance!)
When that breakpoint is hit,
you set a write breakpoint on the variable,
then resume execution.
Then you hope that the breakpoint gets hit.
When it does,
you can see who set the value.
"Oh, the value was copied from that other variable."
Now you repeat the exercise with that other variable,
and so on.
This is very time-consuming but largely uninteresting
so I've skipped over it.
Anon is interested in
why the FAT driver is called FASTFAT.SYS.
"Was there an earlier slower FAT driver?
What could you possibly get so wrong with a FAT implementation that
it needed to be chucked out?"
The old FAT driver probably had a boring name like, um, FAT.SYS.
At some point, somebody decided to write a newer, faster one,
so they called it FASTFAT.
And the name stuck.
As for what you could possibly get so wrong with a FAT implementation
that it needed to be improved:
Remember that circumstances change over time.
A design that works well under one set of conditions may start
to buckle when placed under alternate conditions.
It's not that the old implementation was wrong;
it's just that conditions have changed,
and the new implementation is better for the new conditions.
For example, back in the old days,
there were three versions of FAT: FAT8, FAT12, and FAT16.
For such small disks, simple algorithms work just fine.
In fact, they're preferable because a simple algorithm
is easy to get right and is easier to debug.
It also typically takes up a lot less space,
and memory was at a premium in the old days.
An O(n) algorithm is not a
big deal if n never gets very large and the
constants are small.
Since FAT16 capped out at 65535 clusters per drive,
there was a built-in limit on how big n could get.
If a typical directory has only a few dozen files in it,
then a linear scan is just fine.
It's natural to choose algorithms
that map directly to the on-disk data structures.
(Remember, data structures determine algorithms.)
FAT directories are just unsorted arrays of file names,
so a simple directory searching function would just
read through the directory one entry at a time until it
found the matching file.
Finding a free cluster is just a memory scan looking for a 0
in the allocation table.
Memory management was simple: Don't try.
Let the disk cache do it.
These simple algorithms worked fine until FAT32 showed up
and bumped n sky high.
But fortunately, by the time that happened, computers were also
faster and had more memory available,
so you had more room to be ambitious.
The big gains in FASTFAT came from algorithmic changes.
For example, the on-disk data structures are transformed
into more efficient in-memory data structures and cached.
The first time you look in a directory, you need to do
a linear search to collect all the file names,
but if you cache them in a faster data structure
(say, a hash table),
subsequent accesses to the directory become much faster.
And since computers now have more memory available,
you can afford to keep a cache of directory entries around,
as opposed to the old days where memory was tighter and
large caches were a big no-no.
(I wonder if any non-Microsoft FAT drivers do this sort of
optimization, or whether they just do the obvious thing and
use the disk data structures as memory data structures.)
The original FAT driver
was very good at solving the problem it was given,
while staying within the limitations it was forced to operate under.
It's just that over time, the problem changed,
and the old solutions didn't hold up well any more.
I guess it's a matter of interpretation whether this means that
the old driver was "so wrong."
If your child outgrows his toddler bed,
does that mean the toddler bed was a horrible mistake?
A customer wanted to know if is possible for an application to
edit the user's Start page.
No, there is no interface for editing the user's Start page or
even knowing what is on it.
The Start page is the user's personal space and applications
should not be messing with it.
Imagine if it were possible.
Every application would edit the Start page to put themselves
at the front!
It turns out that the customer wanted their application to make
some changes to the user's Start page when it was installed.
Specifically, they wanted to
hunt down tiles belonging to their competitors and delete them,
then insert a tile for the newly-installed program in exactly
the spot the competitor's tile used to be.
In other words,
somebody was looking to get a really nice bonus.
A customer asked how they could have their program prevent the
system from going to the idle state.
Specifically, when the system goes idle,
the application gets into a weird state
where it starts leaking memory like crazy.
The program normally uses around
100MB
of memory,
but when the system goes idle,
something funky happens and the program's memory usage shoots
up to 4GB.
To avoid this problem,
they want to prevent the system from
entering the idle state.
Now, if your application is a special-purpose program
running on a dedicated computer,
then blocking the entry into the idle state might be acceptable.
After all, the user bought the computer specifically to run
your program and nothing else.
But the description of the program provided by the customer
did not suggest that this was the case.
It was just some program being developed for a general audience.
Interfering with the functioning of the entire system to hide a bug
in your application is a horrible thing to do.
It means that when your program is running,
idle-time tasks never run,
the computer never enters a low-power state,
laptop batteries drain ten times faster than normal,
and you basically ruin the entire computer.
What you should do is debug your program and fix the memory leak.
This is like saying,
"We manufacture car stereo systems,
and we found that when the car is coasting,
the power from the alternator is not sufficient
to drive the speakers.
We would like to prevent the car from coasting."
Suppose you had n indistinguishable balls
and k distinguishable boxes.
Enumerate the ways of distributing the balls into boxes.
Some boxes may be empty.
We can represent each distribution in the form of
n stars and
k − 1 vertical lines.
The stars represent balls,
and the vertical lines divide the balls into boxes.
For example, here are the possible distributions for
n = 3,
k = 3:
This visualization is known in combinatorics circles
as
stars and bars.
From this visualization, we see that what we are doing is
taking
n + k − 1 slots,
and in each slot
placing a star or a bar, subject to the constraint that
there be n stars and
k − 1 bars.
Another way of looking at this is that we are choosing
a subset of size
k − 1
from a set of size
n + k − 1
(the subset specifying where the bars go).
Now we can fire up
our subset-generating machine.
function Distributions(n, k, f) {
Subsets(n + k - 1, k - 1, function(s) {
s.push(n + k);
f(s.map(function(v, i) { return v - (s[i-1]||0) - 1; }));
s.pop();
});
}
We ask to generate subsets of size
k − 1
from a set of size
n + k − 1.
For each such subset, we draw an artificial bar at the end
(slot
n + k),
then calculate the number of stars between the bars.
The number of stars between two bars is the distance between the
two bars, minus 1 because the bar takes up space, too.
Another solution is to reduce this to a problem we already know
how to solve:
enumerating integer compositions.
After distributing the balls into boxes,
we go around like Santa Claus and give each box one extra ball,
which produces a composition.
Conversely, for any composition, remove one ball from each box,
and you get a distribution.
function Distributions(n, k, f)
{
Compositions(n + k, k, function(s) {
f(s.map(function(v) { return v - 1; }));
});
}
We added k extra balls, so we need to generate
compositions of
n + k.
When we get each composition, we take one ball away from
each box and call that the distribution. | http://blogs.msdn.com/b/oldnewthing/default.aspx?PageIndex=2 | CC-MAIN-2014-49 | refinedweb | 3,973 | 62.27 |
Is static implicitly Out Innimo stephan Mar 17, 2009 2:34 PM
I need this static:
@Out(required=false) private MyObject object;
Should I use a normal static getter/setter or does Seam do it automatically static?
private static MyObject object; public static ...get public static void set...
1. Re: Is static implicitly Out Innimo stephan Mar 17, 2009 3:09 PM (in response to nimo stephan)
Why I have to use this:
@In(required=false) @Out(required=false) private MyObject myObject = new MyObject();
to avoid a NPE of myObject ?
I have thought, that
@In(required=false)
creates a new Instance of myObject automatically, but this is not the case. I have to use the new Operator (which I have learned should avoid when using @In, @Out)
2. Re: Is static implicitly Out InTim Evers Mar 18, 2009 1:37 AM (in response to nimo stephan)
Logically it makes no sense to say required=false if you actually want an instance to be created.
By the way, you should never use the new operator on any seam bean. regardless of whether you inject it or not. If you use the new operator you are completly bypassing the SEAM infrastructure and none of SEAM code in that bean will work. I don't want to go in to the details of why this doesn't work, but essentially SEAM beans need to be managed by SEAM. So when you use the new operator you are not allowing SEAM to manage the bean.
If you have:
@In(required=false)
Then this means, inject the variable if it exists, otherwise leave the value set to null.
If you want an instance to always exist you should do:
@In(required=true, create=true)
This means, inject the variable if it exists, otherwise inject a new instance.
Also why do you want the variable static? Do you understand what you are actually doing when you do a static variable?
To make a long answer short, @In @Out is not the same as 'static'.
If you want a global variable maybe you just need an Application scoped bean.
3. Re: Is static implicitly Out Innimo stephan Mar 18, 2009 8:37 AM (in response to nimo stephan)
So doing static in a ApplicationScoped-Class:
@Name("app") @Scope(APPLICATION) @Startup public class App implements HttpSessionListener { // Out is not regocnized due to the new-Operator??? @Out(required=true) private static MyObject myObject = new MyObject (); // Out is not regocnized due to No new-Operator @Out(required=true, create=true) private static MyObject myObject; ...}
So you see, normally myObject is implititly static due to the application-scope, so I can leave the static-keyword. Am I right?
By the way, you should never use the new operator on any seam bean.
So when I want to refresh a (seam-)variable elsewhere in the code, I should not use the new Operator?:
public void init(){ // forbidden?? myObject = new MyObject () }
4. Re: Is static implicitly Out Innimo stephan Mar 18, 2009 8:46 AM (in response to nimo stephan)
This instance:
// Out is not regocnized due to No new-Operator @In(required=true, create=true) @Out private static MyObject myObject;
is not available in Listeners, e.g.
public void sessionCreated(HttpSessionEvent sessionEvent) { //causes a NPE !! System.out.print(myObject); } | https://developer.jboss.org/message/687913 | CC-MAIN-2019-04 | refinedweb | 547 | 53.21 |
getdelim() function shall read from stream until it encounters a character matching the delimiter character. The delimiter argument is an int, the value of which the application shall ensure is a character representable as an unsigned char of equal value that terminates the read process. If the delimiter argument has any other value, the behavior is undefined.
The application shall ensure that *lineptr is a valid argument that could be passed to the free() function. If *n is non-zero, the application shall ensure that *lineptr either points to an object of size at least *n bytes, or is a null pointer., and a terminating NUL added when the delimiter or end-of-file is encountered.
The getline() function shall be equivalent to the getdelim() function with the delimiter character equal to the <newline> character.
The getdelim() and getline() functions, the stream is at end-of-file, the end-of-file indicator for the stream shall be set and the function shall return -1. If an error occurs, the error indicator for the stream shall be set, and the function shall return -1 and set errno to indicate the error.
For the conditions under which the getdelim() and getline() functions shall fail and may fail, refer to fgetc.
In addition, these functions shall fail if:
- [EINVAL]
- lineptr or n is a null pointer.
- [ENOMEM]
- Insufficient memory is available.
These functions may fail if:
- [EOVERFLOW]
- The number of bytes to be written into the buffer, including the delimiter character (if encountered), would exceed {SSIZE_MAX}.
#include <stdio.h> #include <stdlib.h>
int main(void) { FILE *fp; char *line = NULL; size_t len = 0; ssize_t read; fp = fopen("/etc/motd", "r"); if (fp == NULL) exit(1); while ((read = getline(&line, &len, fp)) != -1) { printf("Retrieved line of length %zu :\n", read); printf("%s", line); } if (ferror(fp)) { /* handle error */ } free(line); fclose(fp); return 0; }
Setting *lineptr to a null pointer and *n to zero are allowed and a recommended way to start parsing a file.
The ferror() or feof() functions should be used to distinguish between an error condition and an end-of-file condition.
Although a NUL terminator is always supplied after the line, note that strlen(*lineptr) will be smaller than the return value if the line contains embedded NUL characters. | http://pubs.opengroup.org/onlinepubs/9699919799/functions/getline.html | CC-MAIN-2017-13 | refinedweb | 380 | 59.74 |
This is a head start: Click Here
Also, dig around a bit, you'll find plenty more, or just hit on google python reserved words/python reserved imports.
As for the imports, before naming a module, make sure you check the name in the documentation, Click Here, to see if the name already exist.
Edited by Lucaci Andrew
dir(__builtins__) #list of what's in the built-in namespace
If you not sure do a simple test.
You get a NameError if python can't find the name.
>>> reload <built-in function reload> >>> my_reload Traceback (most recent call last): File "<interactive input>", line 1, in <module> NameError: name 'my_reload' is not defined >>> list <type 'list'> >>> lst Traceback (most recent call last): File "<interactive input>", line 1, in <module> NameError: name 'lst' is not defined
So
my_reload and
lst is ok names to use.
Also pay attention to modules names,so dont name someting
random.py
When Python has a module named
random.
Edited by snippsat
You can run this simple code ...
''' names_reserved101.py show all builtin functions/methods and keywords avoid using any of those names for your variables, or you will get conflicts, using keywords flag as error ''' from keyword import kwlist print("A list of Python's keywords:") print('\n'.join(kwlist)) print('-'*60) print("Show all Python builtin functions, classes and alike:") # does a case insensitive sort first print('\n'.join(sorted(dir(__builtins__), key=str.lower)))
There is also this ...
print("Show all the modules Python currently knows about:") help("modules")
Sorry to clutter this question with even more long code, but this is a script I wrote to check modules/classes for builtin conflicts. It searches the current directory for modules or can be used on other directories by adding to sys.path.
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys def main(argz): addsyspath = argz[1] if len(argz) > 1 else None moduleorclass = argz[0][:-3] if argz[0].endswith(".py") else argz[0] print "current dir: " + sys.path[0] if addsyspath is not None: print "adding sys path: " + str(addsyspath) shortname = moduleorclass.split('.')[-1] print "checking: " + shortname + '\n' # retrieve list of conflicts try: conflicts = runtest(moduleorclass, addsyspath) # print results if len(conflicts) == 0: print "no conflicts found." else: print "found " + str(len(conflicts)) + " conflicts:" print " " + "\n ".join(conflicts) + '\n' except Exception as ex: print "error checking: " + shortname + '\n' + str(ex) return 1 # success print "finished.\n" return 0 def runtest(module_name, new_syspath=None): """ module_name : (string) Full module name or class to import ("mymodule.submodule.classname") new_syspath : (string) Path to add to sys.path (/path/to/module) Imports a module by string name, inserts syspath if wanted, and does getconflicts() on it. """ # add python path (if it was passed) if new_syspath is not None: sys.path.insert(0, new_syspath) # trim .py extension (if it wasn't already) if module_name.endswith(".py"): module_name = module_name[:-3] # import module to check builtins. exec("import " + module_name) imp_ = eval(module_name) # test conflicts and return them return getconflicts(imp_) def getconflicts(module_class): """ runs conflict test on already imported module or class, returns list """ # test conflicts conflicts = [] for i in dir(__builtins__): # test item, filter certain items. if ((i in dir(module_class)) and (not i.startswith("__"))): # filter __item__'s... conflicts.append(str(i)) return conflicts # ----- START OF SCRIPT if __name__ == "__main__": args = sys.argv[1:] if ((len(args) == 0) or ("-h" in args) or ("--help" in args)): # no args, or help flags. print "usage: pyconflicts.py <modulename.or.class> [<python path to add>]\n" + \ " example:\n" + \ " ./pyconflicts.py myscript\n" + \ " ./pyconflicts.py myproject.myclass /path/to/myproject\n" ret = 1 else: # have args, run it. ret = main(args) # exit with return code. sys.exit(ret)
If the name of this script is 'pyconflicts.py' you would run it like this:
./pyconflicts.py myscript ./pyconflicts.py myscript.myclass ** notice no .py extension, name it like you were going to import it. ./pyconflicts.py myotherscript /path/to/myotherdir ** if myotherscript is in a different directory, you will need to add that dir to python path. ... | https://www.daniweb.com/programming/software-development/threads/454492/list-all-built-ins | CC-MAIN-2018-39 | refinedweb | 674 | 65.42 |
My new orangutan, purchased from robotshop.ca, has only 1 line of active lcd display, the other is blank and the faint background squares don’t light up! What’s up? Can I get it replaced?
Hello.
First of all, which specific Orangutan model did you purchase? Can you post the code you’re using to try to write to the second line of the display? We test all our products before they ship, so it seems more likely that your problem is from incorrect LCD code. For example, are you assuming that if you write a string of 10 characters to the LCD, you will see the first eight characters on the top line and the last two characters on the bottom line?
- Ben
Yes, I was very surprised to find this, and I don’t remember if the default code had the problem, but it is currently running the Orangutan Lib lcd test program:
// lcd-test // // Tom Benedict // This example demonstrates most of the functions of the LCD // subsystem. Since the Baby-Orangutan has no LCD, this example // will only work on the Orangutan or the Orangutan-X2. // Include our I/O definitions #include <avr/io.h> // Include information about the device we're building for #include "device.h" // Include for using delay routines #include <util/delay.h> // Include for the LCD subsystem #include "lcd(12); _delay_ms(13); } } // And now for our main routine: int main(void) { int i; #ifdef _ENABLE_LCD_ // Initialize the LCD lcd_init(); for(;;) { // Startup Banner lcd_clear(); lcd_gotoxy(0,0); lcd_string("LCD"); lcd_gotoxy(0,1); lcd_string("Test..."); delay_sec(2); // Test multiline display lcd_clear(); lcd_gotoxy(0,0); lcd_string("Line 1"); lcd_gotoxy(0,1); lcd_string("Line 2"); delay_sec(2); // Test cursor hiding lcd_clear(); lcd_gotoxy(0,0); lcd_string("Hide"); lcd_hide(); delay_sec(2); lcd_gotoxy(0,1); lcd_string("Show"); lcd_show(); delay_sec(2); // Now hide it 'cause it's annoying lcd_hide(); // Scroll left lcd_clear(); lcd_gotoxy(0,0); lcd_string("Scroll"); lcd_gotoxy(0,1); lcd_string("Left"); delay_sec(1); for(i=0; i<=LCD_MAX_X; i++) { lcd_shift(0, 1); delay_sec(1); } // Scroll right lcd_clear(); lcd_gotoxy(0,0); lcd_string("Scroll"); lcd_gotoxy(0,1); lcd_string("Right"); delay_sec(1); for(i=0; i<=LCD_MAX_X; i++) { lcd_shift(1, 1); delay_sec(1); } // Show the cursor again lcd_show(); // Cursor left lcd_clear(); lcd_gotoxy(0,0); lcd_string("Cursor"); lcd_gotoxy(0,1); lcd_string("Left"); lcd_gotoxy(7,0); delay_sec(1); for(i=0; i<=LCD_MAX_X; i++) { lcd_moverel(0, 1); delay_sec(1); } // Cursor right lcd_clear(); lcd_gotoxy(0,0); lcd_string("Cursor"); lcd_gotoxy(0,1); lcd_string("Right"); lcd_gotoxy(0,1); delay_sec(1); for(i=0; i<=LCD_MAX_X; i++) { lcd_moverel(1, 1); delay_sec(1); } // Hide the cursor again lcd_hide(); // Moveto (butterfly pattern) lcd_clear(); lcd_gotoxy(0,0); lcd_string("Move-To"); lcd_gotoxy(0,1);); } #endif // _ENABLE_LCD_ // We never get here, but return a zero if we ever do. return 0; }
It is the Orangutan mega168 (
Oh, and about the wrap, no, I was just testing the display. I was just wondering why the second line didn’t show anything, but then I saw that the second line didn’t have the ‘background’ (for lack of a better word).
I probably won’t have a chance to take a look at this until monday, but I suggest you keep playing around with it as I’m not sure how reliable the lcd test program you’re running is. It might also help if you could post a picture of your LCD and its missing background.
- Ben
The Orangutan-Lib demo code assumes that your Orangutan is running at the internal oscillator’s full 8MHz, but if I remember correctly, the ATMega168’s ship with the “Divide Clock by 8 internally” fuse set, so yours is probably running at 1MHz. I just tried that on my Orangutan, and I think I’m seeing what you’re describing. Only the first line displays text, and it has an extra-high contrast dark background, while the second line is completely blank.
If you like you can change the clock speed definition in device.h, but I think the better thing to do is to set your Orangutan to operate at its full 8MHz speed. More example code will work for you that way, and you get 8-times faster program execution! You should always be careful changing fuses though, you can mess things up in a way that’s hard to undo! (Like setting your clock source to something other than the internal oscillator, which is all your Orangutan has installed right now!).
In the programming window, go to the “Fuses” tab. If the option “Divide clock by 8 internally” is checked, un-check it and click Program. Again, be careful not to change any of the other fuse settings.
Did that do it?
-Adam <-who failed to take his own advice, accidentally set the wrong fuse, and has to wire up a low-frequency external crystal oscillator to recover his Orangutan now
lol, was that because of this?
Anyways. I’m on a mac. So I get a terminal window .
As for the device.h thing… I’m using the orangutan line and the timer 2 line. Not sure if that is what you mean or not. This one line thing also happens when I run servo-test… which also doesn’t work btw. Expect a thread on that in the near future.
Yeah, I was being careless and instead of un-checking “Divide clock by 8 internally” I checked “Ext. Clock” and hit program. I do have an external crystal oscillator on the back of my Orangutan, but now I need to de-solder that and hook up an external clock source to be able to set the fuses back. Let this be a lesson.
Anyway, I’m not sure how you would change fuse settings with your setup, maybe someone else here can help you with that.
In the meantime you could change your clock speed definition. In device.h, try changing:
#ifdef ORANGUTAN #ifndef F_CPU #define F_CPU 8000000UL #endif //!F_CPU
to:
#ifdef ORANGUTAN #ifndef F_CPU #define F_CPU 1000000UL #endif //!F_CPU
That should take care of any delay-based timing issues, like the LCD problem, but you still might have trouble with timer/interrupt based example code. I can’t verify this one way or other until I rescue my Orangutan though!
-Adam
Nope. No luck there.
Any other help here is greatly appreciated.
EDIT: Changed the wrong device.h file (Doh!) but still nothing, just runs faster (about 8X maybe )
PIC, to show what I mean: (copy and paste, img won’t work, link doesn’t load because of freehostia) 1244robotics.freehostia.com/orangutan1.gif
PS, that’s my site too, eh. Go 1244!
I’ve caved, I’m downloading AVR studio. I’ll try wine, and if that doesn’t work I’ll use parallels. I’ll try some of the stuff you suggested now.
EDIT: No I won’t. It doesn’t work under wine OR parallels, didn’t expect that. Oh well.
Your mirrored Orangutan image was confusing me there for a second.
Anyway, it’s odd that your code would execute faster (indicating you did change clock speed definition in the right place) but the screen still wouldn’t work. As soon as I get my Orangutan back in action I’ll check it out, but it looks like the LCD code in Orangutan-Lib (and the servo code for that matter) should work fine with just a proper clock speed definition. If you want to be sure that you’re getting the right speed, you can always add the line:
#define F_CPU 1000000
To the very top of your main program file, before the include statements. This will override the settings in device.h.
Yeah, I’ll be really happy the day AVR Studio works with Wine. Or they just make a Linux version. There’s an ATMega8-based tutorial on setting AVR fuses using AVRDude here. It looks a little risky though, you’ve seen what a mis-set fuse can do to your (my) Orangutan! Maybe just use it to check your fuse settings, and see what your clock speed is set to. If you ever do need to make fuse changes, I would try to borrow to a Windows computer just long enough to install AVR studio and change the fuse settings.
-Adam
Okay, I managed to revive my Orangutan, and I’m pretty certain now that the “Divide by 8” fuse is your whole problem (with the servo control sample code too). I took these pictures just now:
The one on the left is what my Orangutan looks like with the “Divide by 8” fuse set, even if I correctly define the CPU frequency as 1MHz. The one on the right is the same code running at 8MHz, with the “Divide by 8” fuse cleared.
A lot of the Orangutan-Lib sample programs rely on your Orangutan operating at either 8 or 20 MHz, and changing the clock definition alone doesn’t seem to fix that. You can control servos and the LCD with the Orangutan operating at 1MHz, but you’re going to have to do some more editing of the Orangutan-Lib code. Orangutan-Lib is a great resource though, and changing that fuse setting (either through AVRDude or by borrowing a Windows computer briefly) seems like a much better way to go to me.
-Adam
So, I only have to set the fuse setting once and its set for good, right?
What about the servo issue, any ideas?
I took a look at the Orangutan-Lib servo library, and its based on an assumption of either an 8MHz clock speed (original Orangutan) or a 20MHz clock speed (Baby Orangutan, Orangutan X2), regardless of the F_CPU defined clock frequency. Looking at the output signal confirms this.
So yes, you only have to clear the “Divide clock by 8 internally” fuse once, and it will stay that way. You shouldn’t have to mess with the fuse settings again after this, unless you’re doing something exotic like adding an external crystal clock. And yes, this should make the Orangutan-Lib servo functions run properly on your Orangutan as well.
-Adam
Sweet. I’ll install AVRStudio and do that tonight.
Thanks Adam, you’ve been a HUGE help.
Hi,
sorry to open up this thread again, but I’ve just bought an Orangutan atmega168 controller and having similar issues. Im only getting the top line of text showing on the LCD, the bottom line is completely blank - I’ve never actually seen it show any kind of life at all.
Im using the “lcd-only” code from the “orangutan-examples-01” posted on sourceforge. all other examples I’ve tried dont work for me at all.
The divide by 8 fuse is un-checked and I dont appear to be having any contrast issues.
does anyone out there have any suggestions for me to try? This is the first time I’ve played with this unit so its a fair chance its something simple I’m missing!
Im using AVR studio 4.
thankyou.
I wish I could remember what I did…
I guess try changing the clock speed in device.h, I’m pretty sure it isn’t set to orangutan by default, baby-o, i think.
unfortunately not the issue here, this code doesnt have a device.h file, everything is written in a single file.
the clock speed is set at 8MHz.
hmmmm, again, I wish I could remember what I did…
Sorry you’re having trouble, but the fact that the LCD is working at all is a good sign.
Do you have the original Orangutan mega168:
or the Orangutan LV-168:
?
And which fuses are checked if you “Read” them back in AVR studio?
Also, are you seeing the first line run through the different words (Hide, Scroll, Cursor, etc…), or is the display just showing one word for as long as you leave it on?
-Adam
P.S. One last thing to try, what happens if you physically disconnect the programmer, then switch power off and back on? AVRISP programmers reset their target microcontrollers after programming them, and sometimes that can mess with time-based operations like the LCD initialization routine.
Hi Adam, thankyou for your suggestions.
I am using the original orangutan mega 168 (same as the top image you posted).
the only fuse set is the SPIEN which is checked, but also has a question mark there also?
the program appears to be running correctly, it is scrolling, hiding, showing, etc in the test loop, however I only see the top line displayed.
also, no change when I disconnect the programmer, and when I turn the unit off the code is lost as Im storing it in flash.
// lcd-only // // Tom Benedict // This is a set of routines to drive the 8x2 LCD display on the // Orangutan controller. The Baby-Orangutan does not have an // LCD on it and I'm not aware of the Orangutan X2's LCD setup // yet, so for the moment this example is strictly for the // Orangutan. // // The Orangutan drives the LCD in 4-bit mode with E, R/W, and // RS control lines. Here are the pin assignments: // // AVR LCD Direction Function // ------ ------ -------------- ---------------------------- // PD4 E Out Dedicated to LCD Enable // PD2 RS Out Dedicated to LCD ??? // PD3 R/W Out Dedicated to LCD Read/Write // PD7 DB7 In/Out Dedicated to LCD I/O // PB5 DB6 Out LCD I/O and Orangutan SW5 // PB4 DB5 Out LCD I/O and Orangutan SW4 // PB3 DB4 Out LCD I/O and Orangutan SW3 // N/C DB3 // N/C DB2 // N/C DB1 // N/C DB0 // As you can see, three of the four data lines are also tasked to // the three push buttons on the Orangutan. What this means is that // we need to keep track of this and that we can't use the buttons // when the LCD is being written to. We have no gurantee what state // those lines are in, so we need to return them to whatever state // they were in once we're done using them. // // So let's get to it! // Declare your CPU speed based on which device you're using // Just uncomment the value for F_CPU that corresponds to the // device you're building for: // The Orangutan is an 8MHz device #ifndef F_CPU #define F_CPU 8000000UL #endif //!F_CPU // #define F_CPU 8000000UL // The Baby-Orangutan is a 20MHz device // So is the Orangutan-X2 // #define F_CPU 20000000UL #include <avr/io.h> // Unlike most of the other examples, the LCD relies heavily on // delays. So it's required to set F_CPU and include <util/delay.h> // not just for the purpose of this demonstration, but for the LCD // code to work at all. #include <util/delay.h> // Because the LCD routines don't have exclusive rights to PB3, PB4, // and PB5, we need to declare a mask we can use to toggle the state // of those pins in the data direction register. Likewise, since // we're going to use PD7 as both input and output, we need to // declare a mask for PORTD so we can toggle the input/output bit in // DDRD. // Port Masks #define PORTB_MASK 0x38 // PB3, PB4, PB5 #define PORTD_MASK 0x80 // PD7 // Since we're only using four data lines, and since the pins they're // wired up to don't start with 0, we need to shift them into // position in order to load their values into the LCD. Port B uses // bits 3, 4, and 5, so we take our data and shift it by three // positions to make things line up. At that point our data // looks like this: // // PortB: 7 6 5 4 3 2 1 0 // LCD Data: 3 2 1 0 // // The last bit for the LCD needs to go out PortD on pin 7, so we // do one last shift to make its data line up. // // Sorry this is so confusing. It'll make more sense in the // lcd_nibble() routine, which is where these shift values // actually get used. #define PORTB_SHIFT 3 #define PORTD_SHIFT 1 // Just in case the Orangutan X2 uses a different setup for its LCD, // declaring the control pins here will make it easier to set the // code up to compile for it at a later date. // Control Pins #define LCD_RW PD3 #define LCD_RS PD2 #define LCD_E PD4 // These commands are all straight out of the data sheet for the LCD // installed on the Orangutan. // Commands #define LCD_CLEAR 0x01 #define LCD_LINE1 0x02 #define LCD_LINE2 0xC0 #define LCD_SHOW_BLINK 0x0F #define LCD_SHOW_SOLID 0x0E #define LCD_HIDE 0x0C #define LCD_CURSOR_L 0x10 #define LCD_CURSOR_R 0x14 #define LCD_SHIFT_L 0x18 #define LCD_SHIFT_R 0x1C // Usually I try to put initialization routines first in the list, // but the LCD requires its communication routines to be // established before you can initialize it. So we'll start // with the basic communication routine: Send a four-bit nibble // to the LCD. // // lcd_nibble() assumes ports B and D already have their DDR set // correctly, and assumes PD7 is an output. It's the job of the // routines that call lcd_nibble() to make sure these conditions // are met. void lcd_nibble(unsigned char nibble) { // Make sure our nibble really is a nibble. This chops off // the high four bits of the data we're given. nibble &= 0x0F; // Shift our nibble so bits 0, 1, and 2 line up with PB3, PB4, // and PB5: nibble <<= PORTB_SHIFT; // Clear those bits out of PORTB so we can write into them: PORTB &= ~PORTB_MASK; // And load PORTB with those three bits: PORTB |= (nibble & PORTB_MASK); // Now shift our nibble so bit 3 lines up with PD7: nibble <<= PORTD_SHIFT; // Clear that bit out of PORTD so we can write into it: PORTD &= ~PORTD_MASK; // And load pORTD with that last bit: PORTD |= (nibble & PORTD_MASK); // Delay for 1ms so the LCD can register it's got the nibble: _delay_ms(1); // At this point the four data lines are set, so the Enable pin // is strobed to let the LCD latch them. // // The LCD device is highly dependent on delaying for a proper // length of time. For a 20MHz device, 5 clock cycles is enough // of a delay for the LCD to latch its inputs. Delaying too // long is better than not delaying long enough, so this same // delay should work on slower devices as well. // Bring E high PORTD |= (1 << LCD_E); asm( "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" ::); // Bring E low PORTD &= ~(1 << LCD_E); asm( "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" ::); // Our nibble has now been sent to the LCD. } // lcd_send writes one byte to the LCD (or rather, it sends two nibbles) // // This is the command where all the registers get saved, loaded, and // restored at the end. It assumes nothing about the state of ports // B or D, and is the routine that actually sets them correctly, // restoring them when it's done. // // It's this trickery that lets us have pushbuttons on the same lines // we use to talk to the LCD. This is neat, since we basically get // three pushbuttons without eating up any additional I/O lines. void lcd_send(unsigned char data) { unsigned char temp_ddrb, temp_portb, temp_ddrd, temp_portd; // Store our port settings temp_ddrb = DDRB; temp_portb = PORTB; temp_ddrd = DDRD; temp_portd = PORTD; // Set up port I/O to match what the LCD needs DDRB |= PORTB_MASK; DDRD |= PORTD_MASK; // Send the data lcd_nibble(data >> 4); // High nibble first lcd_nibble(data); // Low nibble second // Restore our port settings DDRD = temp_ddrd; PORTD = temp_portd; DDRB = temp_ddrb; PORTB = temp_portb; } // The next two commands are almost identical. One sends a command // to the LCD. The other sends data. The distinction between the // two is the state of the RS line. For commands, RS is held low. // For data, it's held high. // // One other gotcha: The LCD takes a while to process commands. // So the lcd_cmd() command also includes a short delay to let this // happen before anything else is sent to the LCD. void lcd_cmd(unsigned char cmd) { // Hold RW and RS low PORTD &= !((1 << LCD_RW) | (1 << LCD_RS)); // Send the command lcd_send(cmd); // Delay for 1ms to let the command process _delay_ms(1); } void lcd_data(unsigned char data) { // Hold RW low PORTD &= ~(1 << LCD_RW); // Hold RS high PORTD |= (1 << LCD_RS); // Send the data. No waits, so we can go right into sending more // data. lcd_send(data); } // lcd_string sends a string to the LCD. You can send a string // longer than 8 characters, but only eight characters show up. // The string is printed from wherever the cursor is, and will // not span lines. (This lets you concatenate print statements.) void lcd_string(const unsigned char *str) { while (*str != 0) lcd_data(*str++); } // lcd_int prints an integer. Again, this prints from wherever // the cursor is, and will not span lines. (This lets you // concatenate print statements.) void lcd_int(unsigned char n) { unsigned char st[4] = {0,0,0,0}; // The 0x30 addition shifts the decimal number up // to the ASCII location of "0". // Hundreds place st[0] = (n / 100) + 0x30; n = n % 100; // Tens place st[1] = (n / 10) + 0x30; n = n % 10; // Ones place st[2] = n + 0x30; // Print it as a string lcd_string(st); } // lcd_init initializes the LCD and MUST be called prior to // every other LCD command. void lcd_init(void) { // This is done once, and is never checked or set afterward // These are dedicated lines, so this shouldn't be a problem // provided the rest of the program doesn't dink with it. DDRD |= (1 << LCD_RW) | (1 << LCD_RS) | (1 << LCD_E); // This next block is straight out of the data sheet for the // LCD. It's how to wake up the LCD using commands rather // than using a specialized power-up sequence. _delay_ms(30); lcd_cmd(0x30); // 8-bit mode (wake up!) _delay_ms(5); lcd_cmd(0x30); // 8-bit mode (wake up!) _delay_ms(1); lcd_cmd(0x30); // 8-bit mode (wake up!) _delay_ms(1); lcd_cmd(0x32); // 4-bit mode // Now we actually set up the LCD the way we want. The // controller chip inside the LCD module is actually // used on a number of LCDs of various sizes. It's nice // since we can recycle this code for other display sizes. // It's not quite so nice because the controller makes NO // assumptions about the LCD it's driving. You have to // tell it EVERYTHING. lcd_cmd(0x20); lcd_cmd(0x28); // 4-bit mode, 2-line, 5x8 dots/char lcd_cmd(0x08); // Display off, cursor off, blink off lcd_cmd(0x01); // Clear display lcd_cmd(0x0F); // Display on, cursor on, blink on lcd_cmd(0x02); // Return home lcd_cmd(0x01); // Clear display // At this point we're good to go. } // The rest of the routines for the LCD just send one of the command // values to the LCD. They're all listed above as #defines. It's // not too onerous a task to make most, if not all of these routines // inline #defines. But for the sake of clarity only a handful are // written this way. // lcd_moveto moves the cursor to the given position on the LCD // screen. It does this by using one of the following address // locations on the LCD: // // Character 0 1 2 3 4 5 6 7 // ------------------------ // Line 1 80 81 82 83 84 85 86 87 // Line 2 C0 C1 C2 C3 C4 C5 C6 C7 // // It's pretty straightforward to let the programmer give us a // line and character position, and crank out the proper // address so they don't have to worry about it. void lcd_moveto(unsigned char line, unsigned char pos) { // In case this is the first time you've seen this notation, it's // a neat way of doing a comparison. If line is equal to 1, // use 0x80, otherwise 0xC), and add the character position to it. lcd_cmd((line == 1 ? 0x80 : 0xC0) + pos); } // lcd_moverel shifts the cursor left or right the given number of // positions. // // dir = 0 Shift left // 1 Shift right void lcd_moverel(unsigned char dir, unsigned char num) { unsigned char cmd; cmd = dir ? LCD_CURSOR_R : LCD_CURSOR_L; while(num-- > 0) lcd_cmd(cmd); } // lcd_shift shifts the display left or right the given number of // positions. This is what you'd use for a scrolling display. // // dir = 0 Shift left // 1 Shift right void lcd_shift(unsigned char dir, unsigned char num) { unsigned char cmd; cmd = dir ? LCD_SHIFT_R : LCD_SHIFT_L; while(num-- > 0) lcd_cmd(cmd); } // The rest of these are one-liners. Send the appropriate command // to the LCD, and it takes care of the rest: // Clear the LCD #define lcd_clear() lcd_cmd(LCD_CLEAR) // Move the cursor to the beginning of line 1 #define lcd_line1() lcd_cmd(LCD_LINE1) // Move the cursor to the beginning of line 2 #define lcd_line2() lcd_cmd(LCD_LINE2) // Show the cursor as a blinking block. (A non-blinking cursor is // also available.) #define lcd_show() lcd_cmd(LCD_SHOW_BLINK) // Hide the cursor. #define lcd_hide() lcd_cmd(LCD_HIDE) // That's really it for the LCD stuff (and it's plenty!). The only // other subroutine is a delay routine that will let us pause for a // couple of seconds. Almost all the example code will have this // routine in(25); } } // And now for our main routine: int main(void) { int i; // Make sure all our registers are clear DDRB = 0; DDRC = 0; DDRD = 0; PORTB = 0; PORTC = 0; PORTD = 0; // Initialize the LCD lcd_init(); for(;;) { // Startup Banner lcd_clear(); lcd_line1(); lcd_string("LCD"); lcd_line2(); lcd_string("Test..."); delay_sec(2); // Test multiline display lcd_clear(); lcd_line1(); lcd_string("Line 1"); lcd_line2(); lcd_string("Line 2"); delay_sec(2); // Test cursor hiding lcd_clear(); lcd_line1(); lcd_string("Hide"); lcd_hide(); delay_sec(2); lcd_line2(); lcd_string("Show"); lcd_show(); delay_sec(2); // Scroll left lcd_clear(); lcd_line1(); lcd_string("Scroll"); lcd_line2(); lcd_string("Left"); delay_sec(1); for(i=0; i<8; i++) { lcd_shift(0, 1); delay_sec(1); } // Scroll right lcd_clear(); lcd_line1(); lcd_string("Scroll"); lcd_line2(); lcd_string("Right"); delay_sec(1); for(i=0; i<8; i++) { lcd_shift(1, 1); delay_sec(1); } // Cursor left lcd_clear(); lcd_line1(); lcd_string("Cursor"); lcd_line2(); lcd_string("Left"); lcd_moveto(2,7); delay_sec(1); for(i=0; i<8; i++) { lcd_moverel(0, 1); delay_sec(1); } // Cursor right lcd_clear(); lcd_line1(); lcd_string("Cursor"); lcd_line2(); lcd_string("Right"); lcd_moveto(2,0); delay_sec(1); for(i=0; i<8; i++) { lcd_moverel(1, 1); delay_sec(1); } // Moveto (butterfly pattern) lcd_clear(); lcd_line1(); lcd_string("Move-To"); lcd_line2();); } // We nevre get here, but return a zero if we ever do. return 0; } | https://forum.pololu.com/t/new-orangutan-one-line-only-lcd/1011 | CC-MAIN-2022-21 | refinedweb | 4,360 | 68.1 |
I wrote a program that calculates the weekly pay for five people for my C programming class, but I'm having trouble with it when I try to compile and debug it. At first it would prompt me for the name, hours worked, and hourly rate, but would output $0 for everything. And now, (I don't know what I did), it won't even execute the program. Instead, I'll just get this error message: An unhandled exception of type 'System.AccessViolationException' occurred in hourlyratearray.exe
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Below is the code for my program. What am I doing wrong?
Thanks in advance!
Code:
#include <stdio.h>
#include <string.h>
int main(void)
{
int i;
double hourlyRate[5], hoursWorked[5], taxesOwed[5], overTime[5], netPay[5], grossPay[5], basePay[5];
char name[5];
// gathers info
for (i=0; i<5; i++)
{
printf("Enter name.\n");
scanf("%s", &name[i]);
printf("What is their hourly rate?\n");
scanf("%f", &hourlyRate[i]);
printf("How many hours did they work this week?\n");
scanf("%f", &hoursWorked[i]);
// processes input
if( name[i] == -1 || hourlyRate[i] == -1 || hoursWorked[i] == -1)
{
printf("please reenter a nonnegative number");
break;
}
if(hoursWorked[i] > 40)
{
basePay[i] = hourlyRate[i] * hoursWorked[i];
overTime[i] = (hoursWorked[i] - 40) * 1.5 * hourlyRate[i];
taxesOwed[i] = ((hourlyRate[i]*40) + overTime[i])*.2;
netPay[i] = (hourlyRate[i]*40) + overTime[i] - taxesOwed[i];
printf("%s: \n", name[i]);
printf("Hours worked: %f\n", hoursWorked[i]);
printf("Hourly rate: $%.2f\n", hourlyRate[i]);
printf("Base pay: $%.2f\n", basePay[i]);
printf("Overtime pay: $%.2f\n", overTime[i]);
printf("Taxes paid: $%.2f\n", taxesOwed[i]);
printf("Net pay: $%.2f\n", netPay[i]);
}
else
{
basePay[i] = hourlyRate[i] * hoursWorked[i];
taxesOwed[i] = (hourlyRate[i]*40) * .2;
netPay[i] = (hourlyRate[i]*40) - taxesOwed[i];
printf("%s: \n", name[i]);
printf("Hours worked: %f\n", hoursWorked[i]);
printf("Hourly rate: $%.2f\n", hourlyRate[i]);
printf("Base pay: $%.2f\n", basePay[i]);
printf("Taxes paid: $%.2f\n", taxesOwed[i]);
printf("Net pay: $%.2f\n", netPay[i]);
}
}
return 0;
} | http://cboard.cprogramming.com/c-programming/104242-having-problems-arrays-printable-thread.html | CC-MAIN-2014-42 | refinedweb | 356 | 62.24 |
Produce filled convex hulls around a set of points. More...
#include <vtkConvexHull2D.h>
Produce filled convex hulls around a set of points.
Produces a vtkPolyData comprised of a filled polygon of the convex hull of the input points. You may alternatively choose to output a bounding rectangle. Static methods are provided that calculate a (counter-clockwise) hull based on a set of input points.
To help maintain the property of guaranteed visibility hulls may be artificially scaled by setting MinHullSizeInWorld. This is particularly helpful in the case that there are only one or two points as it avoids producing a degenerate polygon. This setting is also available as an argument to the static methods.
Setting a vtkRenderer on the filter enables the possibility to set MinHullSizeInDisplay to the desired number of display pixels to cover in each of the x- and y-dimensions.
Setting OutlineOn() additionally produces an outline of the hull on output port 1.
Definition at line 63 of file vtkConvexHull2D.h.
Definition at line 67 of file vtkConvexHull2D.h.
Definition at line 87 of file vtkConvexHull.
Scale the hull by the amount specified.
Defaults to 1.0.
Produce an outline (polyline) of the hull on output port 1.
Set the shape of the hull to BoundingRectangle or ConvexHull.
Set the minimum x,y-dimensions of each hull in world coordinates.
Defaults to 1.0. Set to 0.0 to disable.
Set the minimum x,y-dimensions of each hull in pixels.
You must also set a vtkRenderer. Defaults to 1. Set to 0 to disable.
Renderer needed for MinHullSizeInDisplay calculation.
Not reference counted.
Convenience methods to calculate a convex hull from a set of vtkPointS.
This is called by the superclass.
This is the method you should override.
Reimplemented from vtkPolyDataAlgorithm. | https://vtk.org/doc/nightly/html/classvtkConvexHull2D.html | CC-MAIN-2021-10 | refinedweb | 294 | 62.24 |
Created by .
Last modified on 2005/02/27.
This How-To describes specifically how to get SQL data into a ZCatalog for searching, but the principles here can be used to put just about anything into the catalog.
Disclaimer: This information is based on my experience using ZCatalog with SQL and other external data. It is not based on deep knowledge of the inner workings of the catalog, so this may or may not be making use of the catalog as it was designed to be used.
There are some basic things about ZCatalog that you should understand before trying this procedure. If are not already very familiar with how ZCatalog works, you should read Chapter 9 of the Zope Book before you continue.
To summarize what you need to know, a ZCatalog (hereinafter referred to as just the catalog) stores 2 main types of information for each object in the catalog: indexes and meta data. The indexes are used during the search to find objects based on search parameters, and the meta data is made available as the results of a matching object. For example, if I have an index PrincipiaSearchSource that contains the text of a document object, I can search document text by using that index. If I have a meta data title, I will be able to display the title of the object when it's returned in the list of search results.
PrincipiaSearchSource
title
The catalog stores information from an object by going through each defined index and meta data name. If the object either has a property or a method with the same name, that information is taken from the object and stored in the catalog. When searching on the catalog, a special result object is returned for each match, not the object that was cataloged (since it is never actually stored in the catalog). These are two very important things to understand and remember.
One discovery I made (maybe it's documented somewhere other than the source code, I don't know), is that the unique ID under which an object is cataloged is used to construct the URL returned by the result object's getURL() method. This comes in very handy when cataloging things that are not in the object database. You can catalog an object that contains the appropriate index and meta data information, but use your own uid to construct the URL you want used when the object shows up in the search results. This should make more sense as you follow the examples below.
getURL()
uid
The first step in any search is to set up the catalog. There is no difference in setting up a catalog for "normal" searches and setting one up for a search of SQL data, so I'm not going to go into detail here on how to do that. Just make sure you have created a catalog with the desired indexes and meta data.
There are two main steps in cataloging the SQL data: 1) setup a ZSQL Method that returns the fields you wish to store in indexes and/or meta data, and 2) create a script that calls catalog_object() on each record returned by the ZSQL Method. These two steps are described in detail below.
catalog_object()
Creating a ZSQL Method
Before you can catalog SQL data, you must be able to tell the catalog what data you want it to store. You do this by creating a ZSQL Method that returns records whose field names correspond to the indexes and/or meta data names in the catalog.
For example, the SQL table Books contains the following fields:
Books
Number, Title, Author, Description, Price
PrincipiaSearchSource, bobobase_modification_time, id, meta_type, title
bobobase_modification_time, id, meta_type, summary, title
If you want the PrincipiaSearchSource index to contain the Description, Title, and Author SQL fields, the summary meta data to contain the Description, and the book Number to be the id, you could use the following ZSQL Method (named getBooksToCatalog):
Description
Title
Author
summary
Number
id
SELECT Number, Title,
concat(Description, Title, Author) as PrincipiaSearchSource,
'Book' as meta_type, Number as id, Description as summary
FROM Books
You now have a ZSQL Method that will return a list of all of the books using field names that match the indexes and meta data of the catalog. I use Book as the meta_type so that I can easily know in the search results that the object refers to a book. It's a nice feature for me, but it isn't necessary for this to work. This illustrates the point that you can provide static information to be stored in the catalog by including it in your query with the desired meta data name.
Book
Now that you have a list of records you want to store, you need to create a script that will iterate over the list and add the information to the catalog. This is easily done with a Python Script. This script is created in the catalog object itself. If you place it anywhere else (it really doesn't matter where), you will need to modify it so that it can find the catalog. Since this script is in the catalog, you can just use the bound variable container to access it. The following script (named catalogBooks) will do the job::
container
catalogBooks
for book in container.getBooksToCatalog():
container.catalog_object(book,
'/Publications/getBook/+book.Number+/bookdetails.html')
print Book # + book.Number
return printed
+book.Number+
Book #
This iterates over the records returned by the ZSQL Method created above, and calls catalog_object() on each. This is where most of the magic happens. Each book number that is cataloged will be printed, one per line...nothing fancy. You don't need the print statements, but it gives some reassuring feedback.
catalog_object() takes two parameters: 1) the object to be cataloged, and 2) a unique ID (uid). The object is a record from the ZSQL Method, and as mentioned above, the uid is used to form the URL that will be returned by the result object's getURL() method. The use of the uid will be explained in detail in the next section.
All you need to do now is execute the script and the data will be put in the catalog. You can run the script either through the Test tab in the management interface, or by entering its URL in your browser. Either way will work the same. You can browse through the catalog to verify that the indexes and meta data have been filled in as expected.
Test
A catalog search returns a list of matching result records. As with creating the catalog, there is no difference in how you search a catalog with SQL data in it. The difference is in the result object's URL. The URL as returned by getURL() does not reference an actual object in the object database. Instead, the uid used to catalog the SQL data will cause getURL() to return URLs like. This URL refers to a ZSQL Method getBook and a DTML Method bookdetails.html, that when used together will display the information on that book. This is actually a feature of Zope and ZSQL Methods. It has nothing to do with the catalog, but it's included here to illustrate the use of the uid.
getBook
bookdetails.html
The folder Publications contains the methods for displaying the information on a book:
Publications
number
SELECT * FROM Books WHERE
dtml-var
<dtml-var
<TABLE><TR>
<TD>Book Number</TD><TD><dtml-var Number></TD>
<TD>Description</TD><TD><dtml-var Description></TD>
</TR></TABLE>
<dtml-var
If you provide links using getURL() on the results page of a search, you can use whatever uid suits you for creating URLs that will displaying the SQL data.
Using a process similar to that above, you can catalog just about anything. As demonstrated above, it doesn't actually have to be an object in the Zope object database. It's a virtual object. If the object you pass to catalog_object() has properties or methods with the same name as the indexes and/or meta data of your catalog, you can add it to the catalog. Note that it is not necessary to provide all index and meta data information in object to be cataloged. If an object doesn't have a particular property or method with the same name as an index/meta data, it is ignored and left blank in the catalog. The key to allowing the user to view the virtual object is in the uid used when cataloging the information. You just need to construct a uid (and thus a valid URL) that will display the object.
If this doesn't make sense, the following example will hopefully help.
What Is Already There
In this example, there are a set of articles in PDF format that can be viewed online. Each article is listed in the SQL table Articles with the following fields:
Articles
Number, Title, Author, Description, Filename
The first four fields should be self explanatory. The Filename field contains the filename of the PDF document associated with the article. The PDF documents are stored on the file system in a directory accessible via a URL such as. They are not stored in the Zope object database.
Filename
The site contains the ZSQL Method getArticle and the DTML Method articledetails.html that show the article information stored in the SQL table (similar to what was used in the book example above). This "preview" of the article also includes a link to the PDF document so that it can be downloaded or viewed through a browser plug-in.
getArticle
articledetails.html
getArticle is as follows:
SELECT * FROM Articles WHERE <dtml-sqltest number column="Number" type=nb>
A very plain version of articledetails.html might is as follows:
<dtml-var
<TABLE><TR>
<TD>Article Number</TD><TD><dtml-var Number></TD>
<TD>Description</TD><TD><dtml-var Description></TD>
<TD>PDF</TD><TD><A HREF="/pdfdocs/&dtml-Filename;">View/Download</A></TD>
</TR></TABLE>
<dtml-var
The goal is to be able to search the text of the article, but have the results direct the user to the article display page above where they can then view the PDF document.
First, create a catalog that contains the following indexes and meta data:
To get a list of the articles to catalog, start with the following ZSQL Method 'getArticlesToCatalog':
SELECT Number, Title, 'Article' as meta_type, Filename
FROM Books
This gives you a list of the articles, but in order to search the text of the PDF document, the text needs to be stored in the PrincipiaSearchSource index. Since the document source is not in the database, you can't just return it using the ZSQL Method as you did with the book descriptions above.
This where it gets exciting. You need to get the records from the ZSQL Method results to return the text of the PDF document as the PrincipiaSearchSource. To do this, you need to use an advanced feature of ZSQL Methods to assign the record to a class. But first you must create the class.
Since Zope cannot read PDF documents, and I don't know of any Python modules that will do it, you must first convert the PDF documents into corresponding text files so that Zope can read the article text. There are a number of tools you can use to do this very quickly and with little effort.
Next, create a file sqlrecord.py in the Extensions directory of your Zope installation that contains the following source code::
sqlrecord.py
Extensions
from string import split
class Article:
"""Class used by ZSQL for indexing articles"""
def id(self):
"""Use article file as id"""
return split(self.Filename, .)[0]
.
def PrincipiaSearchSource(self):
"""Read article text"""
# Get the .txt version of the .pdf filename
basename = split(self.Filename, '.)[0]
filename = /path-to-docs/pdfdocs/+basename+.txt'
)[0]
filename =
+basename+
try:
fp = open(filename, r)
except IOError:
return ''
r
text = fp.read()
fp.close()
return text
You will need to modify the path information to point to the directory where the converted .txt files are.
Now go to the Advanced tab of the getArticlesToCatalog ZSQL Method and enter Article as the Class Name and sqlrecord as the Class File. The Article class will now provide the methods id() and PrincipiaSearchSource() that can be used by the ZSQL Method to provide information to the catalog.
Advanced
getArticlesToCatalog
Article
sqlrecord
id()
PrincipiaSearchSource()
The final step is to create the Python Script the iterates over each ZSQL record and passes it to catalog_object(). The following script (named catalogArticles) will do the job. As with the book example, if you do not place this script in the catalog object itself, you must modify container to be your catalog:
catalogArticles
for article in container.getArticlesToCatalog():
container.catalog_object(article,
'/Publications/getArticle/'+article.Number+'/articledetails.html')
print 'Article #' + article.Number
return printed
When you run this script, Zope will use getArticlesToCatalog, along with the associated class methods, to store the article information and searchable text in the catalog. As you can see from the uid in the catalogArticles script, the search result object will provide URLs that point to the "preview" of the article described above, where the user can then select to view the PDF article. You could also provide a uid that points directly to the PDF file if you wanted to skip the preview.
You can see by example that the possibilities of what can be stored in the catalog are great. Although both examples used SQL data, there's no reason you can't use an object that gets the index and meta data information from the Zope object database, other external files, remote data on other servers, or any combination of the above. If you can create an object that gathers the appropriate information, you can stick it in the catalog.
I hope this How-To has been helpful. If you have any questions, comments, or information to improve this process, please let me know. | http://old.zope.org/Members/rbickers/cataloganything/ | crawl-003 | refinedweb | 2,344 | 59.23 |
Make a Picture Voting Game with Node.js (Part 2)
In the first part of this tutorial, we laid down the foundation of our node.js web app. You learned about running and installing node, about npm and the nedb library, and we even wrote our first module. This week we will continue with the routes and views of our picture voting app.
The Routes and Configuration Files
Last week we made a module that handles the initialization of two datasets - users and photos. These datasets were exported by the module, which allows us to require it and access them in our other js files. We will do this is in our routes.js file, which holds all the routes that the application will respond to.
routes.js
/** * This file defines the routes used in your application * It requires the database module that we wrote previously. */ var db = require('./database'), photos = db.photos, users = db.users; module.exports = function(app){ // Homepage app.get('/', function(req, res){ // Find all photos photos.find({}, function(err, all_photos){ // Find the current user users.find({ip: req.ip}, function(err, u){ var voted_on = []; if(u.length == 1){ voted_on = u[0].votes; } // Find which photos the user hasn't still voted on var not_voted_on = all_photos.filter(function(photo){ return voted_on.indexOf(photo._id) == -1; }); var image_to_show = null; if(not_voted_on.length > 0){ // Choose a random image from the array image_to_show = not_voted_on[Math.floor(Math.random()*not_voted_on.length)]; } res.render('home', { photo: image_to_show }); }); }); }); app.get('/standings', function(req, res){ photos.find({}, function(err, all_photos){ // Sort the photos all_photos.sort(function(p1, p2){ return (p2.likes - p2.dislikes) - (p1.likes - p1.dislikes); }); // Render the standings template and pass the photos res.render('standings', { standings: all_photos }); }); }); // This is executed before the next two post requests app.post('*', function(req, res, next){ // Register the user in the database by ip address users.insert({ ip: req.ip, votes: [] }, function(){ // Continue with the other routes next(); }); }); app.post('/notcute', vote); app.post('/cute', vote); function vote(req, res){ // Which field to increment, depending on the path var what = { '/notcute': {dislikes:1}, '/cute': {likes:1} }; // Find the photo, increment the vote counter and mark that the user has voted on it. photos.find({ name: req.body.photo }, function(err, found){ if(found.length == 1){ photos.update(found[0], {$inc : what[req.path]}); users.update({ip: req.ip}, { $addToSet: { votes: found[0]._id}}, function(){ res.redirect('../'); }); } else{ res.redirect('../'); } }); } };
Here
app is an instance of an Express.js web application that we will create in our index.js file. We are exporting a function which takes the app as an argument, which allows us to inject it as a dependency later on.
The next file that we will write, is a configuration file that sets some settings for our application:
config.js
/** * This file runs some configuration settings on your express application. */ // Include the handlebars templating library var handlebars = require('express3-handlebars'), express = require('express'); // Require()-ing this module will return a function // that the index.js file will use to configure the // express application module.exports = function(app){ // Register and configure the handlebars templating engine app.engine('html', handlebars({ defaultLayout: 'main', extname: ".html", layoutsDir: __dirname + '/views/layouts' })); // Set .html as the default template extension app.set('view engine', 'html'); // Tell express where it can find the templates app.set('views', __dirname + '/views'); // Make the files in the public folder available to the world app.use(express.static(__dirname + '/public')); // Parse POST request data. It will be available in the req.body object app.use(express.urlencoded()); };
We are using the handlebars templating engine for our views (with the help of this adapter library), because it is easy to write and supports layout views. A layout will allow us to share a common design for all our pages, which is a big time saver. The code above also uses the static connect middleware to serve the files in the /public folder. This is the best way to make all the site assets accessible from a web browser.
The next file is index.js, which ties all of these modules together, and initializes a new Express.js application for us:
index.js
/** * This is the main file of the application. Run it with the * `node index.js` command from your terminal * * Remember to run `npm install` in the project folder, so * all the required libraries are downloaded and installed. */ var express = require('express'); // Create a new express.js web app: var app = express(); // Configure express with the settings found in // our config.js file require('./config')(app); // Add the routes that the app will react to, // as defined in our routes.js file require('./routes')(app); // This file has been called directly with // `node index.js`. Start the server! app.listen(8080); console.log('Your application is running on');
Great! Our app is taking shape! To start it, execute the command
node index.js, and the server will start listening on port 8080. However, if you try opening, it in your browser at this point, you will only see error messages for missing template files. This is because we haven't yet written our views.
The Views
The first view that we will create, is the layout. This file will define the common HTML that is shared by the other pages of our site. Your app may have more than one layout (for example if you wish to have separate designs for your home page and for your administration screens), but we will only have one here.
views/layouts/main.html
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>Node.js Picture Voting Game</title> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link href="" rel="stylesheet" /> <link href="css/styles.css" rel="stylesheet" /> </head> <body> <header> <h1><span class="green">Cute</span> or <span class="red">NOT?</span></h1> <h2>A Node.js Voting Game</h2> </header> {{{body}}} <footer> <a class="tz" href="">Tutorial: Node.js Picture Voting Game</a> </body> </html>
The
{{{body}}} tag is automatically replaced by the HTML of the other views that use this layout. Here is the HTML specific to the index page:
views/home.html
<nav> <a class="active" href="./">Game</a> <a href="./standings">Standings</a> </nav> {{#if photo}} <img src="photos/{{photo.name}}" width="530" height="420" alt="Cat Picture" /> <div class="button-holder"> <form action="./cute" method="post"> <input type="hidden" name="photo" value="{{photo.name}}" /> <input type="submit" value="Cute!" /> </form> <form action="./notcute" method="post"> <input type="hidden" name="photo" value="{{photo.name}}" /> <input type="submit" value="Not Cute!" /> </form> </div> {{else}} <h3>No more photos to vote on! Check out the <a href="./standings">standings</a>.</h3> {{/if}}
Handlebars templates can have if/else constructs, loops and lots of other features that allow you to write clean HTML. And here is the template for the standings page:
views/standings.html
<nav> <a href="./">Game</a> <a class="active" href="./standings">Standings</a> </nav> {{#if standings}} <ul> {{#each standings}} <li> <img src="photos/{{name}}" alt="Cat picture thumbnail" /> <p class="up">{{this.likes}}</p> <p class="down">{{this.dislikes}}</p> </li> {{/each}} </ul> {{/if}}
By using templates we are able to separate the code for presenting the data from the data itself. You can use many different template engines in your express web application.
We're Done!
With this, our Node.js picture voting game is complete! You can enhance it with some of the countless node.js modules and libraries and modify it in any way that you wish. I hope that you found this tutorial useful! If you have any suggestions, bring them to the comment section below.
Presenting Bootstrap Studio
a revolutionary tool that developers and designers use to create
beautiful interfaces using the Bootstrap Framework.
How are you passing the IP address onto the visitor? If I run the node app at the port like domain:8080 it works fine, but when i use an Apache using Proxypass it doesn't pass the IP, so if i vote on all the pictures from my IP, and I give the URL to someone else, it shows them that all images have been voted on, curious on your setup how you do this.
To everyone who is reading this, if you run into this problem, simply add this setting to your config.js file:
When you run your node.js app behind Apache or Nginx, your app will always get 127.0.0.1 as the IP address of the visitor. Adding the 'trust proxy' setting tells express.js to work around this problem.
thanks for the trust proxy tip, i hacked together a startup script so the nodeapp starts on boot
Node.js is really powerful! Thanks for sharing.
Could you talk a little bit about deployment strategies? I'd be interested in a controlled host (e.g., Bluehost), or generally anywhere without sudo or apache, or a cloud based solution. | https://tutorialzine.com/2014/01/nodejs-picture-voting-game-part-2 | CC-MAIN-2017-47 | refinedweb | 1,493 | 61.43 |
R is much more magical than Python. What do I mean by this? In R, things like this are a part of everyday life:
> a <- rnorm(10) > b <- rnorm(10) > cbind(a, b) a b [1,] 0.8729978 0.5170078 [2,] -0.6885048 -0.4430447 [3,] 0.4017740 1.8985843 [4,] 2.1088905 -1.4121763 [5,] 0.9375273 0.4703302 [6,] 0.5558276 -0.5825152 [7,] -2.1606252 0.7379874 [8,] -0.7651046 -0.4534345 [9,] -4.2604901 0.9561077 [10,] 0.3940632 -0.8331285
If you're a seasoned Python programmer, you might have the sort of visceral negative reaction that I do to this. Seriously, just where in the hell did those variable names come from? So when I say magic here I'm talking about abusing the language's parser. There is nothing special about R that makes the above behavior possible, but rather taking a fundamentally different design philosophy to, say, Python. As any Python programmer knows: Explicit is better than implicit. I happen to agree. There is also a bit of a semantic difference in R versus Python in that assignment in R typically copies data, whereas variables in Python are simply references (labels) for a particular object. So you could make the argument that the names
a and
b above are more strongly linked to the underlying data.
While building pandas over the last several years, I occasionally grapple with issues like the above. Maybe I should just break from Python ethos and embrace magic? I mean, how hard would it be to get the above behavior in Python? Python gives you stack frames and the ast module after all. So I went down the rabbit hole and wrote this little code snippet:
from pandas.util.testing import set_trace import pandas.util.testing as tm from pandas import * import ast import inspect import sys def merge(a, b): f, args, _ = parse_stmt(inspect.currentframe().f_back) return DataFrame({args[0] : a, args[1] : b}) def parse_stmt(frame): info = inspect.getframeinfo(frame) call = info[-2][0] mod = ast.parse(call) body = mod.body[0] if isinstance(body, (ast.Assign, ast.Expr)): call = body.value elif isinstance(body, ast.Call): call = body return _parse_call(call) def _parse_call(call): func = _maybe_format_attribute(call.func) str_args = [] for arg in call.args: if isinstance(arg, ast.Name): str_args.append(arg.id) elif isinstance(arg, ast.Call): formatted = _format_call(arg) str_args.append(formatted) return func, str_args, {} def _format_call(call): func, args, kwds = _parse_call(call) content = '' if args: content += ', '.join(args) if kwds: fmt_kwds = ['%s=%s' % item for item in kwds.iteritems()] joined_kwds = ', '.join(fmt_kwds) if args: content = content + ', ' + joined_kwds else: content += joined_kwds return '%s(%s)' % (func, content) def _maybe_format_attribute(name): if isinstance(name, ast.Attribute): return _format_attribute(name) return name.id def _format_attribute(attr): obj = attr.value if isinstance(attr.value, ast.Attribute): obj = _format_attribute(attr.value) else: obj = obj.id return '.'.join((obj, attr.attr)) a = tm.makeTimeSeries() b = tm.makeTimeSeries() df = merge(a, b)
While this is woefully unpythonic, it's also kind of cool:
In [27]: merge(a, b) Out[27]: a b 2000-01-03 -1.35 0.8398 2000-01-04 0.999 -1.617 2000-01-05 0.2537 1.433 2000-01-06 0.6273 -0.3959 2000-01-07 0.7963 -0.789 2000-01-10 0.004295 -1.446
This can even parse and format more complicated expressions (harder than it looks, because you have to walk the whole AST):
In [30]: merge(a, np.log(b)) Out[30]: a np
Now, I am *not* suggesting we do this any time soon. I'm going to prefer the explicit approach (cf. the Zen of Python) any day of the week:
In [32]: DataFrame({'a' : a, 'log(b)' : np.log(b)}) Out[32]: a | https://wesmckinney.com/blog/python-r-and-the-allure-of-magic/ | CC-MAIN-2021-31 | refinedweb | 630 | 71.31 |
The intent of this article is to refute a fallacious argument presented in a recent contribution to CP. Although not explicitly stated, without question an implicit argument is made that C# is the superior programming language, the premise to this argument being that using the VB language results in inferior quality software systems. In turn the premise to this premise is that the VB language’s RAD origins coupled with its support for various programming paradigms other than those supported by mainstream software academics “damages” the minds of programmers using the language, thereby, making the software they produce inferior to that produced by their C# counterparts. In much simpler terms, it is the author’s view that using the VB language per se reduces the programmer’s ability to implement an elegant software solution, that is, one strictly typed and object oriented, given the wide array of “options” the language provides the developer.
Of course the argument presented is completely fallacious all the way down to its premises and fails to take into account the most important aspect of software development: Business! Furthermore, although at first glance the article comes off as credible given the eloquence with which it was written, let there be no doubt that it is plagued with fallacies, contradictions, and, worst of all, lies. It is a classic example of an informal convincing argument, one that relies more on rhetoric than facts in order to present and defend a case. In the end the article is one of the best, if not thee best, example of Visual Basic defamation.
Here no attempt is made to argue that one language is superior to the other, because any “serious” attempt at such is without doubt futile. Rather the intent is to negate the various premises the article uses to back up its conclusions.
The article characterizes the VB culture as follows:
“The culture of Visual Basic is the culture of the 90’s: build it fast, hype it up, sell it, and don’t worry about whether the story will hold together tomorrow, or even hold together at all.”
Indeed, and let there be no ifs, ands, or buts concerning the fact that the culture of Visual Basic is first and foremost about business, not computer science. It is about getting the job done right on time for the money. The people on the other side of the applications, that is, end users have always cared less about the inner workings of the software they use every day. End users do not judge systems based on how they’re designed or which languages are used to implement them. End users never appreciate all the hard work that goes behind an elegant software system, rather their one and only concern is that the software complete the task at hand in a friendly manner. Indeed this is where VB programmers have succeeded and dominated over the years, and many of them have been abundantly rewarded, rightly so of course. While C++ programmers showed the boss UML diagrams, the VB programmers showed the boss working prototypes with all kinds of bells and whistles. When the VP of finance asked how long the system will take to design and implement, the C++ programmers estimated a minimum of a year’s time. When the VB programmers were asked the same question, they responded with maximum of a month’s time. While many C++ programmers became victims of over architecture and thus delivered either late or never delivered at all, many VB programmers delivered either on time or prior to the deadline. Indeed it is safe to say that, from a pure software engineering perspective, the average product developed with Visual Basic was inferior to that same product produced with C++, Delphi, or Java. However, without question it is also safe to conclude that the average product produced with Visual Basic was delivered on time, while the equivalent business application written in C++, Delphi, or Java certainly was not! In the business world it does not matter what goes on behind the scenes, and VB programmers throughout the years have realized this fact and acted upon it, and as a result of having a positive effect on the bottom line they were greatly rewarded, justifiably so of course! The typical VB programmers know that business drives technology, while the typical computer scientists know, or at least would like to believe, that technology drives business. The fact that a software solution is designed and implemented using the most elegant and adhered to software development practices is completely irrelevant to the profit maximizing objectives of any business, as is the case when the solution is designed and implemented using the worst practices. The fact of the matter is that the “how” of software systems is completely irrelevant from a business perspective, and certainly from the end user’s perspective. Of course the very valid counter argument is always made that poorly developed software in the long run may scale up the long term maintenance costs of the product, something that will no doubt have a negative impact on the bottom line. Indeed, however, more often than not the long term success of a business depends on the short term actions taken. Furthermore, when poorly developed software actually becomes an issue that deters a business from reaching its profit maximizing objectives a programmer is never asked: "Is it difficult to fix?" Rather a programmer is always told: "Do it!"
The question must then be asked, what is the value of software? First of all, software is an end product no different from any other consumer product, say, for example, an automobile. An automobile has no value in and of itself; rather its value is determined by the product’s demand curve, that is, the value consumers place on it. A BMW, for example, is a fine piece of German automobile engineering; however, if customers are not willing to purchase the vehicle, that is, if the vehicle’s demand curve is completely inelastic at price and quantity zero, then all the fine engineering ends up being a cost without benefit, thus a loss. The exact same basic economic principles of price theory apply to software as well. Software has no intrinsic value; its value is a function of the benefit end users derive from using the software. It is not the design of software, the languages used, or the skill level of the programmer that makes software valuable. Software consumers, that is, end users are the ones that make the final determination whether a piece of software is either valuable or worthless. If it gets the job done on time in a user friendly manner, then it is valuable; otherwise, it’s not, despite its design and implementation being the most elegant. There are always people higher up the business ladder end users report their business activities to, these activities greatly facilitated by the wonders of business software solutions. Workers only care about getting their jobs done and making the powers above them aware that completion of their respective business activities has taken place successfully. It is never the case that end users call the help desk complaining that application X does not work because it is not implemented in a strictly typed object oriented manner. Rather it is always the case that end users call the help desk for any other reason whatsoever, ranging from an actual bug in the software all the way to mere ignorance. A classic example of end user ignorance is when the user on the other side of that tech support call says: “The program does not work! I can’t enter any numbers”. Uh, the Num Lock key perhaps? Indeed users will always try to blame the software for any problems they encounter while using it, most of the time these problems having nothing to do with the software itself, rather are the result of inappropriate use or bad data, but certainly are never the result of the internal design or implementation of the software. From personal experience I have never taken a customer support call, and unfortunately I have taken many, in which the user says: “The program uses global variables, and, therefore, I am unable to use it!” If only such were the case so that, based on customer feedback, the argument can be made to management that such awful programming practices need to be prohibited. However, in the real world, that is, in the business world customers will complain about anything else, but never about the internal mechanics of the software.
Another VB misconception presented by the article while defining the VB culture goes as follows:
“Prior to Visual Basic, application development languages were viewed as complex and restricted to the domain of skilled programmers. Visual Basic was syntactically simple, and it enabled virtually anyone with a few hours of time to learn how to create simple applications.”
Although completely true it completely fails to make the distinction between the old BASIC programming language and the development environment that hosts this language, rather repeatedly uses the term “syntax” to refer to VB as a whole. First of all, syntax is simply the set of rules that governs the grammar of a programming language. To say that the syntax of VB makes VB a bad language is to say that the logic the compiler uses to interpret the series of tokens that comprise VB’s grammar is bad. Under most circumstances it is excusable to refer to a language’s feature set or extensions through the term syntax, regardless of whether or not the person making the reference has any formal programming background. However, since the author is on the attack and makes a decent attempt to list specifics regarding the evils of VB, and, furthermore, since the author classifies himself as a “computer scientist”, the sometimes erroneous use of the term syntax must be pronounced. Second, and of much more importance, the language, that is, BASIC is just half the story, the other half being the “visual” facade aspect of the development environment, which is the main contributing factor that makes development with VB so incredibly easy, and that goodness for that! Indeed the BASIC programming language is the easiest and most intuitive programming language in the history of computing, one which expresses software systems using the same tokens used to express this article. However, to say that BASIC in and of itself makes developing Windows based systems easy is completely wrong, and any average programmer with just an ounce of VB and C++ knowledge knows this. Let there be no doubt that building any type of Windows based application without the assistance of the visual facade, that is, the form designer is much more difficult to do in VB than in C++! The obvious reason being that in C++ for each needed library one line of code enables the programmer to include all the functions exposed by this library, which can then simply be called directly, while in VB you have to declare each and every one of these functions for each and every one of these libraries before they can even be used, not to mention all the other gory details involved when invoking Win API calls through VB, a process almost identical to the current PInvoke process but harder. Furthermore, given all the functionality exposed by the .NET FCL the need to work with the Win API has gone down exponentially.
The article’s summary of the VB culture seriously fails to take into account the business importance of RAD, rather dismisses RAD as one of the factors that makes VB a bad language. However, let there be no doubt that it is the RAD facade that the Visual Basic development environment provides that makes the tool so incredibly valuable to businesses. And just to reiterate, software systems are not inherently valuable, that is, their underlying designs and implementations are not the factors that determine their net worth. Customers, and only customer, are the ones that put the final price tag on any software product. Indeed the author lacks what many computer scientists lack: sound business judgment! In the author’s view the value of a software product is a function of its design and implementation, when in fact this function only expresses the reality that exists within the minds of professional programmers, one that is no where to be found within the typical business environment. After all, it is in our nature as system programmers to strive for the design and implementation of the most elegant software systems, that is, the perfect software systems. Unfortunately, however, the bottom line can’t always wait for this perfection to be attained. Business should always take priority over computer science, that is, computer science should never take priority over business. Once again, more often than not the long term success of a business depends on the short term actions taken and, furthermore, it should never be the case that delivery is sacrificed in favor of architecture.
What makes the article’s arguments so contradictory is that it uses the C# programming language as the point of comparison, that is, as the determining factor between the good and bad programmers as if somehow the C# language and development environment enforces the learning of various programming topics such as memory management and threading, these topics cited by the author, when in fact they do quite the opposite.
First, it’s contradictory the criticisms the article makes against the VB RAD environment, that is, how it tempts programmers to stray away from the ideal principles of software development, yet at the same time makes no comment about the C# RAD environment, one which does a very good job of imitating VB’s RAD facade, and is only getting better with subsequent versions. Anyone that has played with C# 2.0 within the VS.NET 2005 development environment will come to appreciate the productivity features that have been copied from VB. Edit and Continue (EC) is just one prime example. Does this feature not go against the sound principles of software development, specifically, does it not result in side effects that may not be noticeable immediately but may result in logical bugs later down the road given some other unit test? Is EC one of those VB RAD features that the article characterizes as detrimental to elegant systems development? Indeed it is; however, who cares! The productivity gained no doubt outweighs any costs incurred. The program errors out, VS breaks at the point of error ignition, the programmer fixes the error right on the spot, the program continues to run, and so on with the VB productivity story. However, if the author’s argument is taken at face value, then features such as these that are appearing within the C# development environment, that is, the “visual” features, will inevitably have a negative impact on the minds of C# programmers as well. The slippery slope implied here is obvious and ridiculous to say the very least! Indeed C# is just half the story, the other half being the “visual” aspect copied from VB; after all, it is Visual C#, not just C#. Again, the article’s business judgment is highly questionable, to say the very least, and given the negative attitude towards RAD it must be the case that the author develops .NET systems using Notepad. And what’s this? Is it not the case now with 2005 that C#’s intellisense is now case insensitive, like that of VB’s, despite the fact that C# is a C derived language and therefore is case sensitive? Again, the VB RAD features are slowly but surely invading every aspect of the C# development environment, its influence ever so apparent in all other development environments as well. Now the question is, are these features bad news for advanced system developers? To answer that question, one must first ask the question, is developing software quickly and easily a bad thing in and of itself? Certainly not! Why? Because it’s about business, not about computer science! End users do not get that tingly feeling we professional programmers get when we see our elegant systems in action.
Second, it’s contradictory the evil nature the author portrays of the Visual Basic namespace. According to the author, this functionality encourages programmers to take the easy way out of system development problems, and that it should never be used, especially within large projects. A contradictory conclusion, since how is it that the FCL makes the problem solving process any more difficult? It does not of course! The FCL is a beautiful object oriented facade that sits right on top of the Win API, one that alleviates programmers from knowing the inner workings of the Windows operating system. How is it, for example, that the FCL makes writing multithreaded applications a learning process as to how the Windows operating system deals with threads? Well, it does not! On the contrary, it makes the process seem almost trivial. Not a single C# programmer in the world has to have any degree of fluency with the internal workings of Windows to get a program up and running, indeed following the true spirit of Visual Basic. PInvoke is there for those very rare occasions when Win API calls need to be made in order to perform tasks that the FCL provides no types for. This of course being in strike contrast with the development model that existed prior to .NET, one in which any type of advanced Windows functionality required dozens of Win API calls, a story the average VB programmer, like myself, knows far too well. The author’s argument that development facades are evil and conducive to inferior quality software products is completely contradictory to his point that C# is the superior language. After all, the CLR, CTS, and FCL, that is, .NET is a development facade in and of itself. Furthermore, C# is nothing without .NET, in the same manner that VB6 is nothing without COM and VB.NET is nothing without .NET. Once again, the article’s business judgment is completely disgraceful, non existent to be more precise. Taking the author’s words at face value means that C# programmers should never use the lock statement, since the lock statement is the easy way to flag a block of code as a critical section. Absurd to say the least! VB is almost 20 years old, most, if not all, of this history present within the Visual Basic namespace. To ask a VB programmer to ignore the Visual Basic namespace is like asking a plumber to ignore a handy set of tools he has used to get the job done for the past 20 years. Tools are tools, there’s a right way to use them and a wrong way, no different from the tools provided by .NET. Heck, according to the author, even garbage collected environments, like .NET and COM, dumb down programmers, yet ironically C#, like VB, is a memory managed language, that is, one that does not have to worry about heap allocation and clean up. Even VB programmers during the COM era had to worry about memory leaks, although to a far lesser extent than C++ programmers, since COM’s reference counting system used to implement garbage collection failed when circular references were involved between objects originating from different COM servers, an issue C# programmers will never have to face given how the GC works, thank goodness! The question is then asked, how much knowledge does a C# programmer have to have about heap allocations in order to get a program running? None and thank goodness for that! Does this make the C# programmers inferior to their C++ programmers? Certainly not! Furthermore, the article makes continuous exaltations of Delphi and Java, citing these languages as C#’s ancestors and direct contributors to C#’s superior programming culture. Again, the question must be asked how much concern existed over issues like memory management and threading when using these development environments such that these concerns have propagated over to the C# culture. When was the last time Java programmers had to worry about freeing up the heap? Contradictory, is it not? It seems so contrary to the point that C++, for example, was never mentioned throughout the article’s definition of the C# culture, as if C++ was completely irrelevant to the point of portraying C#’s culture as superior to VB’s culture, programming wise at least. Isn’t C++ the only language that really forces programmers to understand the low level details of software development?
Without question the article’s objective is VB defamation. Although not explicitly stated, no one on the face of the planet will end up with a good impression of VB after having the article. It is a classic example of an informal convincing argument, that is, one which at first glance looks convincing given the tone in which it is expressed, yet upon close inspection is completely fallacious, yet, unfortunately, not everyone has the time or knowledge to realize this fact. Individuals in hiring positions or in positions of making language choices can easily be influenced by the lies and misconceptions the author presents, since they are presented in a manner that makes them appear truthful, and indeed it is this malicious intentional influence on the industry that makes the article so damaging. Many qualified VB programmers are going to be turned down jobs by individuals that have no clue about programming, typically IT management type folks, only because they took the article’s words at face value. Many development shops that are facing a tie breaking decision between whether to choose VB or C# will choose C#, certainly not because it is a better language, such being just a matter of personal or business preference, but rather because of the fallacious argument the author presents. For example, perhaps the most damaging lie the article pronounces when discussing the VB transition to .NET goes as follows:
“The lack of inheritance and polymorphism enforced for so many years by the underlying limitations of the Visual Basic engine architecture was overcome by throwing the old engine out completely.”
Indeed any person that reads the above lie and knows nothing about VB will automatically make the incorrect assumption that object oriented applications were never possible using VB prior to .NET. Of course this statement is light years away from the truth, however, since object oriented applications have been built with VB ever since the COM era. Indeed VB until .NET arrived lacked implementation inheritance, but to say that implementation inheritance is a must for the development of elegant object oriented systems is absolutely incorrect. VB ever since it became a COM based language has supported interface inheritance, and in conjunction with containment and delegation the result was very elegant and flexible object oriented systems, those true in spirit with the GOF rule of thumb of favoring object composition over class composition. Let there be no doubt that VB prior to .NET lacked many language features, but one thing it has not lacked since the COM era is the means necessary to create high performing object oriented applications. Moreover, regarding the author’s belief that VB has never had support for polymorphism, another lie of course, further elevates suspicions that not only does the author not know anything about VB but most likely does not know anything about COM! The question must be asked, how much VB knowledge does the author have given all the negative assertions he makes about the VB language? Well, according to the author:
“For the rest of the 90's I worked with VB (and other languages) and built a company (Think Software) that specialized in VB solutions and employed 13 VB coders.”
Huh? The author claims to have years and years of VB experience yet makes assertions like the one just mentioned, particularly the ones relating to polymorphism and inheritance? Indeed! The author writes an entire article criticizing VB programmers for their lack of OO knowledge, yet after years of working with VB, more precisely, after establishing an entire business with VB does not even know that VB has supported the object oriented paradigm since the 1990's. Outrageous! Without question the author falls within his own 80% category of bad VB programmers! Although more likely than not the article is intentionally lying, a fact that results in wondering how is it possible for someone like the author to criticize VB’s culture yet not know anything about it. Defamation! That’s how! It happens all the time, but this author took it a step further by eloquently placing the defamation in a nicely written article and made it available on a site that is highly visible to the entire software industry. Furthermore, just the mere fact that prior to .NET VB was completely based on COM, like today C# is completely based on .NET, is an obvious indicator that VB must have supported polymorphism! Raise your hand if you’ve ever heard of the infamous IUnknown interface. Like today in .NET every type ultimately derives from type Object, yesterday in the COM era every type derived from the IUnknown interface, and hence instances of these COM types were accessed via this interface in order to update the corresponding reference count. Polymorphism in action! Let it be known to the software development and consumer world that the article’s views of VB are nothing more than, well, lies. There’s just not a nicer way to put it.
Another VB criticism the author explicitly makes is related to the fact that VB supports the scripting programming style, one in which 1) there is no need to declare variables (Option Explicit Off), 2) there is no need to explicitly convert types from one form to another rather all conversions are done at run time (Option Strict Off), and 3) there is no need to know at compile time whether or not a member invoked on a reference variable is actually part of the object’s interface rather the determination is made at run time (Option Strict Off, Late Binding). In the author’s view the various programming paradigms enabled by the various forms of the Option statement leads programmers astray from sound software development principles, given the erroneous view that software is valuable in and of itself. Indeed VB is a language that is all about options: do what you want, how you want! VB is at the command of the programmer, whereas C# is the programmer’s commander. The article fails to realize how valuable these options are to VB non programmers and VB programmers alike. Why should Joan Meyers, CPA, have to worry about type conversions when all she wants to do is quickly build an address book? Well, she shouldn’t have to; rather she should focus on keeping the books in order, since, after all, she’s an accountant, not a programmer, and VB of course does not discriminate against either rather welcomes programmers of all backgrounds, disciplines, and skill levels. Why should I have to distribute a COM callable wrapper for each and every COM library I use just to invoke one or two methods of a COM object? This entails having to add an extra reference to the wrapper, plus an extra file that needs to be included in the install? Why do I have to go through the extra steps of using reflection in C# in order to accomplish late binding behavior and, thereby, avoid these distribution issues? Why? Well, with VB I don’t have to, nor do I ever, unless there’s some overwhelming business reason to do so. Late binding is VB’s oldest means of implementing polymorphism, that is, classic polymorphism on par with that available in Smalltalk! No doubt these various programming styles are not ideal from a pure and narrow systems view, the one and only view the author has of software, but from a business perspective the features are priceless, given the tremendous amounts of productivity they provide programmers as well as non programmers. Does Joe have to be a mechanic to change his vehicle’s oil? Does Joe have to have a formal CS background to write a personal website? No! The argument is absurd in that it completely fails to take into account context when making generalizations that feature X is always bad. The business world is dynamic, resources are always limited, decisions need to be made today, not tomorrow, a programmer is not always available, business folks frequently need to perform dual roles, one being the programmer role, legacy systems exist and have to be taken into account, and the list of business factors goes on and on. To say that software always needs to be developed in fashion X without regards to the business context is to fail to understand the role software plays within the business environment, a failure ever so common among programmers, without doubt the article’s author being one of these programmers.
Indeed, to say the very least, the arguments presented are completely contradictory, just a series of fallacious rants typical of ignorant programmers that believe that the business world is identical in form to the CS classrooms they were brought up in. No surprise that so many of these highly qualified engineers have been replaced over the years in favor of the self taught VB programmers that perhaps don’t have that CS diploma hanging above the chimney or produce the most elegant systems but more importantly produce what is in fact important to businesses: systems that work, systems that are user friendly, and systems that are delivered on time, period! Design patterns you say? If there’s enough time to go through the process of identifying them, indeed! Otherwise, forget about it! Strict typing you say? Only if the person involved is an actual professional programmer, in which case a simple project setting makes sure strict typing is enforced; otherwise, no ordinary individual should have to worry about explicitly converting a string to a number. Indeed, let the world be assured that VB is all about options and welcomes programmers of all skill levels! Power to the programmer, not just power to the compiler! Given the author’s negative view towards loosely typed languages, it must be the case that XSLT, for example, is a bad language! After all, XSLT also has built in type conversion mechanics, so if this makes VB bad, then it follows that this makes XSLT bad. However, more likely than not the author has a double standard with regards to VB, that is, it’s only bad when talking about VB; for other languages, it’s OK.
When describing the culture of C# the author makes continuous reference to Hejlsberg, makes reference to Java, makes reference to Delphi, but why no reference to COM or C++? Yes, COM, that technology MS promised back in the 90's would accomplish the same things it is now promising .NET will accomplish. Yes, COM, that technology C++ programmers know far too well. Also, why no mention of C++? For example, Generics, the next big thing in .NET is based on what C++ feature? Which language actually does force programmers to understand the inner workings of the OS? It is just incomprehensible how COM was not mentioned even once in describing the C# culture despite the fact that all of the exaltations the author makes of component based technology contructs were made popular as a result of COM. Contradictory, is it not? As if the past 10 plus years of COM development never existed and therefore had zero impact on the development of .NET and C#. Wow!
According the article:
Concrete Term 1: "80% of C# programmers are good, while 80% of VB programmers are not good. This is not to say that everyone who programs in VB is less skilled than everyone who programs in C#. This is to say that (a) the VB syntax and semantics is designed to attract less skilled programmers and, in combination with other factors examined above, this has created a culture that is populated with less skilled programmers and (b) because VB syntax and semantics make it more difficult to avoid common programming errors and hence to program well."
Concrete Term 3: "Hiring the average C# programmer costs more than hiring the average VB programmer. This is because the average C# programmer is a better programmer than the average VB programmer, and this is because of (1)."
Basically the conclusion the author makes is that C# programmers cost more than VB programmers simply because the former group has superior skill to the latter group. Indeed the conclusion is correct, that is, on average VB programmers cost less than C# programmers. However, the premise to this conclusion is completely false. Again, the article thinks the business world is driven by computer science, yet in fact it’s driven by economics. The simple economic principles of price theory are at work here. To illustrate:
On the supply side, there are many more VB programmers than there are C# programmers, that is, the supply curve for VB programmers is farther out to the right than the C# supply curve. Holding other factors constant, this results in a higher equilibrium price for C# programmers. On the demand side, C# is no doubt a great product that has been extremely hyped up by MS ever since and prior to the dawn of .NET. Before .NET 1.0 beta 2 was released the bookshelves were packed with C# books; however, only one VB.NET book, at least that I know of, existed prior to .NET beta 2, a clear indication of where MS’s marketing efforts were invested at the time. As a result, the demand for C# increased, that is, the C# demand curve is further out to the right than the VB demand curve. Again, holding other factors constant, this results in a higher equilibrium price for C#. All of this is normal business activity that takes place throughout the life cycle of product. Just like VB3 became the most popular development platform back in 93, today the hype is all around C#, although soon market forces will settle down as more C# programmers are born. The author would like to believe that C# is a better product per se and thus the cost of C# programmers is higher. Again, it’s not about computer science, it’s all about business and economics.
Concrete Term 7: ."
People are switching to C# first and foremost for the reasons already stated, that is, as a result of all the hype around the language, and indeed because it is without question a beatiful product that has the advantage of 1) zero backwards compatibility and 2) has benefitted from the past experiences, good and bad, of languages that came before it, VB no doubt included in this group. Indeed the component constructs of properties and events, the ones the author cites, along with others such as the internal access modifier have been native to VB ever since the COM days, although it’s highly unlikely the author is aware of this for the obvious reasons already stated. Indeed C# has taken the same component based route. foreach you ask? Again, just another language extension that has been a native part of VB ever since the COM era and that C# has copied. And why the continuous reference to this so called “C# culture”. What culture I ask? C# has been around only for a couple of years, so how it’s possible to clearly define its culture is beyond me. Furthermore, add to the diversity the fact that all kinds of people are using C# for development, including many of those “bad” VB programmers. Raise your hand if you’ve read C# articles here on CP that afterwards make you wonder how on earth these authors became C# programmers to begin with. Of course another more disturbing factor that is contributing to the switch to C# is VB defamation, like the one the author presents in his article.
Concrete Term 8: "VB programmers, on the average, know less about good object-oriented, distributed, loosely coupled application design and development than C# programmers, on average. This is because their language has not supported these notions, so their culture has grown without them. Although these notions are supported now in VB, they are more slowly being adopted than in the C# culture because of cultural inertia."
Again the author here lies and states that VB prior to .NET has not supported the notions of object oriented programming. Whenever a premise to an argument is in fact a lie, that premise automatically becomes negated, and as a result the argument itself becomes negated. Modes Tolens! I’m sure the author, given the claimed “CS” background, will understand what is meant here, since any half decent CS curriculum includes a Symbolic Logic course. Furthermore, no where does the article mention the word "proportional" when making all of these assertions. As was already stated, the number of VB programmers is by far higher than the number of C# programmers. Furthermore, a great number of these VB programmers are not programmers! They're business folks, hobbyists, etc..., that should not even be counted as programmers when determining the average. Indeed, on average VB programmers know less about object orientation, not because of the language but because there are so many more VB programmers than there are C# programmers. You can’t compare apples to oranges!
According to the article:
"VB by default allows support for late binding. Although it can be turned off with “Option strict”, the culture is such that it’s usually left on. This leads to numerous difficult to catch errors. C# binding is always early."
Applying this point universally to all languages that support late binding is to say that Delphi since version 4 is a bad language. Contradictory, is it not? After all, Shaw throughout his article praises Delphi for its adherance to strict software development standards, although why late binding is always a bad practice is questionable without taking context into account, to say the least, yet to no surprise since 80% of what the article asserts is questionable. However, in all likelihood the author does not apply this principle universally, rather has a double standard applicable only to VB. Furthermore, the VB development environment does not come equipped with a twelve gauge shotgun that forces developers to keep strict typing off. It is just another one of the many options VB programmers and VB non programmers have at their disposal. One simple project setting turns strict typing on or off. It's that simple! The programmer makes this decision based on the surrounding context, not the compiler.
"VB supports optional parameters. Although VB developers often list this as an advantage, it is a disadvantage because the use of optional parameters weakens the contract between the caller and the method, allowing the developer to slacken his analysis and get away with it until bugs creep in. [note: C# param array construct is not the same as optional params]"
Applying this point universally to all languages that support optional parameters is to say that C++ and Delphi, just to name a few, are bad languages. Contradictory, is it not? After all, the author throughout the article praises Delphi for its adherance to strict software development standards, although why optional parameters are bad in and of themselves is questionable, to say the least, yet to no surprise since 80% of what the article states is questionable (I must repeat myself). Indeed method groups are cleaner than optional parameters, at least in my opinion, but it's just a matter of style. Furthermore, was there not a recent CP poll that asked this question? If I recall correctly, there was no overwhelming majority in favor or against optional parameters. In the end no harm done if they're there; the programmer decides what to do with them.
"VB supports the legacy VB functions, with reference to Microsoft.VisualBasic.dll. Many of these functions are slow and they should all be avoided in favor of the .NET framework. However many VB programmers still use them. In new VB projects, this dangerous namespace is included by default."
Given the author’s complete lack of business judgement, more precisely, the urge to never take shortcuts and always recreate the wheel when developing systems, a comment like this is no doubt expected. Indeed if the author faced the issue of having to determine whether or not expression X can be classified as a numeric expression, the author would rather recreate the wheel by writing his own function than simply calling VB’s IsNumeric function. No doubt only some of these functions should not be used in cases where performance is critical, but the author prefers to be vague and use the word “many” and not give any specific examples, as if readers were to actually take the time to do the profiling on their own. Certainly this will never happen, rather most readers will take the author’s words at face value, given they are so eloquently phrased. Never forget that in software development there is a time and place for everything and, furthermore, good programmers are those that make wise use of their tools and take advantage of everything they have at their disposal. The more guns the better.
"VB allows implementation of interfaces with methods of different names, making it confusing and difficult to find the implementation. C# does not."
It seems that the author in developing this list simply closed his eyes and picked a few random differences between the languages, regardless of their relevance to the point he tries to make. Indeed this a point where VB comes up on top for those individuals, like myself, that prefer declarative type programming constructs, although in the end it’s just a matter of personal opinion, just like the entire VB vs C# debate is just a matter of preference or business. However, the article could have at least had the decency to provide a code example to illustrate the point, that is, how name mapping is superior to declarative interface implementation. How can a C# programmer that has never once written a line of VB code make an objective decision as to which style is better without at least seeing the code. In the end the C# programmer will simply take the author’s rhetoric comments at face value. Furthermore, I ask the author what commonality must exist between an interface member and the member that is actually used to implement the interface member? Is it really the case that the name of both members must be the same? Or is it the case that both members must have an identical signature? Thank goodness VB left behind in COM the name mapping style of implementing interfaces!
“If an organization is content to write average quality software and has average VB developers, there may be no benefit in switching to C#.”
Exactly who within the organization is to determine whether the software used is of low, average, or high quality. In other words, how is such a determination made and by whom? Programmers or end users? And if the switch is indeed made, how is it that average software and groups of average VB developers automatically become of higher quality. Assuming that the organization is not content in writing average quality software, what course of action should that business take? Is it really the case that the business value of software is a function of its design and implementation? Indeed not!
“If an organization has an exceptional VB team and wants to continue to improve, there is a real danger in continuing in VB. The danger is that the programmers will leave for opportunities in C#. Once even one top developer does this, the polarization of the group toward the old VB culture may accelerate, thus accelerating the attrition.”
There is absolutely no danger whatsoever in continuing with VB for any type of development, whether advanced or trivial development. On the contrary, VB is an exceptional tool that has been and will be around for years to come, and any business that chooses one or the other should make the decision based on business factors, not computer science factors. Exceptional programmers are those that can adapt to the surrounding context, and if that context requires programming in C#, VB, C++, Delphi, or any other programming language, so be it! Businesses fear not that your VB programmers are going to leave in favor of positions that involve C# programming rather fear the obvious that programmers will leave to the business across the street if doing so results in a bigger pay check. Again, it’s never about computer science rather it’s always about business.
“An organization with an exceptional VB team should switch to C#. The exceptional VB team will have no problem learning the new syntax, so there is no danger. The team will then reap the benefits of the C# syntax, semantics and culture for years to come.”
An organization with an exceptional VB team should not switch to C# unless there is a business reason that warrants such a change. Otherwise, an organization should continue development with VB and capitalize on its investment. The C# syntax provides no business benefits whatsoever, nor does the VB syntax or the syntax of any other programming language. Syntax is irrelevant for any organization that is equipped with an exceptional development team, for that team should be able to handle the syntax of any language if indeed it is an exceptional team. Furthermore, in years to come we will just then be able to define what exactly the C# culture is; now, however, any such determination is premature. VB and C# are both exceptional tools for .NET development and the choice of one or the other should be made based on the business context, not the CS context. If the business context does not warrant one language or the other, ask your developers what they would feel more comfortable with. If C# is chosen, great. If VB is chosen, that’s great as well.
If you’re in a hiring position make sure to critically analyze articles that make an attempt to define why language X is better than language Y. More likely than not a bias against language Y exists and therefore any conclusions made will not be objective. Don’t believe me rather believe a wise man:
Bjarne Stroustrup:
"Several reviewers asked me to compare C++ to other languages. This I have decided against doing. Thereby,. I do not have the time, and as the designer of C++, my impartiality would never be fully credible.. Thus, I restrict my comments about languages other than C++ to generalities and to very specific comments."
That said, I consider C++ the best choice in programming language for a wide variety of people and applications.”
Finally, remember that business always comes first, and only after do academics come in the picture.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
LongRange.Shooter wrote:On the PC side of the fence I first taught myself C++ before moving into VB 6. Coded in that for a few years and taught a class in object development in VB. Used both VB.NET and C# during the internal beta days and my company was an early adopter of VB.NET. I have since coded in nothing but C# and only recently had to write a complex application in VB.NET.
The two languages cannot be compared but over that past 10 contracts I've fulfilled I have found enough concerns about VB.NET to say that it should never be used in a professional environment. Here are my reasons:
LongRange.Shooter wrote:In the one well-written case I found one example of late binding that was occurring. But when I looked at the code there was no way there was anything wrong with the code. I tore apart the IL and found that even though the developer coded what would be efficient code in C# the resulting VB code had inserted a late bind instruction to an array that was created two logic layer levels previously. Proof that even a good coder generates bad code when using VB.
vbc.exe
LongRange.Shooter wrote:There are many implementations under VB that make no sense at all, such as TypeOf which in C# returns the typeof( object ) but in VB is a two-element method that does vastly different behaviour.
typeof( <Type Name> )
GetType( <Type Name> )
TypeOf
TypeOf <Object Instance> Is <Type Name>
<Object Instance> is <Type Name>
typeof
<Object Instance>.GetType()
LongRange.Shooter wrote:And when we tried to find the IndexOf a string within a string....forget it. We had to follow the specification alternative of returning "0" because it could not be done.
IndexOf()
System.String
InStr()
Microsoft.VisualBasic
LongRange.Shooter wrote:Finally there are the VB developers themselves. The one I worked with had been a "VB DEVELOPER" for several years. He supposedly had written an entire VB.NET application in his last job. I was brought in for the sole reason that he did not know how to process XML (a poor sign to begin with) but when I passed the object over to him to write his piece of code, he just stared at the screen for TWO WEEKS. Why? Because he did not know how to access the properties that were in a child object of the base object I gave him. In fact his way of writing VB.NET code was to continue writing monolithic code. And let's face it, many of the VB developers from back in the VB6 days know only monolithic code.
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages. | http://www.codeproject.com/Articles/10264/VB-Defamation-Indeed | CC-MAIN-2016-22 | refinedweb | 8,424 | 56.89 |
Defining Plug-ins
This chapter describes how to define plug-ins, which are a specialized form of KPI.
Before reading this chapter, be sure to read the previous chapters on KPIs.
For a comparison of plug-ins with other kinds of model elements, see the chapter “Summary of Model Options” in Defining Models for InterSystems Business Intelligence.
Also see “Accessing the BI Samples.”
Introduction
A plug-in is a class that defines one or more computations to use in the Analyzer and in queries. A plug-in has the following features:
In any given context, the plug-in instance has access to the lowest-level data.
It can accept parameters.
It executes asynchronously. When the plug-in is used in a pivot table, the system can display the plug-in current status (as the string n% complete) in any pending cells.
The pivot table automatically refreshes when the results are available.
Values returned by the plug-in are cached.
Plug-ins are especially appropriate for complex or time-consuming computations. For example, you might have a computation that uses several different parts of the source record, as well as external information; a plug-in would be suitable in this case.
How Plug-ins Can Be Used
Depending on the plug-in class, you can use it in some or all of the following ways:
With the MDX %KPI function (which also enables you to specify values for any parameters). This is possible in all cases.
This means that in all cases, you can define a calculated member that uses the plug-in. (For information on defining calculated members, see Defining Models for InterSystems Business Intelligence.)
Directly in the Analyzer and in widgets. This is possible if the PLUGINTYPE class parameter is "Pivot" and the PUBLIC class parameter is 1 (the default).
To create a plug-in that cannot be directly used in the Analyzer or in widgets, specify PLUGINTYPE as "Aggregate". Or specify PUBLIC as 0.
Available Plug-in Classes
The %DeepSee.PlugIn package provides several plug-in classes for you to use in calculated measures. These classes are as follows:
%DeepSee.PlugIn.Distinct
— Gets the count of distinct values for a given level in a given cell.
%DeepSee.PlugIn.Median
— Gets the median value for a given measure, across all the lowest-level records used in a cell.
%DeepSee.PlugIn.Percentile
— Gets a percentile value for a given measure, across all the lowest-level records used in a cell.
These plug-in classes are defined with PLUGINTYPE as "Aggregate" and so cannot be directly used in the Analyzer or in widgets. For more details on them, see “%KPI” in the reference “MDX Functions” in InterSystems MDX Reference.
Other classes — More advanced plug-ins for use with Text Analytics. These are used by the Pivot Analysis screens in the Analyzer.
Another sample plug-in class is BI.Model.KPIs.PluginDemo. This plug-in class is defined with PLUGINTYPE as "Pivot" and thus can be used directly.
Samples That Demonstrate Plug-ins
Within the BI samples, see the dashboards in the KPIs & Plug-ins folder:
The dashboard HoleFoods Plug-ins uses the calculated measures Median Revenue and 90th Percentile Revenue, which are defined in the HoleFoods cube. These measures use the %KPI function to retrieve values from the sample plug-in classes %DeepSee.PlugIn.Median
and %DeepSee.PlugIn.Percentile
.
The dashboard Patients Plug-ins has a pivot table that uses the calculated measures Median Test Score and 90th Percentile Test Score. These calculated members are defined in the Patients cube, in a similar manner to the ones in the previous bullet.
This dashboard contains another pivot table, which directly uses the plug-in defined by the sample class BI.Model.KPIs.PluginDemo.
Requirements for a Simple Plug-in
To define a simple plug-in, create a class as follows:
Use %DeepSee.KPIPlugIn
as a superclass.
Define an XData block named KPI that specifies at least one property. For example:
XData KPI [ <property name="PatientCount" displayName="PatientCount" /> <property name="HighScoreCount" displayName="HighScoreCount" /> </kpi> }
You can also include filters, as with other KPIs.
For details, see the appendix “Reference Information for KPI and Plug-in Classes.”
Specify the BASECUBE class parameter. For a simple plug-in, specify the logical name of a single cube or subject area. (But also see “Creating a Plug-in for Multiple Cubes,” later in this chapter.)
Specify the base MDX query to use. Either specify the mdx attribute of <kpi> or implement the %OnGetMDX() method in the following generic way:
Method %OnGetMDX(ByRef pMDX As %String) As %Status { Set pMDX = "SELECT FROM "_..#BASECUBE Quit $$$OK }
InterSystems IRIS automatically applies context information (row, column, and filter) to this base query.
Specify the fields that need to be available to the %OnCompute method. These can be fields in the source table of the cube or can be fields in the fact table. You can specify a hardcoded list, or you can use a callback to define the list of fields.
To specify these fields:
Note:
If the fields you want to use are in the fact table, specify the LISTINGSOURCE class parameter as "FactTable". (For details on the fact table, see “Details for the Fact and Dimension Tables” in Defining Models for InterSystems Business Intelligence.)
If you omit this parameter or specify it as "SourceTable", the plug-in queries the source table of the given cube.
If you want to specify a hardcoded list of field names, specify the LISTINGFIELDS class parameter. Specify a comma-separated list of fields to use.
For example:
Parameter LISTINGFIELDS = "Field1, Field2, Field3";
You can specify an alias for any field. For example:
Parameter LISTINGFIELDS = "Field1, Field2 as FieldAlias, Field3";
You can also use arrow syntax and SQL functions, as with other listings.
If you use arrow syntax, be sure to specify an alias for the field.
Or if you want to define the list of fields programmatically, implement the %OnGetListingFields() method. For example, the following method causes the plug-in to retrieve a single field:
Method %OnGetListingFields() As %String { //could use an API to get the field name, but in this case factName is set //so the field name is known Set tListingFields = "MxTestScore" Quit tListingFields }
For information, see “Defining a Listing for a KPI,” earlier in this book.
For a plug-in, the LISTINGFIELDS parameter and the %OnGetListingFields() do not define a detail listing or any listing fields. These options only define the fields that are available to the %OnCompute() method.
Implement the %OnCompute() method. The following section provides details on this task.
Optionally specify the PLUGINTYPE and PUBLIC class parameters. See “How Plug-ins Can Be Used,” earlier in this chapter.
Implementing %OnCompute()
For each pivot table cell where the plug-in is used, the plug-in performs either a DRILLTHROUGH or DRILLFACTS query (depending on the value of LISTINGSOURCE) and returns the fields specified by LISTINGFIELDS or %OnGetListingFields() (as applicable). It then passes the field values to the %OnCompute() method. This method has the following signature:
Method %OnCompute(pSQLRS As %SQL.StatementResult, pFactCount As %Integer) As %Status
Where:
pSQLRS is an instance of %SQL.StatementResult
that contains the fields specified by LISTINGFIELDS or %OnGetListingFields().
For information on using this class, see “Using Dynamic SQL” in Using InterSystems SQL.
pFactCount is total number of facts in the given context.
In your implementation of this method, do the following:
Iterate through the statement result. To do so, use the %Next() method of this instance.
As needed, retrieve values for each row. The statement result instance (pSQLRS) provides one property for each field in the listing query; the name of the property is the same as the field name.
For example, in the previous section, %OnGetListingFields() retrieves a single field, MxTextScore. In this case, pSQLRS has a property named MxTextScore.
Perform the desired computations.
Set the properties of the plug-in instance, as described in the previous chapter. At a minimum, set the following properties:
%seriesCount — Specifies the number of series (rows) in this plug-in.
InterSystems recommends that plug-ins have only one series. (For plug-ins with PLUGINTYPE equal to "Pivot", when a user drags and drops a plug-in property, the Analyzer uses only the first series.)
%seriesNames(n) — Specifies the name of the series n, where n is an integer.
%data(n,propname) — Specifies the value of the given property (propname), for the series n.
The property name must exactly match the name of a <property> in the XData block.
For example:
// place answer in KPI output Set ..%seriesCount = 1 Set ..%seriesNames(1) = "PluginDemo" //set Count property of KPI -- just use received pFactCount Set ..%data(1,"PatientCount") = pFactCount // iterate through result set to get HighScoreCount set n = 0 Set highcount = 0 While (pSQLRS.%Next(.tSC)) { If $$$ISERR(tSC) Quit set n = n + 1 Set testscore = pSQLRS.MxTestScore if (testscore>95) { Set highcount = highcount + 1 } } Set ..%data(1,"HighScoreCount") = highcount
This is an extract from the sample class BI.Model.KPIs.PluginDemo, which is available in the Analyzer for use with the Patients cube.
Indicating State of Completion
Plug-ins are executed asynchronously. When a query containing plug-ins is executed, the query can be complete before the plug-ins have completed execution. In this case, there are cells whose results are pending. Within these cells, you can display the plug-in current status (as the string n% complete). To do so, within %OnCompute(), periodically invoke the %SetPercentComplete() instance method; the argument is an integer between 0 and 100. For example, you could do the following while iterating through the statement result:
// update pct complete If (n#100 = 0) { Do ..%SetPercentComplete(100*(n/pFactCount)) }
The appropriate approach depends on the logic in %OnCompute(). In some cases, the majority of the computation time might occur outside of this iteration.
The pivot table automatically refreshes when the results are available.
Creating a Plug-in for Multiple Cubes
The previous sections describe how to create a plug-in that can be used with a single cube or subject area. You can also create a plug-in that can be used in multiple cubes. In practice, this is difficult to do because it is usually necessary to programmatically determine the fields to query.
To create a plug-in that you can use with multiple cubes, use the following additional instructions:
Specify the BASECUBE class parameter as one of the following:
A comma-separated list of logical cube or subject area names
"*" — refers to all cubes and subject areas in this namespace
This option determines which cubes and subject areas can use the plug-in.
Include the following filter definition within the XData block:
<filter name="%cube" displayName="Subject Area" />
The name must be %cube but you can use any value for the display name.
When you use this plug-in within the Analyzer (if applicable), the system passes the name of the current cube or subject area to this filter. Similarly, when you use this plug-in within an MDX query, the FROM clause of the query determines the value of this filter.
Implement the %OnGetMDX() method so that it uses the value of the %cube filter. For example:
Method %OnGetMDX(ByRef pMDX As %String) As %Status { Set tBaseCube = "" // Use %cube filter to find the base cube If $IsObject(..%filterValues) { If (..%filterValues.%cube'="") { Set tBaseCube = ..%filterValues.%cube } } If (tBaseCube'="") { Set pMDX = "SELECT FROM "_tBaseCube } Quit $$$OK }
Ensure that the listing query can work with all the desired cubes and subject areas. Either:
For hardcoded listings, use only fields that are suitable in all cases.
Programmatically determine the fields to use.
For examples, see %DeepSee.PlugIn.Median
and %DeepSee.PlugIn.Percentile
.
Determining the Listing Fields Programmatically
If the query for the plug-in specifies LISTINGSOURCE as "FactTable", there are additional tools that enable you to programmatically determine the fields to use in %OnGetListingSQL(). You can do the following:
Include the following filter definition within the XData block:
<filter name="%measure" displayName="Measure" />
The name must be %measure but you can use any value for the display name. This filter provides a list of all measures defined in the applicable cube or subject area.
Implement the %OnGetListingSQL() method as follows:
Examine the value of the %measure filter.
Use the %GetDimensionInfo() method of the %DeepSee.Utils class to retrieve, by reference, information about the selected measure.
Use this information as input for the next step.
Use the %GetDimensionFact() method of the %DeepSee.Utils class to retrieve the name of the field that stores the selected measure.
Optionally implement the %OnGetListingOrderBy() and %OnGetListingMaxRows() callbacks. For details, see the class reference for %DeepSee.KPIPlugIn
.
For examples, see %DeepSee.PlugIn.Median
and %DeepSee.PlugIn.Percentile
. Also see the class reference for the %DeepSee.Utils class.
Filtering the Listing
Plug-ins provide a feature that is not available in other scenarios: namely, the ability to specify which records to use when a detail listing is displayed. By default, when a user requests a detail listing for a given cell or set of cells in the results, the system displays a listing that shows all the records associated with those cells. In some cases, however, it is preferable to show a subset of them. For example, the sample class BI.Model.KPIs.PluginDemo has a plug-in property called HighScoreCount. The following shows an example MDX query that uses this plug-in property as a measure:
SELECT NON EMPTY {[Measures].[%COUNT],%KPI("PluginDemo","HighScoreCount",,"%CONTEXT")} ON 0, NON EMPTY [AllerSevD].[H1].[Allergy Severities].Members ON 1 FROM [PATIENTS] Patient Count HighScoreCount 1 Nil known allergi 158 12 2 Minor 113 7 3 Moderate 103 5 4 Life-threatening 133 9 5 Inactive 122 8 6 Unable to determi 119 6 7 No Data Available 385 29
Consider the row for Nil known allergies. If you display a listing for either cell, by default, the system displays a listing that consists of 158 records, because there are 158 patients with no known allergies. But the purpose of the HighScoreCount measure is to count the patients with scores above a given threshold, so when we display the detail listing for the cell HighScoreCount in this row, we might prefer to see only the patients with scores above that threshold.
To apply this sort of filtering to a plug-in, include the following logic in your implementation of %OnCompute(), for any source class ID that should be shown in the listing:
set ..%data("IDLIST",pluginProperty,sourceClassID) = ""
Where pluginProperty is the name of the plug-in property that should use this filtering, and sourceClassID is the ID in the source class. (The ID should be a source class ID even if plug-in otherwise uses the fact class. To make the source class ID available to the plug-in, add %sourceId to the field list.)
For a given plug-in property, if %data("IDLIST",pluginProperty) is not defined, the listing shows all the records associated with the given cell or cells.
Example
To see an example, edit the sample class BI.Model.KPIs.PluginDemo as follows:
Change LISTINGFIELDS to be the following:
Parameter LISTINGFIELDS As STRING = "%sourceId,MxTestScore";
Find the part of %OnCompute() that sets the highcount variable, and modify it as follows:
if (testscore>95) { Set highcount = highcount + 1 Set tHighScoreId = pSQLRS.sourceId Set ..%data("IDLIST","HighScoreCount",tHighScoreId)="" }
Save and recompile the class.
Then, in the Analyzer, create a pivot table that uses both properties of this plug-in (for purposes of comparison). Select a cell that displays the HighScoreCount property, display a listing, and notice that only patients with a high score are shown. For contrast, select a cell that displays the PatientCount property and display a listing for that. In this case, you will see patients with all scores.
Available Error Logging
If a plug-in encounters an error, the system writes to the error log file in the manager’s directory. The name of this file is DeepSeeTasks_namespace.log.
Defining a Calculated Member That Uses a Plug-in
For any plug-in (and any other KPI), you can create a calculated member that retrieves values from it. Then users can drag and drop this member within the Analyzer. To create such a calculated member:
Define a calculated measure as described in “Defining a Calculated Measure,” in Defining Models for InterSystems Business Intelligence.
For Expression, specify an MDX expression of the following form:
%KPI(pluginname,propertyname,seriesname,"%CONTEXT")
Where pluginname is the name of the plug-in, propertyname is the name of the property, and seriesname is the name of the series. You can omit seriesname; if you do, this function accesses the first series in the plug-in.
"%CONTEXT" is a special parameter that provides row, column, and filter context to the plug-in; this information is passed to the base MDX query used by the plug-in.
For example (for a plug-in with only 1 series):
%KPI("PluginDemo2","Count",,"%CONTEXT")
For plug-ins with PLUGINTYPE equal to "Pivot", when a user drags and drops a plug-in property, the Analyzer automatically uses syntax like this in the underlying MDX query that it generates.
For additional options, see the %KPI function in the InterSystems MDX Reference. | https://docs.intersystems.com/irisforhealthlatest/csp/docbook/DocBook.UI.Page.cls?KEY=D2MODADV_CH_PLUGIN | CC-MAIN-2021-39 | refinedweb | 2,855 | 55.34 |
Nowadays when you write another app you probably want (and should!) to reach for tested and reliable solution to save yourself a significant amount of work. Fortunately Google is aware of typical developer’s tasks and comes forth with package of solutions called Android Architecture Components.
Why should you choose Android Architecture Components over other frameworks?
Well, I am not saying that you should always strive to use official solutions. There are probably many corner cases where other framework will be better fit. If you see downsides and limitations forced on you by using Android Architecture Components I will assume you dug deep enough to know better what you are doing. But! What I’m trying to say is that they should be your first pick. There are many, many libraries written to solve same issues. One thing that you can be sure of is that going for Android Architecture Components will give you an official support, tons of documentations and stack posts, you can rely on Google engineers experience, expect new features to show up and be sure that even if there is a bug somewhere, somebody will fix it pretty soon and publish corrected version. This really means a lot if you are planning to release you app to market and maintain it for quite some time.
What actually are these components?
Handling lifecycle
Managing lifecycles of objects is not an easy task especially when you are dealing with UI and can’t anticipate user’s actions. There are many activities, fragments, services and you need to make sure they are properly synchronized between each other, receive proper data when recreated and work smoothly to not spoil user’s experience.
Android Architecture Components answers that need providing lifecycle mechanism. Their design is pretty straightforward as is based on observer pattern. Lifecycle class has two enumerations, one representing events like changing state of the object and another showing current state. With observer pattern you are sure that everything happens when it should without leaving space to some nasty race conditions.
This code snippet show how simple is that
public class UpdateObserver implements DefaultLifecycleObserver { @Override public void onStop(LifecycleOwner owner) { // pause update } @Override public void onStart(LifecycleOwner owner) { // start update download code } }
To observe events you need to implement DefaultLifecycleObserver and properly override its methods.
Before Java 8 things looked a bit different as you were forced to implement LifecycleObserver and use annotation to mark methods as events handles.
public class UpdateObserver implements LifecycleObserver { @OnLifecycleEvent(Lifecycle.Event.ON_START) public void downloadUpdate() { //... } @OnLifecycleEvent(Lifecycle.Event.ON_STOP) public void stopDownloadingUpdate() { //... } }
On the other end we need observed object conforming LifecycleOwner interface which has only one method getLifecycle. Fragment and FragmentActivity already implement LifecycleOwner interface but you are free to create your own subject class.
Room
Another component is object-relational mapping library for SQLite called Room which I personally really liked. It is rapidly gaining on popularity despite many competitors thanks to being official and well-designed solution.
First thing that needs to be done is to create Room database class which will contain holder to SQlite database and act as an access points to underlying data. It has to inherit RoomDatabase and have @Database annotation. Via entities parameter in @Database we specify which classes will be used to create tables. Optionally we can add some custom type converters, this way we won’t have to worry about storing “non-standard” data later on. Last thing worth noticing is that we create abstract method for each data access object we want to have.
@Database(entities = {Project.class, User.class}, version = 1) @TypeConverters({DateConverter.class}) public abstract class RoomDBInstance extends RoomDatabase { private static RoomDBInstance sInstance; @VisibleForTesting public static final String DATABASE_NAME = "testDB"; public abstract ProjectDao projectDao(); public abstract UserDao userDao();
@Entity marks a class that will have a mappig table in SQLite database. All that needs to be done is to mark primary key with @PrimaryKey annotation. Other non transient fields will automatically have coresponding columns in table unless they are explicetly ignored. There are many more annotation modifiers which give you full control over table shape.
@Entity(tableName = "users") public class User { @PrimaryKey @NonNull public int user_id; public String email; public String nazwa; }
Concept of data access object might be a bit different from what you usually expect. With annotations you can mark methods with commons database operations like @Insert, @Delete, @Update, but in addition there is @Query which takes a string with actual SQL query and can be used as a replacement for all of the above. I like this approach because even though writing queries is still needed you do not have to learn another API. Also correctness of queries is checked at compile time what saves you some (nerves) time on testing.
Another feature is @Transaction annotation. Database operations in this method will be run on single transaction, so if you have to run many queries be sure to use it. It is very useful when you want to perform some more complicated operation presumably requiring several steps.
@Transaction public void insertProjectIfNotExist(Project project) { if (!projectExists(project.user_id, project.nazwa)) insertProject(project); }
In example above we firstly check if we already have such project in our database and if not we insert it (hint: this just example and such operation could probably be done with proper OnConflictStrategy applied to @Insert query).
@Dao public abstract class UserDao { @Insert(onConflict = OnConflictStrategy.ROLLBACK) public abstract void insertUser(User newUser); @Query("DELETE FROM users") public abstract void deleteAllUsers(); @Query("SELECT * FROM users WHERE user_id = :id") public abstract User getUserById(int id); }
As we jumped to performance Room is at the forefront. Overhead is minimal so times are very close to proper SQLite code. Below you will see collation of measured times for popular Android ORMs.
I showed here balanced variant of measurements (you can get more detailed info about measurement methods under this link). It is worth to mention that additional SQLite optimizations like caching were disabled by author and could have some impact on results. Despite that it is clear that Room is in the forefront in terms of speed. Some framework perform especially well in specific scenarios (like writing with Realm) thanks to their varied mechanics, but this usually comes with downsides during different operations like excessive memory usage or underperformance (for Realm that would update and delete according to charts). My conclusion would be that there is no universal solution and you should carefully choose the best ORM based on what kind of database operations will be most common for your application.
ViewModel
Model–view–viewmodel (MVVM) architectural pattern is similar to well-known model–view–presenter. The most remarkable distinction between view-model and presenter is that presenter has a reference to view whereas view-model does not. In MVVM view binds directly to view-model to update its data. Android has its own implementation of this pattern in form of ViewModel class. It was created to help developers store and manage UI related data in lifecycle-aware way. As a result there we have neat way to omit some unnecessary, overhead operations done in background and in general make user experience more fluent.
Let’s imagine such a situation. You have activity that presents user’s project. All projects are stored in database so to get one you need to create transaction and make a query. In addition to fully present project some additional parameters have to be calculated. Now user chooses a project and waits for view. The moment it shows up he decides that everything will look more readable after rotation and everything needs to be done again wasting resources and making things more complicated than they should be.
Luckily now we have another weapon in our arsenal called ViewModel. This class is lifecycle aware. What it means is that it can live through configuration changes so you read exactly same data after rotation. Important thing to remember is that ViewModel does not replace onSavedInstanceState. When activity is killed by system you still will have to use it to retrieve your data. On the downside using ViewModel for simple UI might be an overkill as data biding between view and view-model tends to generate a lot of book-keeping data and can result in excessive memory consumption so it’s worth to take that into account.
LiveData
Next we will take a look at LiveData. This class is basically observable data holder, but what distinguishes it from regular observer is fact that it is lifecycle aware. It will only notify app components that are in active state. Thanks to this feature we don’t need to check if data underneath changed as we will be notified every time. LiveData interacts nicely with other architecture components like ViewModel or Room. For example we can create query method in Room DAO returning LiveData.
@Query("SELECT * FROM projects WHERE user_id = :uid") public abstract LiveData<List<Project>> getAllUserProjects(int uid);
This little code change has significant consequences. Now Room will call automatically and asynchronously this method from DAO whenever database changes and if there is observer for this data it will be notified. All this is a great setup for wall app which I mentioned at the beginning of this article. Now whenever someone posts something new, UI will know that it needs to update its content.
In example above LiveData works really well, but as I mentioned before if this solutions does not fit your case don’t force it. In my cases when I was storing only local data to my database and knew upfront that UI refresh will be needed so I decided to handle this with my own code. It solved problem with visible items reload after changing fragments. Of course it could be done still having LiveData in the picture, but the case was simple enough for me to feel safe with more “raw” solution.
Summary
If you are Android developer architecture components are a great way to tackle your everyday programming tasks. Becoming friendly with them will really make your life easier so don’t hesitate!
Sources: | https://blog.j-labs.pl/2019/05/Android-Architecture-Components | CC-MAIN-2021-49 | refinedweb | 1,684 | 52.9 |
Hello,.
Is there any other way to change the value of req.proxyreq? Is there
some obscure Apache setting that might do the same that I've somehow
missed? Yes, I know I could write an Apache module in C that would get
this done, but that's way more than I want to do. I might as well
recompile Apache with the section that adds the headers commented out.
The method I tried was to define a this method:
def fixuphandler(req):
req.proxyreq = 1
return apache.OK
and use this in a PythonFixupHandler Apache directive. This causes a
500 error and throws 'TypeError: attribute 'proxyreq' of 'mp_request'
objects is not writable'.
Thanks in advance,
-Bill | http://www.modpython.org/pipermail/mod_python/2006-March/020500.html | crawl-002 | refinedweb | 117 | 84.37 |
python calc for c in column rows containing data
I am interested in writing an iterative look up using python macros. Essentially the sheet on the spread sheet will have in Column A, a list of values (xxx, yyy, zzz, etc, ...) There will be an occasional blank row which will be skipped, but I will not have up front knowledge of the precise length of the list. My plan is to us a for loop to cycle through the data and fetch the outside information and place it in column B adjacent to the item in col A.
A B xxx 14 yyy 16 zzz 03 and so forth.
code snippet which will allow me to get the data is as follows:
import sys import uno import time import urllib.request from datetime import date oDoc = XSCRIPTCONTEXT.getDocument() def update(): oSheet = oDoc.CurrentController.ActiveSheet oCell1 = oSheet.getCellRangeByName('A1') url_stub = '' part = 'ABSR' url = url_stub + part + '&ac=qtyonhand' r = urllib.request.urlopen(url) oCell1.Value = r.read() return()
This works. It calls the url with..., but obviously it only works once. It returns a number between 0 and n and stores (in this case a number in cell A1 on the current sheet.
What I would like to do is to do an iterative process across rows: (pseudo-code)
def update(): oSheet = oDoc.CurrentController.ActiveSheet oCell1 = oSheet.getCellRangeByName('A1') oCell2 = oSheet.getCellRangeByName(1,0) url_stub = '' for part in oSheet.oCell1. [ some method which ends when there is no more data in rows 1 and below ] url = url_stub + part + '&ac=qtyonhand' r = urllib.request.urlopen(url) oCell2 = oSheet.getCellRangeByValue(1,row number) oCell2.Value = r.read() return()
If someone can point me in the right direction for the best method for detecting no more data below the final row, I'd be grateful. The rest of it, I think I can figure out. As I have struggled with python macros in LibreOffice, and am now pounding the old StarOffice documents, I'm going to try to put what I've learned into a consolidated document once I get through this project. All the stuff I've seen is mainly based on BASIC, but I think if I can figure out the python methods, it might be a better way to go. Thanks for any help. | https://ask.libreoffice.org/en/question/109625/python-calc-for-c-in-column-rows-containing-data/ | CC-MAIN-2019-09 | refinedweb | 382 | 66.33 |
Win extra savings between Sept.12-30!
water cooled 250CC japan style racing motorcycle
Discount Free Inspection
US $700-1000 / Unit
24 Units (Min. Order)
OTTC racing motorcycle 250cc water cooled 4 valves balanced engine
US $1400-1450 / Piece
1 Piece (Min. Order)
250cc racing motorcycle water cooled
US $1650-2250 / Unit
5 Units (Min. Order)
New 250cc water cooled Racing Motorcycle Best 250cc Motorcycle Made In China
US $1100-1300 / Unit
1 Unit (Min. Order)
jiajue 125CC 300C Water cooled high power street sport racing bike motorcycle
Discount Free Inspection
46 Sets (Min. Order)
sport motorcycle RXM200B-2
24 Units (Min. Order)
TAIWAN SYM RV 250 cc EFi EVO NEW SCOOTER / MOTORCYCLE
1 Twenty-Foot Container (Min. Order)
300cc water-cooling racing motorcycle/300cc sport motorbike (TKM300-A2)
US $1550-1650 / Unit
10 Units (Min. Order)
250cc eec trike atv motorcycle
5 Pieces (Min. Order)
250cc china sports motorcycles for sale cheap(WJ250R)
US $850-1200 / Piece
1 Piece (Min. Order)
Horizon 350cc powerful racing motorcycle double cyclinder water cooled double carburater
US $0-3000 / Piece
10 Pieces (Min. Order)
Powerful 400CC EEC Water Cooled Racing bike
US $1400-1600 / Piece
10 Pieces (Min. Order)
EEC 250/300CC MOTORCYCLE (MC-393)
US $2200-2600 / Piece
2 Pieces (Min. Order)
sport Chinese motorcycle water cool NAC25
US $1250-1500 / Carton
20 Cartons (Min. Order)
2016 new powerul 150cc/200cc/250cc racing motorcycle/ sports motorcycle with EEC certificate/oil cooling motocicleta
Discount Free Inspection
US $900-1100 / Unit
30 Units (Min. Order)
EEC 250CC Motorcycle 250XQ-N10
US $1000-2200 / Unit
1 Unit (Min. Order)
hot new racing motorcycles GT 350CC water cooled in high quality beautiful design
US $1200-1600 / Set
24 Sets (Min. Order)
Racing motorcycle DRAGON 250cc, 300cc, motor bike, dirt bike, water cooled
US $700-1100 / Unit
24 Units (Min. Order)
Water cooled racing motorcycles, two big mufflers, 250cc/300cc, 2016
US $1000-1500 / Unit
30 Units (Min. Order)
Used Motorcycles For Sale In Japan
US $800-1400 / Unit
10 Units (Min. Order)
2015 hot sale 250cc water cool motorcycle,motocicletas
US $1000-2000 / Unit
32 Units (Min. Order)
PT150-11A Durable Water-cooled New Design Four-stroke Cheap 250cc Motorcycle
US $550-750 / Unit
74 Units (Min. Order)
Cool Sport 2015 New Fashion Outdoor Adult Motor Scooter for Sale
US $1099-1288 / Piece
5 Pieces (Min. Order)
import cheap goods from china water cooled motorcycle engine
Discount Free Inspection
US $965-1100 / Set
32 Sets (Min. Order)
Classical super racing bike 250cc in cheap price
US $690-790 / Unit
96 Units (Min. Order)
300cc cheap motorcycle cvt(MC-393)
US $2280-2500 / Piece
2 Pieces (Min. Order)
China Newest Model 250cc Motorcycle Racing
US $465-485 / Unit
10 Units (Min. Order)
racing motocicleta bajaj pulsar 300cc 250CC water cooled oil cooled
Discount Free Inspection
US $700-1000 / Unit
24 Units (Min. Order)
Chinese 250cc Sports Motorcycle/ Racing Motorbike For Sale/250cc EEC motorcycle(WJ250R)
US $850-1200 / Piece
1 Piece (Min. Order)
2016 latest 350cc water cooled Regal Raptor racing motorcycle
US $1-1500 / Unit
5 Units (Min. Order)
Chinese new 250cc racing motorcycle
US $1650-2100 / Unit
5 Units (Min. Order)
Sport motorcycle 350cc DD350G(SPT35)
US $1650-1900 / Carton
20 Cartons (Min. Order)
125cc EEC water-cooled racing motorcycle with LED lights&Digital speedmeter (TKM125E-R15)
US $1510-1590 / Unit
10 Units (Min. Order)
Buying Request Hub
Haven't found the right supplier yet ? Let matching verified suppliers find you. Get Quotation NowFREE
Do you want to show 250cc water cooled racing motorcycle or other products of your own company? Display your Products FREE now!
Related Category
Supplier Features
Supplier Types
Recommendation for you
related suppliers
related Guide
Trade tools | http://www.alibaba.com/showroom/250cc-water-cooled-racing-motorcycle.html | CC-MAIN-2016-40 | refinedweb | 616 | 56.96 |
Hello Colin
This is not related with CDI, you are using @Stateful annotation defined in EJB specification.
EJB names are used to give a unique name to EJB beans, therefore you can inject them via @EJB(name
of the bean). In OpenEJB, you can use the same name here but name will be used for EJB bean
first deployed. If Movies2 will be deployed first, only this bean is deployed otherwise Movies
will be deployed and created JNDI name for them. According to EJB specification, The ejb-name
element contains the name of an enterprise
bean. The name must be unique within the ejb-jar file. Therefore, you have to give unique
names to EJB beans.
So, if you want to use Alternative with CDI specification, you can use @Inject to inject EJB
Beans and use @Alternatives to describe alternative CDI beans and also define alternatives
in beans.xml.
Please have a look at this example :
<>
Hope that it helps!
Best
Gurkan Erdogdu
ManageCat, <>
Office : +1 (909) - 366 – 9337
340 S Lemon Ave #7996 Walnut, CA 91789
One of them is :
> On 16 Sep 2015, at 07:54, cfnz <reg@hill-labs.co.nz> wrote:
>
> Still trying to come to grips with beans and CDI, etc...
>
> I was under the impression that if two beans had the same name, that the
> container would complain as it would not know which one to use... but it
> doesn't... is it supposed to?
>
> Test case... take the eclipse link movies example, copy Movies.java to
> Movies2.java and add the following:
>
> @Stateful(name = "Movies")
> public class Movies2 {
> ... etc
> }
>
> I thought this would complain... When the test case asks for Movies, how
> does it know which movies it will get?? I have been looking into the
> @Alternative annotation, but the first thing I need to sort out is why the
> above works... (I have another query on how to select the @Alternative, but
> I shall do another post for that.)
>
> Regards
> Colin
>
>
>
>
> --
> View this message in context:
> Sent from the TomEE Users mailing list archive at Nabble.com. | http://mail-archives.us.apache.org/mod_mbox/tomee-users/201509.mbox/%3CB23B3F88-FA73-464F-89D3-47B6DA3F36B4@managecat.com%3E | CC-MAIN-2019-18 | refinedweb | 345 | 73.17 |
Subject: Re: [boost] [threadpool] new version v12
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-11-02 13:49:47
----- Original Message -----
From: "Anthony Williams" <anthony.ajw_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Saturday, November 01, 2008 11:03 PM
Subject: Re: [boost] [threadpool] new version v12
>
> k-oli_at_[hidden] writes:
>
>> Am Samstag, 1. November 2008 19:35:23 schrieb Vicente Botet Escriba:
>>> IMO, the implementation of the fork/join semantics do not need fibers.
>>> The wait/get functions can call to the thread_pool scheduler without
>>> context-switch. Which are the advantages of using fibers over calling
>>> recursively to the scheduler?
>
>> Please take alook into the example folder of threadpool. You will find
>> two
>> exmaples for recursivly calculate fibonacci. Configure the pool with
>> tp::fibers_disabled and try to calulate fibonacci(3) with two
>> worker-threads.
>> Your application will block forever.
>> Use the option tp::fiber_enabled and you can calculate any fibonacci
>> number
>> without blocking
> I haven't looked at Oliver's use of Fibers, but you don't need to use
> fibers to do this. Whenever you would switch fibers to a new task,
> just call the task recursively on the current stack instead. The
> problem here is that you may run out of stack space if the recursion
> is too deep: by creating a Fiber for the new task you can control the
> stack space.
Thanks Anthony to anwer my question. The 'run out of stack space' problem
was already the case of the sequential recursive algotithm. Of course with
fibers you can avoid the recursion problem, but now you need to reserve a
specific stack space for each fiber. IMO tasks should be more lighwitgth
that fibers. I'm interested in knowing the overhead of using fibers respect
to the recursive call.
I'm not saying that fibers are not useful, the fiber library should be
useful in its own in a lot of contexts; I'm also waiting the review of the
corutine library. Maybe it should be up to the end user to choose between a
fibers implementation or a recursive one.
> The problem with doing this (whether you use Fibers or just recurse on
> the same stack) is that the nested task inherits context from its
> parent: locked mutexes, thread-local data, etc. If the tasks are not
> prepared for this the results may not be as expected (e.g. thread
> waits on a task, resumes after waiting and finds all its thread-local
> variables have been munged).
You are right, this reenforce my initial thinking. We need to separate
between tasks (root tasks) and sub_tasks (which will inherit context from
its parent task).
* In addition we could have a default thread pool (the_thread_pool) and have
access to the current task (this_task). How this default thread pool is
built must be defined.
This could let write things like
int seq_fibo( int n)
{
if ( n <= 1) return n;
else return seq_fibo( n - 2) + seq_fibo( n - 1);
}
int par_fibo( int n)
{
using namespace boost::tp;
if ( n <= 3) return seq_fibo( n);
else {
sub_task< int > t1(this_task::submit(par_fibo, n-1));
sub_task< int > t2(this_task::submit(par_fibo, n-2));
return t1.get() + t2.get();
}
}
int fibo( int n) {
using namespace boost::tp;
task< int > t(the_thread_pool::submit(fibo, n));
return t.get_future().get();
}
* Independently of whether the implementation uses fibers or a recursive
call the working thread scheduler, there are other blocking functions that
could be wrapped to use the current working thread to schedule other
tasks/sub_tasks doing a busy wait instead of a blocking wait. For example a
task can wait on a condition that can be provided by other tasks/sub_tasks,
so the end user could be able to write something_like
this_working_thread::wait(condition);
So I think that the library must provide a mechanism allowing writing this
kind of wrappers providing a one_step_schedule function.
void this_working_thread::wait(boost::condition cnd) {
while (!cnd.try_wait()) {
this_working_thread::one_step_schedule();
}
}
* Just one additional feature I would like to see on boost, which could be
included on the thread pool library or on a separated library. I would like
to be able to submit/schedule tasks at a given time (callouts) which could
be oneshot or periodics. Something like
timeout_task to = the_thread_pool::submit_at(absolute_time, funct);
timeout_task to = the_thread_pool::submit_at_periodically(absolute_time,
period, funct);
Of course the scope of the library will be wider, and the TaskScheduler
could be more adequated name for the library.
The implementation of the timeouts scheduler could be based on "Redesigning
the BSD Callout and Timer Facilities" by Adam M. Costello, George Varghese;jsessionid=B5202FC949FF3EDB0E789F68F509950C?doi=10.1.1.54.6466&rep=rep1&type=pdf
BTW Olivier,
* could the interrupt function extract the task from the queue if the
task is not running already?
* as a task can be only on one queue maybe the use of intrusive
containers could improve the performances
* the fiber queue is a std::list and you use size function which could
have a O(n) complexity. This should be improved in some way (intrusive
container provides already a constants_size list implementation).
Best,
Vicente
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk | https://lists.boost.org/Archives/boost/2008/11/144138.php | CC-MAIN-2021-43 | refinedweb | 862 | 61.97 |
Type: Posts; User: touseef4pk
Why you people alwayz take such questions as home work? I had asked for the sake of my curosity. I am not allowed to use Query Sring meanz I have confined my self to use it because I have to encrypt...
HI!
I have a web page Test.aspx having two button of next and back on it. I redirect to this page (Test.aspx) from multiple pages. I want to define a flag that when i click to back button this page...
Hi,
Can we create an object of a class having private constructor. If so, then how? Please tell me.
Thanks in advance
HI!
I want to write a regular expression which may enforce input in upper case and one embedded space e.g I want to give me input as "M23 9RQ". So please help me the regular expression for this...
I am using this code for row update of the gridview. But when i update the specific record of the row say 3 it is still giving the exception that "There is no row at position 3. Help me how can i...
hi dears,
I have this join query
string qry = "Select Users.UserName, Attendence.TimeIn, Attendence.TimeOut from Users Inner Join Attendence on Users.UserID = Attendence.UserID";
where...
hi all,
I want to generate rdlc report and use linq as datasource for my rdlc report. Please help me in this regard giving some C# example.
0
answers
0 votes 1
view
Tags: SQL
Plz help me out to resolve a conflict. I have made untiring efforts to resolve but coudln't. I have showed my data in gridivew now in windows forms...
All examples u have give are of asp.net but my question is still there because i need help regarding windows forms not in asp.net. So tell me if i hve showed my gridview on a form. how can i update...
Dear seniours,
I have showed a table in gridview on a form. Now i want to make changes in the gridview cells and when i click save these changes should be reflected back in database. and my griview...
Yes Sir both tables are liked primary-foreign key.
i am trying this code to show my gridview after join operation but i am unable to write correct code please help me out.
SqlConnection con =...
Dear Seniours,
Please guide me how can i show data in a single gridview from two tables in windows forms.
How can we show gridview data on the same window or form. Please help me.
Dear seniours,
Please tell me how can i show my data from database in gridview on the same form rather than separate form against a click event?
Respected Fellows,
I have showed my data on a form in gridview. Now i want that when i click on a cell on a grid view it should get the Row Id of that selected row. Please tell me how can i do that?.
I am beginners in C++. i have made the following code but it is giving a few errors i am unable to remove them plz indicate it and rectify it.
#include<iostream>
using namespace std;
class Date...
i have a c++ code here. Plz assisst me that if i want to calculate its time complexity considering it as an algorithm. How can i do that? What would be its time complexity?
#include<iostream>...
1. Why we use enableEvents() method?
2. Can a GUI component handle its own events? If yes; then how?
3. Which technique/concept can be use to implement multiple inheritances
in java?
i am have currently started learning java though books and lectures. There are some questions which are creating some conflicts in my mind. Plz guide me.
1. Why we use enableEvents() method?
2.... | http://forums.codeguru.com/search.php?s=6f29854d87dc7e7419dd10b288f92787&searchid=2758217 | CC-MAIN-2014-15 | refinedweb | 640 | 85.49 |
You can subscribe to this list here.
Showing
1
results of 1
I've created an executable for a small program that uses anydbm.
The executable runs OK on my computer but fails when run on other computers
that do not have Python installed. When setup.py is run a warning message
is generated:
The following modules appear to be missing
['_pybsddb']
and the text in the log file generated when the executable is run on
non-Python compters ends with:
File "sol.py", line 184, in __init__
File "Utils\gdb.pyo", line 36, in __init__
File "anydbm.pyo", line 83, in open
File "dbhash.pyo", line 16, in open
File "bsddb\__init__.pyo", line 299, in hashopen
bsddb._db.DBNoSuchFileError: (2, 'No such file or directory')
My setup script is:
from distutils.core import setup
import py2exe
excludes = ["doctest", "unittest", "difflib",
"pywin", "pywin.debugger", "pywin.debugger.dbgcon",
"pywin.dialogs", "pywin.dialogs.list", "win32com.client"]
setup(
version = "0.0",
windows = ["sol.py"],
options = {"py2exe": {"compressed": 1,
"optimize": 2,
"includes": ["dbhash"],
"excludes": excludes,
"dll_excludes": ['MSVCR71.dll'],
#"xref": 1,}})
If I add "_pybsddb" to the list of includes an import error occurs:
ImportError: No module named _pybsddb
I've searched Py2exe_users, comp.lang.python and Googled for "py2exe and
anydbm" and various others patterns but have found nothing that appears to
have any bearing on this problem. I'm using ActiveState Python version
2.4.3.
What can I do to correct this problem?
Many thanks for your help. | http://sourceforge.net/p/py2exe/mailman/py2exe-users/?style=flat&viewmonth=200911&viewday=6 | CC-MAIN-2014-42 | refinedweb | 247 | 59.8 |
/*
* EventNode>EventNode</code> object is used to represent an event
* that has been extracted from the XML document. Events provide a
* framework neutral way to represent a token from the source XML.
* It provides the name and value of the event, if applicable, and
* also provides namespace information. Some nodes will have
* associated <code>Attribute</code> objects, typically these will
* be the XML element events. Also, if available, the event will
* provide the line number the event was encountered in the XML.
*
* @author Niall Gallagher
* @see org.simpleframework.xml.stream.EventReader
interface EventNode extends Iterable<Attribute> {
/**
* This is used to provide the line number the XML event was
* encountered at within the XML document. If there is no line
* number available for the node then this will return a -1.
*
* @return this returns the line number if it is available
*/
int getLine();
* This provides the name of the event. Typically this will be
* the name of an XML element if the event represents an element.
* If however the event represents a text token or an element
* close token then this method may return null for the name.
* @return this returns the name of this event or null
String getName();
* This returns the value of the event. Typically this will be
* the text value that the token contains. If the event does
* not contain a value then this returns null. Only text events
* are required to produce a value via this methods.
* @return this returns the value represented by this event
String getValue();
* This is used to acquire the namespace reference that this
* node is in. A namespace is normally associated with an XML
* element or attribute, so text events and element close events
* are not required to contain any namespace references.
* @return this will provide the associated namespace reference
String getReference();
* This is used to acquire the namespace prefix associated with
* this node. A prefix is used to qualify an XML element or
* attribute within a namespace. So, if this represents a text
* event then a namespace prefix is not required.
* @return this returns the namespace prefix for this event
String getPrefix();
* This is used to return the source of the event. Depending on
* which provider was selected to parse the XML document an
* object for the internal parsers representation of the event
* will be returned. This is useful for debugging purposes.
* @return this will return the source object for this event
Object getSource();
* This is true when the node represents an element close. Such
* events are required by the core reader to determine if a
* node is still in context. This helps to determine if there
* are any more children to be read from a specific node.
* @return this returns true if the event is an element close
boolean isEnd();
* This is true when the node represents a new element. This is
* the core event type as it contains the element name and any
* associated attributes. The core reader uses this to compose
* the input nodes that are produced.
* @return this returns true if the event represents an element
boolean isStart();
* This is true when the node represents a text token. Text
* tokens are required to provide a value only. So namespace
* details and the node name will typically return null.
*
* @return this returns true if this represents text
boolean isText();
} | http://simple.sourceforge.net/download/stream/report/cobertura/org.simpleframework.xml.stream.EventNode.html | CC-MAIN-2017-13 | refinedweb | 552 | 63.19 |
Related: Collaboration, Communication & Connectivity for future-ready organizations, leveraging mobility to create inclusivity, speed and cohesiveness.
4. Or start writing code with Kotlin to call methods written in Java or vice-versa as it is 100% interoperable with Java.
Everything is now ready to build the application and run it on an emulator or device. You can make a release or build an APK of the application and sign it similarly. Kotlin compiler produces byte-code, thus there really is no difference in terms of look and feel of Kotlin applications versus those written in Java.
Kotlin completely removes null references by making all datatypes non-nullable (by default) i.e. the compiler won’t let you to use a non-initialized, non-nullable variable. To declare the type as nullable, add a question mark after the type. The compiler will enforce a null-check before accessing the variable. This practice drastically reduces bugs.
You can check if it’s nullable variable in two ways. (a).The first is a traditional if statement:
if (nullVar != null)
nullVar.fooboo();
(b).The second is with NULL safe call operator:
nullVar?.fooboo()
For example:
println(nonNullVar.substring(0, 3)) //prints first 3 characters
println(nullVar?.substring(0, 3)) //prints first 3 characters if the string is not null, prints null otherwise
In some cases programmer may need to test the code if it is null pointer exception or not ,or if he knows the variable is nullable. Then he can use it as the compiler will not check for the null, and if it is null then throws null pointer exception.
println(nullVar!!.substring(0,3)) //prints first 3 characters if the string is not null, crashes with a NullPointerException otherwise.
With an extension function, you can call a function from an object as if it were a part of its class. Kotlin lets you extend a class by adding additional functions to it without manipulating the original definition. Such functions are known as extension functions. The names of these functions should be preceded by the names of the classes they extend.
For example, to add an extension function isTeenager to the Student class, you write the following code outside the class:
fun Student.isTeenager(): Boolean {
// If age falls in the range
// 13-19 return true
return age in 13..19 //range
}
In Kotlin, it is compiled to a static function that returns a boolean value. You’d call it as if it were a member function, like
var student = Student()
student.isTeenager()
as if it is a member function of Student class
We all know that most of our apps are data dependent, we often find ourselves creating model classes to hold data. In Java, this can be very tedious task, generating getter and setter functions for each field. With Kotlin, we can declare the class and all its properties in a single line. The compiler will generate all getter and setter functions, as well as the equality members, toString() and a copy() function.
For example, take this in Java:
public class Student{;}
}
To run the same function in Kotlin, all we need is:
data class Student(var name: String, var age: Int?)
You just have to add data keyword before class keyword and the compiler will take care of generating constructor and getter setters.
4. Singleton: Kotlin doesn’t support static member for class. So, how can we create singleton class in Kotlin?
A thread safe singleton design pattern
In Java if it is like:
public class SomeSingleton {
private static SomeSingleton instance = null; private SomeSingleton(){
}
private synchronized static void createInstance() {
if (instance == null) {
instance = new SomeSingleton();
}
}
public static SomeSingleton getInstance() {
if (instance == null) createInstance();
return instance;
}
}
In Kotlin, it is
object SomeSingleton
The object will be instantiated and its init blocks will be executed lazily upon first access, in a thread-safe way as constructors are private and in case programmer need to initialize something.
With an object declaration, you are getting a safe and efficient singleton class.
object SomeSingleton {
init {
println("init called")
}
}
5. More features that will save you from some more keystrokes:
(a). Type aliases: Assign an alias to any given type. This is most useful for long types with many generic parameters.
E.g.
typealias MofL = Map<String, List> fun useMap(map: MofL) { }
(b). Clicklistners:
Consider this click listener
In Java:
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// perform click event
}});
In Kotlin:
view.setOnClickListener { // perform click event }
(c). Semi colons: It is sufficient for Kotlin to sense the end of the statement through a line break. So if you forget to add semicolon at the end of the line, it’s okay!
(d). Constructors: Kotlin’s syntax to create a constructor is very compact. You don’t need to write a constructor separately to initialize member variables but you can add it to the class header only like in the example shown:
class Person(var name: String, var age: Int, var school: String?) {}
If you don’t need to write anything in class then you don’t even need curly braces.
You can add other constructors as well and are known as secondary constructors but you have to delegate it to the primary constructor using this keyword.
constructor(name: String, age: Int, school: String?, email: String) : this(name, age, college) {
this.email = email
}
Whenever a new programming language is launched, it takes some time to get into the market. When Kotlin launched, it wasn’t as mature and proper as it is now. Looking at the limitations, as it is new in town, you will not get proper tutorials and learning stuff. Programmers who already worked with Java can pick up Kotlin in a day just by going through the documentation. Kotlin has its own library that will be added on top of Java’s standard library, so file’s build size increases by 100kb and gradle build also takes little more time.
So you can saw that Kotlin doesn’t have any ground breaking characteristics. While the goal was not to create something revolutionary, but to provide something that is usable and familiar to modern enterprise developers. Kotlin helps us in avoiding some common pitfalls which are common with Java like null references, which increases code efficiency and product quality and it is 100% interoperable with Java. | https://blog.trigent.com/kotlin-on-android-is-it-good-for-developers/ | CC-MAIN-2021-04 | refinedweb | 1,056 | 62.98 |
While entering code, you forgot the name of either a method you wanted to call or some of a method’s parameters.
Use Eclipse’s
code assist (also
called
content assist) to
help out. When you
enter the name of an object or class in the JDT code editor followed
by a period (.) and then pause, code assist
displays the members of that object or class, and you can select the
one you want. You also can bring up code assist at any time (e.g.,
when you’ve positioned the cursor inside a
method’s parentheses, and you want to see what
arguments that method takes) by pressing Ctrl-Space or by selecting
Edit→ Content Assist.
Code (or content) assist is one of the good things about using a full Java IDE. It’s an invaluable tool that accelerates development, and it’s a handy resource that you’ll probably find yourself relying on in time. In the code example we’ve been developing over the previous few recipes, enter the following code to display some text:
public class FirstApp { public static void main(String[] args) { System.out.println("Stay cool."); } }
To work with code assist, enter
System. in the
main method of the
FirstApp
project, then pause. Code assist displays the classes and methods in
the
System namespace, as shown in Figure 1-11.
Double-click
out in the code assist list so that
code assist inserts that member into your code, insert a period so
that the phrase now reads
System.out., and pause
again. Code assist now displays the methods of the
out class. Double-click the code assist suggestion
println(String arg0), and code assist inserts the
following code into the
main method:
public class FirstApp { public static void main(String[] args) { System.out.println( ) } }
Edit this to add the text
Stay cool.
. Note that code assist adds
the closing quotation mark automatically as you type:
public class FirstApp { public static void main(String[] args) { System.out.println("Stay cool.") } }
As soon as you enter this code, Eclipse displays it with a wavy red
underline, shown in Figure 1-12, to indicate that a
syntax problem exists. Rest the mouse cursor over the new code, and a
tool tip appears, also shown in Figure 1-12,
indicating that a semicolon is missing. Note also that a red box
(displayed in stunning black and white in the figure) appears
in the
overview bar
to the right of the code. Clicking that box jumps to the error, which
is handy if you’ve got a lot of errors and a long
code file.
Tip
Deprecated methods also are underlined automatically in the JDT editor, but in yellow, not red. Syntax warnings in general are displayed with yellow boxes in the overview bar.
Add that semicolon now to the end of the line to give you the complete code and to make the wavy red line disappear.
Tip
Eclipse can format your code automatically, adding indents and cleaning up the source code nicely, which is great if you’re pasting code from somewhere else. Just select Source→ Format, and Eclipse will handle the details. In time, you’ll probably find yourself using this feature more often than you expected.
Finally, save the file by clicking the disk icon in the toolbar or by selecting File→ Save. An unsaved file appears with an asterisk before its name in its editor tab (as shown in Figure 1-12), but the asterisk disappears when the file is saved. If you don’t save a code file before trying to compile and run that code, Eclipse will prompt you to do so. We’ll run this code in the next recipe.
To sum up, code assist is a great tool for code completion, and it will start automatically when you insert a period (.) in the JDT editor after the name of an object or class. You also can make code assist appear at any time while you’re typing code; just press Ctrl-Space or select Edit→ Content Assist.
Recipe 1.10 on running your code; Chapter 1 of Eclipse (O’Reilly).
Get Eclipse Cookbook now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers. | https://www.oreilly.com/library/view/eclipse-cookbook/0596007108/ch01s10.html | CC-MAIN-2021-04 | refinedweb | 715 | 70.33 |
program never finishes when run on mono 3.4.0 on Linux (CentOS) (also on mono 3.2.0 on Windows). I have also reproduced it using the csharp REPL. The problem reproduces almost always, though small changes in the program prevent it from happening. If it is not reproducing on your machine, try adding some wait time between creating the thread that tries to accept a connection, and the call to Environment.Exit.
The problem never reproduces if run on the CLR on windows. I also wasn't able to reproduce on mac with mono 3.8.0, but I didn't get a chance to try changing the timing.
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace Example
{
class Program
{
static void Main(string[] args)
{
var s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
Console.WriteLine("Socket created");
s.Bind(new IPEndPoint(new IPAddress(new byte[] { 127, 0, 0, 1 }), 12345));
Console.WriteLine("Socket bound");
s.Listen(100);
new Thread(() => s.Accept()).Start();
//On windows it also reproduces if you replace
//the previous line with a call to
//s.AcceptAsync(new SocketAsyncEventArgs())
Console.WriteLine("Exiting...");//the problem may not reproduce without this, it's probably timing dependent
Environment.Exit(0);
}
}
}
I cannot reproduce with latest mono: Mono JIT compiler version 4.8.0 (mono-4.8.0-branch/6100225 Thu Jan 12 11:37:51 EST 2017)
Please reopen the bug if you can still witness it. | https://bugzilla.xamarin.com/22/22717/bug.html | CC-MAIN-2021-25 | refinedweb | 245 | 53.88 |
Next.js is indispensable when you want to build a high performance React app.
It’s being used to power some of my apps such as Medtally, a data-driven medical community and True Home, an automated home valuation tool for properties in Hong Kong.
Along the way, I learned a few tricks and figured out a few “gotchas” of the framework that beginners might find useful. And without further ado, let’s get started:
1. You need to cache the data from getInitialProps or the browser’s back button behavior will break.
getInitialProps is used to fetch data for the page but it also fires when the user presses the back button on the browser. This causes the browser to scroll to the position where you previously left off but without the remote data from
getInitialProps needed to render. You can read more about this issue here.
To solve this problem, you need to cache the data on the client side after fetching it. Here’s a quick and simple way to do it:
let cache = {}; class App extends React.Component { static async getInitialProps({ req, query, asPath, pathname }) { let data; //if data is in cache then use the cache if (cache[someID]) { data = cache[someID] } else { //if not, then fetch from server data = await fetch(`someAPI`); } return { data: data } render() { //check if client, if so store the data in the cache. //If you don't do this check, there will be a separate cache stored on the server since Next.js does server side rendering as well. if (process.browser) { cache[someID] = this.props.data; } render (){ //your components } } }
You can also do this with Redux.
2. Use Next.js’ Link component instead of Router.push so Google can crawl your URLs
Google’s crawler doesn’t see links written like this:
<div onClick={handleClickWithRouter}>Go to About Page!</div>
So avoid writing your links with Next’s Router if possible. Instead, use Next’s
<Link> component like this:
import Link from 'next/link' function Home() { return ( <div> Click{' '} <Link href="/about"> <a>here</a> </Link>{' '} to read more </div> ) } export default Home
3. Next.js works better with Material UI React than Semantic UI React
If you’re trying to choose between Material UI and Semantic UI React component libraries to go along with your Next.js app, you should choose Material UI.
Semantic UI’s responsive components aren’t built in a way that works well with Next.js’ server-side rendering because they look for the browser’s
window object which isn’t available on the server.
If you must use Semantic UI, you can hack it together by following this GitHub ticket.
On the other hand, Material UI’s responsive components only use media queries which means your components should render in the same way on the server and in the client.
If I convinced you, head over to Material UI’s Next.js example to get started.
4. If you use isomorphic-unfetch to do your data fetching, you’ll need to provide the absolute URL
The Next.js creators recommend a library called
isomorphic-unfetch for data fetching. It has a much smaller bundle size than
axios and works well on both the client and the server.
However, isomorphic-unfetch requires an absolute URL or it will fail. I’m assuming it has something to do with the different environments (client & server) on which your code can be executed. Relative URLs are just not explicit & reliable enough in this case.
You can construct an absolute URL from getInitialProps like this:
class App extends React.Component { static async getInitialProps({ req, query, asPath, pathname }) { let baseUrl = req ? `${req.protocol}://${req.get("Host")}` : ""; let data = await fetch(baseUrl + 'relativeURL') return { data: data } }
- Store your URLs in the database if you want the prettiest of pretty URLs
URLs should be pretty so people want to click on them when they see them on Google.
You generally want to avoid having the database table id in your URL like this:
/post/245/i-love-nextjs/.
Ideally, your URLs should be something like this:
/post/i-love-nextjs.
But this URL is missing the id 245 needed to fetch the data from the database.
To solve this problem, you’ll need to store the URL in the database like this:
On the server, write code to fetch data using the URL in lieu of the post id when someone requests mywebsite.com/post/i-love-nextjs. Here’s an example using Express.js:
server.get('/post/:slug', async (req, res) => { const actualPage = "/post"; //get the data using '/post/i-love-nextjs' as the id let data = await fetchDataWithURL(req.params.slug) const postContent = { data: data }; app.render(req, res, actualPage, postContent); });
I recommend
slugify if you need a library to convert text into URLs.
If you have many URLs and you’re using a relational database, you should consider adding an index to the url column so that your lookup query runs faster.
- CSS breaks in prod but not development when using Material UI with Next.js
function createPageContext() { return { theme, sheetsManager: new Map(), sheetsRegistry: new SheetsRegistry(), //add this to fix broken css in prod generateClassName: createGenerateClassName({ productionPrefix: "prod" }) }; }
If this happens to you, try adding this line to your getPageContext.js file:
And that’s it!
Discussion (1)
Good article, dude. I'm new into nextJS, so this was pretty helpful.
About the last one 'createPageContext()', it should be added on my _document.js? | https://dev.to/jlei523/6-tips-using-next-js-for-your-next-web-app-1hhh | CC-MAIN-2021-25 | refinedweb | 915 | 63.39 |
User namespaces provide a way for a process running in a container to appear to be running as root, but are in fact running as a different user on the host. The objective of this feature is to allow deployers to enable and configure which users and groups are mapped between container and host.
It is a security risk to allow user processes to run as root on container hosts. In order to mitigate this risk, it is a good idea to run processes in those containers as non-root users. The problem with this is some processes may like to run (or at least appear to run as root inside the container). For example, running an init system as the init process of the container.
Further, to boot an image in a user namespaced environment, the contents of it’s filesystem must be owned by the target user for root on the host.
User namespaces allow processes inside a container to appear to be run as root, but are in fact running as another user. Libvirt exposes this feature through idmaps. This change would introduce a set of elements on the instance’s domain xml to indicate which user and group ids should map between container and host.
To address the owning of the filesystem by the targeted root user, the image will be chowned by Nova at boot time.
Config for this feature will be disabled by default. It will be up to the deployer to enable and configure it.
New config options in libvirt group:
uid_maps: comma separated list of mappings, maximum of 5
gid_maps: comma separated list of mappings, maximum of 5
Format for mappings is “guest-id:host-id:count,guest-id:host-id_count,…”
Alternative image chown points, with performance impact:
Chown by image creator: No performance impact
Rejected as the end user shouldn’t have to worry about it
Chown by Glance on import: Image will take longer to become active
Not ideal is it introduces a dependency on import being configured properly in glance.
Chown by Nova when cached: Initial boot on all hosts will take longer
Rejected initially as there are too many changes going on around image caching. Once activity around iamge caching slows down, this may be the ideal option.
This change will improve the security of containers in Nova significantly. Before this change, processes running in containers built by Nova will be run as the host’s root user. After this change, a deployer can restrict which user(s) processes will be run as.
It should be noted that this change is not meant to provide isolation between guests, but instead isolation between host and guest. It is out of the scope of this change, but is reasonable to assume that if a mechanism was created to ensure that containers all used different UID/GIDs, user namespacing could be used to provide further guest-guest separation. This change provides a base that could be extended in the future for that use case.
Images need to be deliberately created to be run in a user namespaced environment. The contents of an image’s filesystem need to be owned by the target uid/gid. In this iteration of this feature, Nova will chown the image on boot.
Due to the chowning of the image’s filesystem on boot by Nova, there will be a performance hit on boot depending on how many files are on the image’s filesystem.
Linux 3.8+ kernel
Early 3.8 kernels may be buggy. If user needs minimum kernel, user should use latest 3.8 kernel possible.
Libvirt 1.1.1
Making sure that the nova config options are properly mapped to libvirt domain objects can easily be handled by unit testing. Functional testing for this will not be possible until libvirt-lxc is included in the CI environment. Depending on how chowning is implemented, functional testing could be a bit tricky.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents. | http://specs.openstack.org/openstack/nova-specs/specs/juno/implemented/libvirt-lxc-user-namespaces.html | CC-MAIN-2019-26 | refinedweb | 677 | 61.06 |
Thomas Gleixner wrote:> On Mon, 2 Mar 2009, Darren Hart wrote:>> From: Darren Hart <dvhltc@us.ibm.com>>>>> PI Futexes must have an owner at all times, so the standard requeue commands>> aren't sufficient.> > That's wrong. The point is that PI Futexes and the kernel internal> rt_mutexes need to have an owner if there are waiters simply because> the PI boosting can not operate on nothing.Yup, sorry - old patch header comment. Fixed.> >> + /* For futex_wait and futex_wait_requeue_pi */>> struct {>> u32 *uaddr;>> u32 val;>> u32 flags;>> u32 bitset;>> + int has_timeout;> > Hmm. time == 0 perhaps or just add another flag bit to the flags field ?I've created FLAGS_HAS_TIMEOUT and use that instead. I opted for this approach instead of using time==0 as that seemed like it could be confused for an expired timer.> >> +/* dvhart: FIXME: some commentary here would help to clarify that hb->chain>> is>> + * actually the queue which contains multiple instances of futex_q - one per>> + * waiter. The naming is extremely unfortunate as it refects the>> datastructure>> + * more than its usage. */> > Please either do a separate patch which fixes/adds the comment or just> leave it as is. This change has nothing to do with requeue_pi and just> makes review harder.My apologies, I had removed all of these types of FIXMEs into another branch, but produced this patchset from the wrong git tree. We'll call this "Figure 1" and I'll refer to it often below ;-)> >> /*>> * Split the global futex_lock into every hash list lock.>> */>> @@ -189,6 +196,7 @@ static void drop_futex_key_refs(union futex_key *key)>> /**>> * get_futex_key - Get parameters which are the keys for a futex.>> * @uaddr: virtual address of the futex>> + * dvhart FIXME: incorrent shared comment (fshared, and it's a boolean int)>> + * dvhart FIXME: incorrent shared comment (fshared, and it's a boolean int)> > LOL. The time it took to add the FIXME comments would have been enough> to make a separate patch which fixes the existing commentSee Figure 1> >> /*>> + * futex_requeue_pi_cleanup - cleanup after futex_requeue_pi_init after>> failed>> + * lock acquisition.> > "after after cleanup". Shudder. Instead of this useless comment the code> could do with some explanatory comments> This function looks like it could do with an overhaul. I wrote it early on and kind of forgot about it :/ Thanks for the catch.>> + * @q: the futex_q of the futex we failed to acquire>> + */>> +static void futex_requeue_pi_cleanup(struct futex_q *q)>> +{>> + if (!q->pi_state)>> + return;>> + if (rt_mutex_owner(&q->pi_state->pi_mutex) == current)>> + rt_mutex_unlock(&q->pi_state->pi_mutex);>> + else>> + free_pi_state(q->pi_state);>> +}>> +>> +/*>> * Look up the task based on what TID userspace gave us.>> * We dont trust it.>> */>> @@ -736,6 +760,7 @@ static void wake_futex(struct futex_q *q)>> * at the end of wake_up_all() does not prevent this store from>> * moving.>> */>> + /* dvhart FIXME: "end of wake_up()" */> > Sigh.See Figure 1> >> smp_wmb();>> q->lock_ptr = NULL;>> }>> @@ -834,6 +859,12 @@ double_lock_hb(struct futex_hash_bucket *hb1, struct>> futex_hash_bucket *hb2)>> }>> }>>>> +/* dvhart FIXME: the wording here is inaccurate as both the physical page and>> + * the offset are required for the hashing, it is also non-intuitve as most>> + * will be thinking of "the futex" not "the physical page and offset this>> + * virtual address points to". Used throughout - consider wholesale cleanup>> of>> + * function commentary.>> + */> > /me throws a handful of FIXMEs at dvhartSee Figure 1> >> /*>> * Wake up all waiters hashed on the physical page that is mapped>> * to this virtual address:>> @@ -988,19 +1019,123 @@ out:>> }>>>> /*>> - * Requeue all waiters hashed on one physical page to another>> - * physical page.>> + * futex_requeue_pi_init - prepare the top waiter to lock the pi futex on>> wake>> + * >> + *>> + * Returns 0 on success, a negative error code on failure.>> + *>> + * Prepare the top_waiter and the pi_futex for requeing. We handle>> + * the userspace r/w here so that we can handle any faults prior>> + * to entering the requeue loop. hb1 and hb2 must be held by the caller.>> + *>> + * Faults occur for two primary reasons at this point:>> + * 1) The address isn't mapped (what? you didn't use mlock() in your>> real-time>> + * application code? *gasp*)>> + * 2) The address isn't writeable>> + *>> + * We return EFAULT on either of these cases and rely on futex_requeue to>> + * handle them.>> + */>> +static int futex_requeue_pi_init(u32 __user *pifutex,>> + struct futex_hash_bucket *hb1,>> + struct futex_hash_bucket *hb2,>> + union futex_key *key1, union futex_key *key2,>> + struct futex_pi_state **ps)>> +{>> + u32 curval;>> + struct futex_q *top_waiter;>> + pid_t pid;>> + int ret;>> +>> + if (get_futex_value_locked(&curval, pifutex))>> + return -EFAULT;>> +>> + top_waiter = futex_top_waiter(hb1, key1);>> +>> + /* There are no waiters, nothing for us to do. */>> + if (!top_waiter)>> + return 0;>> +>> + /*>> + * The pifutex has an owner, make sure it's us, if not complain>> + * to userspace.>> + * FIXME_LATER: handle this gracefully> > We should do this right now. It's not that hard.Hrm. So if another task owns the futex then POSIX says undefined scheduling be should be expected. So failing here seems like a good way to encourage proper usage of the cond vars. Or can you think of a sane scenario in which the outer mutex should not be held prior to the call to cond_signal() or cond_broadcast()? If you are thinking outside of glibc cond vars, then there are likely other gaps with this patch, such as only being able to requeue from non-pi to pi futexes.That being said... now that this is more or less implemented, I'm not sure there is really anything I'd need to do different to support this. I'll pour over this for a while and see if there are any gotchas that I'm missing right now.> >> + */>> + pid = curval & FUTEX_TID_MASK;>> + if (pid && pid != task_pid_vnr(current))>> + return -EMORON;> > Though it's a pity that we lose EMORON :)Does that mean I'll have to forfeit the nickname bestowed upon me by LWN? I've received numerous comments on this line - all of them in favor. Apparently lots of kernel developers are eager for a way to slyly mock users from within the context of the kernel. ;-)> >> + /*>> + * Current should own pifutex, but it could be uncontended. Here we>> + * either take the lock for top_waiter or set the FUTEX_WAITERS bit.>> + * The pi_state is also looked up, but we don't care about the return>> + * code as we'll have to look that up during requeue for each waiter>> + * anyway.>> + */>> + ret = futex_lock_pi_atomic(pifutex, hb2, key2, ps, top_waiter->task);> > Why do we ignore the retunr value here ???-EMORONWe should just return ret if < 0 and let futex_requeue() process it. This is basically what we did before, but it wasn't obvious since the code just moved on to testing !pi. There was the potential to lose the return code however, so that is now fixed. Running with this fix, will appear in V6.> >> + /*>> + * At this point the top_waiter has either taken the pifutex or it is>> + * waiting on it. If the former, then the pi_state will not exist>> yet,>> + * look it up one more time to ensure we have a reference to it.>> + */>> + if (!ps /* FIXME && some ret values in here I think ... */)>> + ret = lookup_pi_state(curval, hb2, key2, ps);>> + return ret;>> +}>> +>> ;>> +}> > Can you please split out such changes to the existing requeue code> into a separate patch ?Should have from the start, updated for V6.> >> +/*>> + * Requeue all waiters hashed on one physical page to another physical page.>> + * In the requeue_pi case, either takeover uaddr2 or set FUTEX_WAITERS and>> + * setup the pistate. FUTEX_REQUEUE_PI only supports requeueing from a>> non-pi>> + * futex to a pi futex.>> */>>;>> struct futex_hash_bucket *hb1, *hb2;>> struct plist_head *head1;>> struct futex_q *this, *next;>> - int ret, drop_count = 0;>> + u32 curval2;>> + struct futex_pi_state *pi_state = NULL;>> + int drop_count = 0, attempt = 0, task_count = 0, ret;>> +>> + if (requeue_pi && refill_pi_state_cache())>> + return -ENOMEM;> > Why do you want to refill the pi_state_cache of current ? current is> not going to wait for the pi_futex.I may need to allocate a pi_state during futex_requeue_pi_init()->futex_lock_pi_atomic()->lookup_pi_state(). Making use of this current->pi_cache seemed like the best way to do it. Is there a more appropriate place to store a preallocated pi_state?> >> retry:>> + if (pi_state != NULL) {>> + free_pi_state(pi_state);>> + pi_state = NULL;>> + }>> +>> ret = get_futex_key(uaddr1, fshared, &key1);>> if (unlikely(ret != 0))>> goto out;>> @@ -1023,12 +1158,15 @@ retry:>> if (hb1 != hb2)>> spin_unlock(&hb2->lock);>>>> + put_futex_key(fshared, &key2);>> + put_futex_key(fshared, &key1);>> +> > Isn't this a reference leak in mainline as well, which needs to be> fixed separate ?Huh, I didn't intend to do that. I'll submit separately.> >> ret = get_user(curval, uaddr1);>>>> if (!ret)>> goto retry;>>>> - goto out_put_keys;>> + goto out;>> }>> if (curval != *cmpval) {>> ret = -EAGAIN;>> @@ -1036,32 +1174,104 @@ retry:>> }>> }>>>> + if (requeue_pi) {>> + /* FIXME: should we handle the no waiters case special? */> > If there are no waiters then we should drop out here right away. Why> should we do more if we know already that there is nothing to do.Well, looking at this again, I don't think it's worth testing this separately. As it is we'll call get_futex_value_locked() then move to plist_fort_each_entry_safe() since there are no waiters to iterate over, and exit. So I think this is handled adequately and I'll just axe the comment and move on.> >> + ret = futex_requeue_pi_init(uaddr2, hb1, hb2, &key1, &key2,>> + &pi_state);>> +>> + if (!ret)>> + ret = get_futex_value_locked(&curval2, uaddr2);>> +>> + switch (ret) {>> + case 0:>> + break;>> + case 1:>> + /* we got the lock */>> + ret = 0;>> + break;>> + case -EFAULT:>> + /*>> + * We handle the fault here instead of in>> + * futex_requeue_pi_init because we have to reacquire>> + * both locks to avoid deadlock.>> + */>> + spin_unlock(&hb1->lock);>> + if (hb1 != hb2)>> + spin_unlock(&hb2->lock);> > Can we please put that sequeuence into an inline function> e.g. double_unlock_hb(). We have at least 5 instances of it.Hrm... looking at this it seems we already have a double_lock_hb() which uses the pointer values to decide which it order it locks them in. Using that in combination with this name-order unlock looks like an ABBA deadlock waiting to happen to me.futex: double_unlock_hb() coming up in my futex-fixes branch which contains the other broken out non requeue_pi related patches and I'll rebase this series on that.> >> + put_futex_key(fshared, &key2);>> + put_futex_key(fshared, &key1);>> +>> + if (attempt++) {>> + ret = futex_handle_fault((unsigned>> long)uaddr2,>> + attempt);>> + if (ret)>> + goto out;>> + goto retry;>> + }>> +>> + ret = get_user(curval2, uaddr2);>> +>> + if (!ret)>> + goto retry;>> + goto out;>> + case -EAGAIN:>> + /* The owner was exiting, try again. */>> + spin_unlock(&hb1->lock);>> + if (hb1 != hb2)>> + spin_unlock(&hb2->lock);>> +))>> continue;>> - if (++ret <= nr_wake) {>> - wake_futex(this);>> + /*>> + * Regardless of if we are waking or requeueing, we need to>> + * prepare the waiting task to take the rt_mutex in the>> + * requeue_pi case. If we gave the lock to the top_waiter in>> + * futex_requeue_pi_init() then don't enqueue that task as a>> + * waiter on the rt_mutex (it already owns it).>> + */>> + if (requeue_pi &&>> + ((curval2 & FUTEX_TID_MASK) != task_pid_vnr(this->task)))>> {> > Why don't you check the owner of the rtmutex, which we installed> already ? Then we can drop this curval2 business altogether.Because we can own the futex without an rt_mutex existing. The first time through this loop we consider the top_waiter of uaddr1. If uaddr2 had no owner, then it is now owned by the top_waiter, but since there are still no waiters on uaddr2, the rt_mutex has not been initialized. Once we know we are not the owner, then we also know the pi_state->pi_mutex exists.Hrm.... I suppose a test for "!this->pi_state" is equivalent to"(curval2 & FUTEX_TID_MASK) != task_pid_vnr(this->task)" then isn't it...? Seems like a rather fragile test though doesn't it?We wouldn't save much by eliminating the curval2 here though since futex_requeue_pi_init needs it for the atomic_lock, so we still need the fault logic... unfortunatley.Thoughts?> >> + atomic_inc(&pi_state->refcount);>> + this->pi_state = pi_state;>> + ret = rt_mutex_start_proxy_lock(&pi_state->pi_mutex,>> + this->rt_waiter,>> + this->task, 1);>> + if (ret)>> + goto out_unlock;>> + }>> +>> + if (++task_count <= nr_wake) {>> + if (requeue_pi) {>> + /*>> + * In the case of requeue_pi we need to know>> if>> + * we were requeued or not, so do the requeue>> + * regardless if we are to wake this task.>> + */>> + requeue_futex(this, hb1, hb2, &key2);>> + drop_count++;>> + /* FIXME: look into altering wake_futex so we>> + * can use it (we can't null the lock_ptr) */> > Err, no. wake_futex() does a plist_del(&q->list, &q->list.plist);> What's wrong with using wake_up() ?Nothing I guess, just trying to use the existing futex infrastructure as much as possible without implementing a bunch of lower level calls inline. But if everyone is alright with this approach, we'll leave it be.> >> + wake_up(&this->waiter);>> + } else>> + wake_futex(this);>> } else {>> - /*>> - * If key1 and key2 hash to the same bucket, no need>> to>> - * requeue.>> - */>> - if (likely(head1 != &hb2->chain)) {>> - plist_del(&this->list, &hb1->chain);>> - plist_add(&this->list, &hb2->chain);>> - this->lock_ptr = &hb2->lock;>> -#ifdef CONFIG_DEBUG_PI_LIST>> - this->list.plist.lock = &hb2->lock;>> -#endif>> - }>> - this->key = key2;>> - get_futex_key_refs(&key2);>> + requeue_futex(this, hb1, hb2, &key2);>> drop_count++;>> ->> - if (ret - nr_wake >= nr_requeue)>> - break;>> }>> +>> + if (task_count - nr_wake >= nr_requeue)>> + break;>> }>>>> out_unlock:>> @@ -1073,12 +1283,13 @@ out_unlock:>> while (--drop_count >= 0)>> drop_futex_key_refs(&key1);>>>> -out_put_keys:>> put_futex_key(fshared, &key2);>> out_put_key1:>> put_futex_key(fshared, &key1);>> out:>> - return ret;>> + if (pi_state != NULL)>> + free_pi_state(pi_state);>> + return ret ? ret : task_count;>> }>>>> /* The key must be already stored in q->key. */>> @@ -1180,6 +1391,7 @@ retry:>> */>> static void unqueue_me_pi(struct futex_q *q)>> {>> + /* FIXME: hitting this warning for requeue_pi */> > And why ?Old comment I believe. I no longer see this in my testing. Removed.> >> WARN_ON(plist_node_empty(&q->list));>> plist_del(&q->list, &q->list.plist);>>>> @@ -1302,6 +1514,8 @@ handle_fault:>> #define FLAGS_CLOCKRT 0x02>>>> static long futex_wait_restart(struct restart_block *restart);>> +static long futex_wait_requeue_pi_restart(struct restart_block *restart);>> +static long futex_lock_pi_restart(struct restart_block *restart);>>>> /* finish_futex_lock_pi - post lock pi_state and corner case management>> * @uaddr: the user address of the futex>> @@ -1466,6 +1680,9 @@ retry:>>>> hb = queue_lock(&q);>>>> + /* dvhart FIXME: we access the page before it is queued... obsolete>> + * comments? */>> +> > I think so.> See Figure 1>> /*>> * Access the page AFTER the futex is queued.>> * Order is important:>> @@ -1529,6 +1746,7 @@ retry:>> restart->fn = futex_wait_restart;>> restart->futex.uaddr = (u32 *)uaddr;>> restart->futex.val = val;>> + restart->futex.has_timeout = 1;>> restart->futex.time = abs_time->tv64;>> restart->futex.bitset = bitset;>> restart->futex.flags = 0;>> @@ -1559,12 +1777,16 @@ static long futex_wait_restart(struct restart_block>> *restart)>> u32 __user *uaddr = (u32 __user *)restart->futex.uaddr;>> int fshared = 0;>> ktime_t t;>> + ktime_t *tp = NULL;> > One line please> Done in broken out patch for the FLAGS_HAS_TIMEOUT>> - t.tv64 = restart->futex.time;>> + if (restart->futex.has_timeout) {>> + t.tv64 = restart->futex.time;>> + tp = &t;>> + }>> restart->fn = do_no_restart_syscall;>> if (restart->futex.flags & FLAGS_SHARED)>> fshared = 1;>> - return (long)futex_wait(uaddr, fshared, restart->futex.val, &t,>> + return (long)futex_wait(uaddr, fshared, restart->futex.val, tp,>> restart->futex.bitset,>> restart->futex.flags & FLAGS_CLOCKRT);>> }>> @@ -1621,6 +1843,7 @@ retry_unlocked:>> * complete.>> */>> queue_unlock(&q, hb);>> + /* FIXME: need to put_futex_key() ? */> > Yes. Needs to be fixed in mainline as well.Added to futex-fixes branch.> >> cond_resched();>> goto retry;>> default:>> @@ -1653,16 +1876,6 @@ retry_unlocked:>>>> goto out;>>>> -out_unlock_put_key:>> - queue_unlock(&q, hb);>> ->> -out_put_key:>> - put_futex_key(fshared, &q.key);>> -out:>> - if (to)>> - destroy_hrtimer_on_stack(&to->timer);>> - return ret;>> ->> uaddr_faulted:>> /*>> * We have to r/w *(int __user *)uaddr, and we have to modify it>> @@ -1685,6 +1898,34 @@ uaddr_faulted:>> goto retry;>>>> goto out;>> +>> +out_unlock_put_key:>> + queue_unlock(&q, hb);>> +>> +out_put_key:>> + put_futex_key(fshared, &q.key);>> +>> +out:>> + if (to)>> + destroy_hrtimer_on_stack(&to->timer);>> + return ret;>> +>> +}>> +>> +static long futex_lock_pi_restart(struct restart_block *restart)>> +{>> + u32 __user *uaddr = (u32 __user *)restart->futex.uaddr;>> + ktime_t t;>> + ktime_t *tp = NULL;>> + int fshared = restart->futex.flags & FLAGS_SHARED;>> +>> + if (restart->futex.has_timeout) {>> + t.tv64 = restart->futex.time;>> + tp = &t;>> + }>> + restart->fn = do_no_restart_syscall;>> +>> + return (long)futex_lock_pi(uaddr, fshared, restart->futex.val, tp, 0);>> }>>>> /*>> @@ -1797,6 +2038,316 @@ pi_faulted:>> }>>>> /*>> + * futex_wait_requeue_pi - wait on futex1 (uaddr) and take the futex2>> (uaddr2)>> + * before returning>> + * @uaddr: the futex we initialyl wait on (possibly non-pi)>> + * @fshared: whether the futexes are shared (1) or not (0). They must be the>> + * same type, no requeueing from private to shared, etc.>> + * @val: the expected value of uaddr>> + * @abs_time: absolute timeout>> + * @bitset: FIXME ???>> + * @clockrt: whether to use CLOCK_REALTIME (1) or CLOCK_MONOTONIC (0)>> + * @uaddr2: the pi futex we will take prior to returning to user-space>> + *>> + * The caller will wait on futex1 (uaddr) and will be requeued by>> + * futex_requeue() to futex2 (uaddr2) which must be PI aware. Normal wakeup>> + * will wake on futex2 and then proceed to take the underlying rt_mutex prior>> + * to returning to userspace. This ensures the rt_mutex maintains an owner>> + * when it has waiters. Without one we won't know who to boost/deboost, if>> + * there was a need to.>> + *>> + * We call schedule in futex_wait_queue_me() when we enqueue and return there>> + * via the following:>> + * 1) signal>> + * 2) timeout>> + * 3) wakeup on the first futex (uaddr)>> + * 4) wakeup on the second futex (uaddr2, the pi futex) after a requeue>> + *>> + * If 1 or 2, we need to check if we got the rtmutex, setup the pi_state, or>> + * were enqueued on the rt_mutex via futex_requeue_pi_init() just before the>> + * signal or timeout arrived. If so, we need to clean that up. Note: the>> + * setting of FUTEX_WAITERS will be handled when the owner unlocks the>> + * rt_mutex.>> + *>> + * If 3, userspace wrongly called FUTEX_WAKE on the first futex (uaddr)>> rather>> + * than using the FUTEX_REQUEUE_PI call with nr_requeue=0. Return -EINVAL.>> + *>> + * If 4, we may then block on trying to take the rt_mutex and return via:>> + * 5) signal>> + * 6) timeout>> + * 7) successful lock>> + *>> + * If 5, we setup a restart_block with futex_lock_pi() as the function.>> + *>> + * If 6, we cleanup and return with -ETIMEDOUT.>> + *>> + * TODO:>> + * o once we have the all the return points correct, we need to collect>> + * common code into exit labels.>> + *>> + * Returns:>> + * 0 Success>> + * -EFAULT For various faults>> + * -EWOULDBLOCK uaddr has an unexpected value (it>> changed>> + * before we got going)>> + * -ETIMEDOUT timeout (from either wait on futex1 or locking>> + * futex2)>> + * -ERESTARTSYS Signal received (during wait on>> futex1) with no>> + * timeout>> + * -ERESTART_RESTARTBLOCK Signal received (during wait on futex1)>> + * -RESTARTNOINTR Signal received (during lock of futex2)>> + * -EINVAL No bitset, woke via FUTEX_WAKE, etc.>> + *>> + * May also passthrough the follpowing return codes (not exhaustive):>> + * -EPERM see get_futex_key()>> + * -EACCESS see get_futex_key()>> + * -ENOMEM see get_user_pages()>> + *>> + */>> +static int futex_wait_requeue_pi(u32 __user *uaddr, int fshared,>> + u32 val, ktime_t *abs_time, u32 bitset,>> + int clockrt, u32 __user *uaddr2)>> +{>> + struct futex_hash_bucket *hb;>> + struct futex_q q;>> + union futex_key key2 = FUTEX_KEY_INIT;>> + u32 uval;>> + struct rt_mutex *pi_mutex;>> + struct rt_mutex_waiter rt_waiter;>> + struct hrtimer_sleeper timeout, *to = NULL;>> + int requeued = 0;>> + int ret;> > All ints in a line please. And please order the lines in descending> line length. Makes it much easier to read.OK, done.> >> + if (!bitset)>> + return -EINVAL;>> +>> + if (abs_time) {>> + unsigned long slack;> > Missing new line. Also this is nonsense. A rt task should have set> its timer_slack_ns to 0, so we can just use current->timer_slack_ns> in the hrtimer_set_expires_range_ns(). If the timer_slack_ns is> random for rt_tasks then we need to fix this in general.> Added a WARN_ON(!current->timer_slack_ns) to my debug patch and used that value here. I'll create a patch to futex-fixes to address the existing calls that I copied this approach from.>> + to = &timeout;>> + slack = current->timer_slack_ns;>> + if (rt_task(current))>> + slack = 0;>> + hrtimer_init_on_stack(&to->timer, clockrt ? CLOCK_REALTIME :>> + CLOCK_MONOTONIC, HRTIMER_MODE_ABS);>> + hrtimer_init_sleeper(to, current);>> + hrtimer_set_expires_range_ns(&to->timer, *abs_time, slack);>> + }>> +>> + /*>> + * The waiter is allocated on our stack, manipulated by the requeue>> + * code while we sleep on the initial futex (uaddr).>> + */>> + debug_rt_mutex_init_waiter(&rt_waiter);>> + rt_waiter.task = NULL;>> +>> + q.pi_state = NULL;>> + q.bitset = bitset;>> + q.rt_waiter = &rt_waiter;>> +>> +retry:>> + q.key = FUTEX_KEY_INIT;>> + ret = get_futex_key(uaddr, fshared, &q.key);>> + if (unlikely(ret != 0))>> + goto out;>> +>> + ret = get_futex_key(uaddr2, fshared, &key2);>> + if (unlikely(ret != 0)) {>> + drop_futex_key_refs(&q.key);>> + goto out;>> + }>> +>> + hb = queue_lock(&q);>> +>> + /* dvhart FIXME: we access the page before it is queued... obsolete>> + * comments? */> > Yes. The reason is the serializing via hb->lock.Ack, thanks. (and see Figure 1)> >> + /*>> + * Access the page AFTER the futex is queued.>> + *.>> + *>> + * for shared futexes, we hold the mmap semaphore, so the mapping>> + * cannot have changed since we looked it up in get_futex_key.>> + */>> + ret = get_futex_value_locked(&uval, uaddr);>> +>> + if (unlikely(ret)) {>> + queue_unlock(&q, hb);>> + put_futex_key(fshared, &q.key);>> +>> + ret = get_user(uval, uaddr);>> +>> + if (!ret)>> + goto retry;>> + goto out;>> + }>> + ret = -EWOULDBLOCK;>> +>> + /* Only actually queue if *uaddr contained val. */>> + if (uval != val) {>> + queue_unlock(&q, hb);>> + put_futex_key(fshared, &q.key);>> + goto out;>> + }>> +>> + /* queue_me and wait for wakeup, timeout, or a signal. */>> + futex_wait_queue_me(hb, &q, to);>> +>> + /*>> + * Upon return from futex_wait_queue_me, we no longer hold the hb>> lock,>> + * but do still hold a key reference. unqueue_me* will drop a key>> + * reference to q.key.>> + */>> +>> + requeued = match_futex(&q.key, &key2);>> + drop_futex_key_refs(&key2);> > Why do we drop the ref to key2 here ? What if we were requeued ?Hrm. I remember adding this and it being necessary - but I can't see it know. I suspect I changed up where I get the futex key or the exit logic, making this unecessary (and wrong). Nice catch. Removed.> >> + if (!requeued) {>> + /* Handle wakeup from futex1 (uaddr). */>> + ret = unqueue_me(&q);>> + if (unlikely(ret)) { /* signal */> > Please put the comment into a separate line if a comment is> neccesary for the condition. This one is pretty useless.> Removed :)> Also the logic is completely backwards here. It has to be the same> as in futex_wait()Is it broken? I believe the reason I wrote it as I did was because the ret == 0 case should be very rare here. Infact, it is an error. The only reason we should wake on the first futex (uaddr) is on a signal or a timeout, otherwise the user most likely paired a FUTEX_WAKE_REQUEUE_PI with FUTEX_WAKE, instead of FUTEX_REQUEUE_PI.I can change it around if you have a strong preference though (or if it's broken in some way I'm missing of course).> > if (!unqueue_me()) {> handle_futex_wakeup();> } else {> if (timeout happened) {> handle_timeout;> } else {> prepare_restart();> }> }> >> + /*>> + * We expect signal_pending(current), but another>> + * thread may have handled it for us already.>> + */>> + if (!abs_time) {>> + ret = -ERESTARTSYS;>> + } else {>> + struct restart_block *restart;>> + restart =>> ¤t_thread_info()->restart_block;>> + restart->fn = futex_wait_requeue_pi_restart;>> + restart->futex.uaddr = (u32 *)uaddr;>> + restart->futex.val = val;>> + restart->futex.has_timeout = 1;>> + restart->futex.time = abs_time->tv64;>> + restart->futex.bitset = bitset;>> + restart->futex.flags = 0;>> + restart->futex.uaddr2 = (u32 *)uaddr2;>> +>> + if (fshared)>> + restart->futex.flags |= FLAGS_SHARED;>> + if (clockrt)>> + restart->futex.flags |= FLAGS_CLOCKRT;>> + ret = -ERESTART_RESTARTBLOCK;>> + }>> + } else if (to && !to->task) {/* timeout */>> + ret = -ETIMEDOUT;>> + } else {>> + /*>> + * We woke on uaddr, so userspace probably paired a>> + * FUTEX_WAKE with FUTEX_WAIT_REQUEUE_PI, which is not>> + * valid.>> + */>> + ret = -EINVAL;>> + }>> + goto out;>> + }>> +>> + /* Handle wakeup from rt_mutex of futex2 (uaddr2). */>> +>> + /* FIXME: this test is REALLY scary... gotta be a better way...>> + * If the pi futex was uncontended, futex_requeue_pi_init() gave us>> + * the lock.>> + */> > Didn't we take the rtmutex as well ??Not necessarily. If the pi futex was ownerless and there was only one task requeued, then there is no rtmutex as it is created by the first waiter.It is possible that other tasks have since tried to take this mutex and now there is an rtmutex, but we have to catch the case where there might not be one.> >> + if (!q.pi_state) {>> + ret = 0;>> + goto out;>> + }>> + pi_mutex = &q.pi_state->pi_mutex;>> +>> + ret = rt_mutex_finish_proxy_lock(pi_mutex, to, &rt_waiter, 1);> > > Eeek. We got a wakeup _after_ we have been requeued. So now you go> back to sleep on the pi_mutex ?Yes. The futex_requeue() calls wake_up() which allows the waiter here to wake and continue processing it's half of the rt_mutex acquisition loop that I split out of rt_mutex_slowlock() in rt_mutex_finish_proxy_lock().> >> + debug_rt_mutex_free_waiter(&waiter);>> +>> + if (ret) {>> + if (get_user(uval, uaddr2))>> + ret = -EFAULT;> > Why drop we out here w/o retrying ?> At this point we have already been requeued and woken. There is no need to continue with futex_wait_requeue_pi(), we can just call futex_lock_pi() directly. However, I see that we don't do that, we just return -EFAULT to userspace. I'll spend some more time on this exit path and see if I can make it more robust, as well as easier to follow.> Also why do we have a separate handling of "ret" here ? This logic> is fundamentally different from futex_lock_pi().At this point ret can be:0: we don't get hereEINTR: We need to restartETIMEDOUT: We should return that to userspace (well we should... looks like that isn't handled quite right either...)EFAULT: I guess I felt if we start faulting at this point we're in trouble, but you are correct, it should retry. I'll add this in.EDEADLOCK: We should return that to userspace (same story as ETIMEDOUT)So... plenty of dope jokes are warranted here. I'll clean this error path up. It's just broken.>> + if (ret == -EINTR) {>> + /*>> + * We've already been requeued and enqueued on the>> + * rt_mutex, so restart by calling futex_lock_pi()>> + * directly, rather then returning to this function.>> + */>> + struct restart_block *restart;>> + restart = ¤t_thread_info()->restart_block;>> + restart->fn = futex_lock_pi_restart;>> + restart->futex.uaddr = (u32 *)uaddr2;>> + restart->futex.val = uval;>> + if (abs_time) {>> + restart->futex.has_timeout = 1;>> + restart->futex.time = abs_time->tv64;>> + } else>> + restart->futex.has_timeout = 0;>> + restart->futex.flags = 0;>> +>> + if (fshared)>> + restart->futex.flags |= FLAGS_SHARED;>> + if (clockrt)>> + restart->futex.flags |= FLAGS_CLOCKRT;>> + ret = -ERESTART_RESTARTBLOCK;>> + }>> + }>> +>> + spin_lock(q.lock_ptr);>> + ret = finish_futex_lock_pi(uaddr, fshared, &q, ret);>> +>> + /* Unqueue and drop the lock. */>> + unqueue_me_pi(&q);>> +>> +out:>> + if (to) {>> + hrtimer_cancel(&to->timer);>> + destroy_hrtimer_on_stack(&to->timer);>> + }>> + if (requeued) {>> + /* We were requeued, so we now have two reference to key2,>> + * unqueue_me_pi releases one of them, we must release the>> + * other. */>> + drop_futex_key_refs(&key2);>> + if (ret) {> > This whole "ret" logic is confusing. I agree. As I said above, I'll if I can think of something more robust as well as easier to follow. If you have some ideas, please share.Many thanks for the review. I've addressed most of the above while responding to this review, but I have a few items that will take me some time to address. I hope to have V6 out and tested this week.--Darren> >> + futex_requeue_pi_cleanup(&q);>> + if (get_user(uval, uaddr2))>> + ret = -EFAULT;>> + if (ret != -ERESTART_RESTARTBLOCK && ret != -EFAULT)>> + ret = futex_lock_pi(uaddr2, fshared, uval,>> + abs_time, 0);>> + }>> + }>> + return ret;>> +}> > Thanks,> > tglx-- Darren HartIBM Linux Technology CenterReal-Time Linux Team | http://lkml.org/lkml/2009/3/10/5 | CC-MAIN-2015-32 | refinedweb | 4,193 | 65.62 |
WCTOB(3) Linux Programmer's Manual WCTOB(3)
wctob - try to represent a wide character as a single byte
#include <wchar.h> int wctob(wint_t c);
The wctob() function tests whether the multibyte representation of the wide character c, starting in the initial state, consists of a single byte. If so, it is returned as an unsigned char. Never use this function. It cannot help you in writing internationalized programs. Internationalized programs must never distinguish single-byte and multibyte characters.
The wctob() function returns the single-byte representation of c, if it exists, of EOF otherwise.ctob() │ Thread safety │ MT-Safe │ └──────────┴───────────────┴─────────┘
POSIX.1-2001, POSIX.1-2008, C99.
The behavior of wctob() depends on the LC_CTYPE category of the current locale. This function should never be used. Internationalized programs must never distinguish single-byte and multibyte characters. Use either wctomb(3) or the thread-safe wcrtomb(3) instead.
btowc(3), wcrtomb(3), wctomb(3)
This page is part of release 5.07 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at. GNU 2017-09-15 WCTOB(3)
Pages that refer to this page: btowc(3) | https://www.man7.org/linux/man-pages/man3/wctob.3.html | CC-MAIN-2020-29 | refinedweb | 202 | 51.85 |
Posted 05 Jan
Link to this post
I'm needing to be able to print a web page so I'm trying to use the pdf processing. It is an MVC5 and using Visual Studio 2015 I was trying to complete the telerik example at . I started by creating a new telerik mvc application and just an index page. I added references Telerik.Windows.Documents.Fixed,
Telerik.Windows.Documents.FormatProfiders.Pdf and
Telerik.Windows.zip.
when I tried adding the using statements in my controller page it does not recognize the .Export statement.
using Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export;
the error is Error CS0234
The type or namespace name 'Export' does not exist in the namespace 'Telerik.Windows.Documents.Fixed.FormatProviders.Pdf' (are you missing an assembly reference?)
I tried this because I got the same error trying to add this in the real application I have that I need to convert the web page to a pdf.
So what am I missing.
Posted 09 Jan
Link to this post
Could you please let me know which version of Telerik.Windows.Documents.Fixed you are using in your case? Generally to use the RadPdfProcessing library in your project, you need to add references to the following assemblies:
So I added the Telerik.Windows.Documents.Core and is still doesn't recognize the export.
so before I started this mvc project I went into the Telerik Control Panel and ran the update for UI for ASP.NET MVC which updated to version 2016.3.1118.545 then after the application was created I added the references above by going to Reference, Add then under the Assemblies I clicked the Extensions then found the above dll's. which are version number 2014.1.224.45, I would have thought there was a newer version but I don't know what the latest is.
Posted 11 Jan
Link to this post
Posted 20 Jan
in reply to
Kostadin
Link to this post
Thank you, I've been on another project sorry for the delay. that did fix that, as a side question why would not the latest version I have installed not show up in the Assemblies when adding a reference.
Second now that that is fixed I went back to the Demo above and the source code for the CreatePdfDocument.cs is not showing.
Posted 24 Jan
Link to this post
Posted 31 Jan
in reply to
Kostadin
Link to this post
Posted 02 Feb
Link to this post
1. Launch the Telerik Control Panel and log in
2. Click on the UI for MVC product tile
3. Check turn features on/off check box and proceed
4. Verify Demos feature is | http://www.telerik.com/forums/telerik-windows-documents-fixed-formatproviders-pdf-export | CC-MAIN-2017-09 | refinedweb | 452 | 65.01 |
Quick Links
RSS 2.0 Feeds
Lottery News
Event Calendar
Latest Forum Topics
Web Site Change Log
RSS info, more feeds
Topic closed. 2 replies. Last post 8 years ago by Spincognito.
My state posts odds online for new scratch-off games. But once the game has been sold for a while, I assume the odds have changed. Is that correct? So, for example, if there were 10 of the top prize available at the beginning, but 6 have been won, how do you calculate the odds for the remaining 4 top prizes? More important, how do you calculate the odds for all remaining prizes as a group? Thanks.
You can't, unfortunately.
I live in SC and they are very open and honest about the odds for their scratch off games (though sometimes you won't believe it when you hit a losing streak! grrrrr.....).
However, though they post the total tickets in the run, the total prizes with the value of those prizes, and then even post the remaining top prizes for each ticket (and the dollar value of ALL prizes left), there's still no way to adjust the return/odds because we aren't given sales figures about how many total tickets have been sold.
Let's try to make this simple: As a ticket is sold, and prizes are won and losers are removed from the potential pool to buy from the odds do change. Unfortunately, we have no way of knowing what the new updated odds are.
It's even possible that ALL the top prizes could be gone from a ticket, and the ticket is still a GREAT ticket to play. But the only way to know that is to have access to a handful of very important current numbers, and all states keep at least one of those numbers to themselves so we can't determine which are the best tickets to currently play.
It will help if we simplify all the numbers, while keeping the principles the same. Let's pretend we have our own lottery, with a 20 ticket run for the whole set. In those twenty tickets (which we will sell for $1 a piece) we will have a single top prize of $5 and four smaller prizes of $2 a piece. This means that once we sell the entire reel of tickets we will have made $20 and have to pay out $13. This means our game has a return rate of 65% ($13/$20) which is a realistic return rate for a scratch off game.
We represent the tickets below, with dollar values for winners and the letter X for losers. We will divide them up into four groups as well to simulate that we are sending them out to four stores.
[X][X][X][X][$2]
[X][X][X][$2][X]
[X][$2][X][X][$2]
[X][X][$5][X][X]
Now, let's say that the game sells way down until the jackpot ($5) is won and we then have just these tickets left:
[$2]
[$2][X]
[X][$2]
Now, some might say that the jackpot is won, so this game is a waste of time. And true, the jackpot takes a large percentage of the prize with it once it's won, but because we can see everything, we can do the new math and see what the new return on this game is now....
$6 in prizes remaining, with $5 in total tickets left to buy. Thats' $6/$5, or 120% return!!!
When a game has a positive return (above 100%) that means it makes actual financial sense to buy as much of it as possible. Of course, this is a ultra rare situation, but even high returns below 100% still make for fun gambling.
But we can't know when these situations happen, because the states might as most tell us how much the value of the prizes are left. We wouldn't know (in our above scenario) that only 5 tickets were left with a value of $6.
So, concluding, without current sales data for tickets (how many have been sold, and how many prizes are left, and what the value is for the prizes remaining) we can't calculate current odds, and just have to rely on the odds they gave us when the ticket run started.
Totally excellent explanation!
My suggestion would be to play games that have been out for a while yet still have many of the jackpot tickets available. If a game that offers say 10 $1million dollar prizes has been out for 6 months and only two or three of those top prizes are gone, I am playing that game. Also, if a similar game has been out for nearly two years and has only one or two top prizes left, I surmise then that game must be nearing its end and those last jackpot tix are soon to be coughed up, hopefully to me! Keep an eye on the website of your state lottery. Take note of where the winners came from if possible. I live in Massachusetts on the coast and if I see that a certain game has had j/p winners in the western part of the state, I play that game here on the coast, surmising that the lottery likes to spread out the winners. Most websites will post pics and stories as well as the location of the store that sold the biggie.
Like totally said, you will never be able to figure out the odds on a daily basis but there are things you can do to increase your odds and play smart.
Good Luck!-2016 Speednet Group. All rights reserved. | https://www.lotterypost.com/thread/187786 | CC-MAIN-2016-44 | refinedweb | 953 | 74.73 |
This week we released ASP.NET 5 Beta5 as an in-place update to Visual Studio 2015 RC on!
The version that shipped with VS2015RC was Beta4 so you’ll definitely want toget this update. ASP.NET 5 Beta5 is loaded with lots of new features, improvements, and bug fixes.
It’s important to remember that there’s the ASP.NET runtime (the bits that run your web apps) and there is the Web Tooling bits for Visual Studio (the bits that give you the HTML and JavaScript editor and the File New Dialog Box). Beta5 is an update to the ASP.NET 5 runtime!
Remember that ASP.NET 5 runs on both the full .NET Framework and also (still a work in progress) .NET Core. It’s .NET Core that will run on Windows, Azure, Linux, and Mac. It’s important to note that ASP.NET runs on both these frameworks, so this is a good time to start installing the betas and trying out your applications with ASP.NET 5.
Here are just some of the highlights from this release:
.NET Execution Environment (DNX)
- Support for NuGet v3 feeds. Restoring packages using the new NuGet v3 feed is significantly faster – try it out by adding as a package source.
- Support for the new dotnet Target Framework Moniker (TFM). You can now use DNX to build portable .NET libraries that work on any .NET flavor that supports your package dependencies using the new dotnet TFM. We will provide more details on using the new dotnet TFM for package authoring in a future post.
- Specify language and release notes link in project.json. These nuspec properties can now be specified in your project.json file.
- Removed JSON.NET version pinning. This is an important change that we are introducing as it no longer requires that your application use the same version of JSON.NET that is shipped with the DNX version that you are working with. As JSON.NET evolves, you can choose to download and install new releases without being required to upgrade the DNX version you are using.
- New IRuntimeEnvironment service. Use the new IRuntimeEnvironment service to get runtime details, like OS, CLR, and bitness.
ASP.NET 5
- HttpContext.Connection. Added connection information to HttpContext via the new Connection property.
- New localization abstractions and middleware. You can see the new abstractions in action in this localization sample.
- Consistent way to terminate ASP.NET hosting. Previously ASP.NET hosting would terminate on any key press. We now consistently terminate on Ctrl-C.
MVC 6
- C# 6 support in Razor. You can learn more about the new features available in C# 6 at MSDN blogs.
- Simplified MVC options and added top level settings. There are now app-level settings for configuring various settings for HTML helpers
- New JSON helper for serializing JSON in views. This helper allows you to serialize your .NET objects to JSON in Razor views very easily with syntax like the following:
@Json.Serialize(Model)
- Attribute routing token replacement in route names. In addition to using route tokens in route templates you can now use them in route names, like this:
[Route("Products/[action]", Name = "[actions]Products")] public class ProductsController { public void Add() { } public void Buy() { } }
- New ImageTagHelper. The new ImageTagHelper allows you to automatically append image filenames with a cache-buster version number so that you can aggressively cache images with your application, like this:
<img asp-file-version=”true” src=”~/images/my_cool_image.png” />
- Tag helper support for binding dictionary properties. You can now bind server side attributes to dictionary properties on your tag helpers. For example, the AnchorTagHelper binds route values for link generation using attributes that follow the asp-route-* pattern, like this:
<a asp-action=”Edit” asp-route-id=”@index”>Edit</a>
- Support conditionally binding tag helpers based on presence of server-side attributes. You can now specify that tag helper should only be bound to a tag based on the presence of server-side attributes using the Attributes property on TargetElementAttribute.
Be sure to read the Beta5 release notes to find all the details on what’s new as well as known issues. There will be more Betas after this one as we march towards a final release. The final release of ASP.NET 5 will happen AFTER Visual Studio 2015 is released. We’ll announce the schedule very soon.
As I said previously, this ASP.NET 5 runtime update is compatible with Visual Studio 2015 RC. You can open, build and run ASP.NET 5 apps using the Beta5 runtime packages and Visual Studio 2015 RC.
To update to ASP.NET 5 Beta5 use the following steps:
- Install the .NET Version Manager (DNVM) if you don’t already have it (it comes preinstalled with Visual Studio 2015 RC, or you can get the latest version)
- From a command prompt set the DNX_FEED environment variable to
- Run “dnvm upgrade”
- In your app update your global.json to point to beta5 version of the .NET Execution Environment (DNX)
- Also your project.json to point to the beta5 package versions
- Run “dnu restore”
- Run “dnu build” and migrate your code to beta5 s needed
There have been quite a few API changes in this release as part of a broad API review. In the process we refactored many of our packages to reduce dependencies and to improve the layering. To help you update your Beta4 code you can find a list of the most impactful changes on our Announcements repo along with details for each change. You can also find docs and samples for ASP.NET 5 at.
We hope you enjoy this release! If you find any issues or have suggestions for improvement please let us know through our public issues trackers on GitHub. Thanks for trying out ASP.NET 5!
Please join us every Tuesday for the ASP.NET Community Standup. The schedule and previous episodes are at.
Join the conversationAdd Comment
On Linux, do we still need to switch to Mono to run "dnu restore"?
@Keith Yes, you will need to run on Mono to restore packages. We actually haven't released the .NET Core based DNX packages for Mac and Linux to nuget.org yet as they are still in early phases of development. We plan to publish a roadmap in the weeks ahead with the transition plan from Mono to .NET Core for cross platform development.
How do you set the DNX_FEED environment variable? Also it's worth noting I had to use Powershell, the VS 2015 command prompt does not recognize the DNVM command.
How do we use the new configuration model after the namespace changes? Current beta4 one to add an ini source:
var config = new Configuration().AddIniFile(iniFile);
The docs at docs.asp.net/en/latest are yet to be updated.
Setting the DNX_FEED environment variable can be done using the following command in PowerShell:
set DNX_FEED
When I then run the dnvm upgrade command also in PowerShell I get the following error:
C:Program FilesMicrosoft DNXDnvmdnvm.ps1 : Unable to find any runtime packages on the feed! At line:1 char:1
@Anon Try this:
$env:DNX_FEED= "…/v2"
For me, the latest dnvm (1.0.0-beta4-10356) seems to be using the exact same url as default stable feed so there is no need to set the entvar.
Also when installing the latest version by PowerShell, %userprofile%.dnxbin is not automatically added to path. That's why you can't run dnvm directly.
Will the mono DNX still be available once dnu works on CoreCLR? I am asking since there a cases where I need the full framework parts that mono provides for some projects. Also there is the fact that CoreCLR is not out for x86.
I am behind a company proxy, how do I upgrade DNVM?
DNVM, NPM, Bower, Gulp all require separate proxy configuration. This is madness and needs to be fixed.
Hmmm…Nuget seems to be short some beta5 packages. EntityFramework and Microsoft.Framework.Logging.Testing still show as beta4 (there may be others). Also, it looks like the github repos master branches are still at beta4. Will these be switched to beta5 and if so when? If not, what branch should we get beta5 source from, release?
P.S. I can't say it enough, but this new stack seems awesome. I also love watching the weekly(ish) Community Standups, lots of good stuff on there.
@Binh-Nguyen Tran, You will want to do something like the following to use the new Configuration assembly
public IConfiguration Configuration { get; set; }
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
var builder = new ConfigurationBuilder(appEnv.ApplicationBasePath)
.AddJsonFile("config.json")
.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables()
.AddIniFile("config.ini", optional: true);
Configuration = builder.Build();
}
This code assumes you have added the dependency to Microsoft.Framework.Configuration.Json, so if you only needed the ini file capability you would just need Microsoft.Framework.Configuration (notice the ConfigurationModel dependency isn't used anymore).
Upgrading doesn't work:
C:UsersChris>set DNX
DNX_FEED="…/v2"
C:UsersChris>dnvm upgrade
Determining latest version
C:Program FilesMicrosoft DNXDnvmdnvm.ps1 : Unable to find any runtime packa
ges on the feed!
At line:1 char:182
+ … envvars.cmd';& 'C:Program FilesMicrosoft DNXDnvmdnvm.ps1' upgrade
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExcep
tion
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio
n,dnvm.ps1
@Chris Seems to be working for me. Check the output of just running "dnvm" and make sure you have the right default feed configured. If you are still having problems then open an issue on github.com/…/issues and we will see if we can help you out.
@Chris: I had the same thing. When I user PowerShell instead of command prompt it worked.
I struggled a little bit with the update until I found this on github:
github.com/…/1746
deleting the cache solved it
going forward to test the new bits!
I've been working with beta4 trying to port an app from mvc 5 and making good progress.
Reading the instructions for upgrading to beta5 and reading the comments has made me reluctant to try it for fear of getting things into a broken state that I can't resolve which would stop my progress on porting the app.
I'm not worried about resolving the breaking changes from the announcements repo, I feel confident to handle that stuff but still thinking maybe I should wait for beta6 which will come with the next version of VS.
I can see the beta5 packages in my nuget feed and I guess I don't understand why I can't just update there or why these command line steps which may or may not work for me are needed. Its the posts about missing nuget packages (here an in other places) and command line errors that I'm worried will get me into a corner I can't get out of. I wish it were as simple as updating the nugets and I wish I was confident all the nugets would be there and be in sync.
Updated everything according to steps above. However, visual studio doenst show beta5 packages in intellisence in project.json. Keeps insisting only beta4 packages exist. When I specify "Microsoft.AspNet.StaticFiles": "1.0.0-beta5" for example resolving works fine. Seems only the intellisence is broken or not updated.
If anyone is having problems migrating from beta4 to beta5, you can refer to this stackoverflow answer which I did, maybe it will help you. stackoverflow.com/…/31281489
Cheers.
Hey, Thanks to share this new update of asp.net.Asp.net5 beta5 is a new update with new features and improvements. I have some idea regarding asp.net from the myasp.net site. Now I get some more knowledge.
Good work. | https://blogs.msdn.microsoft.com/webdev/2015/06/30/asp-net-5-beta5-now-available/?replytocom=54541 | CC-MAIN-2018-47 | refinedweb | 1,963 | 67.35 |
Retrieve the first item from a list
list get first element java
how to get first element of arraylist in java
java 8 get first element of list
list get first element c#
java 8 get last element of list
get last element of list java
get first element of set python
I'm having trouble getting the first item from a list. The data is added to the list from a text file however, the system is returning
System.Linq.Enumerable+<TakeIterator>d__25'1[System.String] instead of the first item in the list.
The following is my implementation
string[] inputData = rawInputData.Split(','); List<string> splitData = new List<string>(inputData.Length); splitData.AddRange(inputData); var numberOfCaves = splitData.Take(1); Console.Write(numberOfCaves);
I am unsure as why this is happening and any suggestions would be appreciated, Thanks!
Retrieve the first item from a list, Just use FirstOrDefault . You can also save yourself a lot of footwork, as Split returns an array ( IEnumerable ) already. So you don't have to If you need to get the first text value in a list (a one-column range) you can use the VLOOKUP function set to exact match, with a wildcard character for the lookup value. In the example the formula in D7 is: =
Use
First or
FirstOrDefault instead. These eagerly get the first item.
Take uses deferred execution, so what you are actually printing is the
ToString() of the iterator, not the value of the first item.
The best clue when you experience these kind of issues with LINQ is that you should assume that anything returning
IEnumerable<T> is deferred (not always true though) and that anything returning a single item is eager (e.g.
Max,
First,
Single, and so on).
Python, Let's discuss certain ways to get the first and last element of the list. Method #1 : Using list index. Using the list indices inside the master list can perform this Retrieving the first value in a list that is greater / smaller than a specified value The generic formula for finding the first number from a list that is greater than a given number is. = INDEX (list,match(TRUE,list>number,0))
Aside of First or FirstOrDefault you can also directly access the array entries.
string[] inputData = rawInputData.Split(','); string first = inputData[0]; string second = inputData[1]; ...
But you have to make sure that the array index you access really exists. Otherwise you get an Exception for accessing non existent entry.
Get first and last elements from ArrayList in Java, If we know how to get the size of ArrayList then we can get those two values easily. But remember, that you java program print first and last element of a List. To return items from a list, use the GetItemById() method to return a single item, or the GetItems(CamlQuery) method to return multiple items. You then use the Load<T>(T, []) method to attain list item objects that represent the items. Retrieving items from a list
How to get first and last elements from ArrayList in Java?, How do I find the first element of a list? first create a variable containing the first four values then using the extend () function extend the tlats four values with the first value the return the variable extended as follows: def rt (lis): first4 = lis [:4] last4 = lis [-4:] last4.extend (first4) return (last4) Vittorio Somaschini. 33,367 Points.
How to get the first element of each tuple in a list in Python, How do you get the first value in a list Python? Copies the list. Can return a subset. Also, if you are performing many pop (0), you should look at collections.deque. from collections import deque >>> l = deque( ['a', 'b', 'c', 'd']) >>> l.popleft() 'a' >>> l deque( ['b', 'c', 'd']) Provides higher performance popping from left end of the list. share.
Get first element in list, How do you print the last value in a list Python? List<string> list1 = new List<string>(); list1[0] //for getting the first element of the list
- As a side note, result can never be null here. | http://thetopsites.net/article/53420681.shtml | CC-MAIN-2021-04 | refinedweb | 687 | 63.19 |
What
JavaScript Notes
Language notes — ECMAScript 5
Compiled by Jeremy Kelly
These are my personal JavaScript notes, covering implementations deriving from ECMAScript 5. They%.
It is possible to end some lines without semicolons, particularly if the next line cannot be parsed as a continuation of the current line. This should be avoided outside of minifiers.
Single-line comments are prefixed with
//. Multi-line comments begin with
/* and end with
*/.
Identifiers must begin with letters, underscores, or dollar signs. After the first letter, digits can also be added.
Along with JavaScript keywords, the following reserved words are forbidden for use as identifiers:
When strict mode is enabled, these words are also reserved:
In ECMAScript 3, all Java keywords were reserved.
Boolean values are represented with
true and
false. When evaluated as booleans, falsy values like these are considered to be
false:
undefined
NaN
null
All other values are considered to be truthy.
All numbers are represented with double-precision IEEE 754 floats. JavaScript does not provide integer types, but all integer values between -253 and 253 retain full precision in the number type. JavaScript defines global variable
Infinity and
NaN to represent infinite values and undefined numeric results. As in other languages,
NaN is unequal to every value, including itself. A value can be checked for
NaN with the global function
isNaN. This function also returns
true if the value is something other than a number or boolean, though type conversion causes
isNaN('') to return
false.
isFinite returns
false if the value is positive or negative infinity, or
NaN.
Numbers can be specified with scientific notation, the exponent being marked with
E or
e:
var gTol = 1E-3;
Hex values are specified by prefixing the number with
0x or
0X. These cannot have fractional components.
Number primitives are wrapped by the
Number class. Its methods include:
toString()
toString(base)
toFixed(ct)
toPrecision(ct)
JavaScript strings are sequences of 16-bit character values. There is no distinct character type. Strings are immutable.
String literals can be surrounded with single or double quotes. Quote characters are escaped with a single backslash. Long strings can be split across lines by ending each line with a backslash inside the string:
var gWarn = "No people ever recognize \ their dictator in advance";
Single backslashes in other positions have no effect, and are excluded from the string.
The usual escape sequences are available:
An arbitrary character can be specified by combining
\x or
\u with a number of hex digits:
If
\0 is followed by a digit, the digit sequence will be interpreted as a octal number, producing an exception if strict mode is enabled, or an unexpected result if it is not. It is safer to specify the null character with
\x00.
String primitives are wrapped by the
String class. Its properties and methods include:
length
charAt(index)
substr(start, len)
Returns the substring that begins at start and has length len. If start is negative, it is considered to wrap once orig with substring new. orig can be a string or a regular expression. If it()
padStart(len)
padStart(len, pad)
padEnd(len)
padEnd(len, pad)
As of ECMAScript 5, array syntax can be used to read characters from a string, just like
charAt. Because strings are immutable, the characters cannot be modified:
var oCh = gWarn[0];
undefined is a unique instance of its own dedicated primitive type, as is
null.
undefined is assigned to variables that have been declared but not initialized, among other things. If an attempt is made to read a variable that has not been declared, the browser will throw a
ReferenceError exception in JavaScript, and, like other objects, these can store properties, including other functions. All object variables are references. Objects are never passed by value.
Global values are members of the global object, which is created when the JavaScript interpreter starts. This includes global properties like
undefined and
NaN, functions like
isNaN, constructors like
String, and custom globals defined in the script. Within a browser, the global object also serves as the
Window object.
An object can be serialized by passing it to
JSON.stringify, which returns a string containing a JSON representation. The object can be deserialized with
JSON.parse. JSON represents data with a subset of the JavaScript object literal syntax.
Property names need not qualify as identifiers. In fact, any quoted string can serve as a name, even the empty string:
var oLook = { "Site E": 108, "Site F": 90, "": 0 };
In this sense, objects are more like maps than traditional class or structure instances. If a particular name is not a valid identifier, it must be dereferenced with the array syntax:
var oCd = oCdsFromName["Site E"];
This syntax also allows the name to be specified with a variable:
var oKey = "Num"; var oNum = oRack[oKey];
When using the array syntax, nested objects:
var gPrefs = { Def: { Name: "New", LenMax: 10 } };
are accessed by concatenating dereference operators, just as a nested array would be:
gPrefs["Def"]["Name"] = "OBSOLETE";
Properties can be added to an object by assigning to them. There is no need to declare the property:
oRack.Num = 10;.
As of ECMAScript 5,: so that it hides the parent value, as usual.
Accessors can be added to existing objects with
Object.defineProperty or
Object.defineProperties.
In ECMAScript 5, properties have attributes that determine whether they are enumerable, whether they can be reconfigured or deleted, and whether their values can be changed. Attributes are also used to create accessor properties.
The attributes for a single property can be set by passing the object, the name of the property, and a property descriptor to
Object.defineProperty. If the property already exists, and if it is configurable, it will be modified. If it does not exist, it will be created:
Object.defineProperty(oRef, "Cd", { get: function () { return "F" + this.Num; }, set: function (a) { this.Num = a.substring(1); }, enumerable: true, configurable: true });
Multiple properties can be configured by passing the object to
Object.defineProperties, along with a second object associating one or more property::
var oCkCd = "Cd" in aParams;
It also accepts a number and an array. It returns
true if the number is a valid index for the array:. In ECMAScript 5, the
Object.keys method also identifies enumerable properties, but it returns an array of names, and it excludes inherited properties. The
Object.getOwnPropertyNames method returns a similar array, but non-enumerable properties are included.
The
delete operator removes a property from an object. The property can be referenced fails silently. Inherited properties cannot be deleted through the child; they must instead be deleted through the parent to which they were added.
Objects can be initialized with object literals, which contain property/value pairs within curly braces. Each property is separated from its value by a colon, and multiple pairs are delimited with commas:
var oRt = { Region: gRegionDef, Zone: 0 };
Omitting the properties produces an empty object:
var oRack = {};
As in other languages, a constructor is a function that initializes new objects, though in JavaScript, the function is not a member of the type. As will be seen, constructors are often used to store class-static variables and methods. They are invoked like functions, but they are preceded by the
new keyword:.
Constructors are not meant to return values. If an object is returned, the first constructed object will be replaced with the returned value. If a non-object value is returned, it will be ignored.
Note that the new object's
constructor property is not necessarily set to reference the function just invoked. The constructor has a
prototype property, that object has a
constructor property, and that value is assigned to the new object's
constructor. By default, this will reference the actual constructor, but it can be changed in the prototype.
In ECMAScript 5, objects can also be instantiated with the
Object.create method. This method accepts an argument that specifies the object's prototype:
var oData = Object.create(tData.prototype);
Note that the new object's
constructor property is set to the
constructor of the prototype, even though that function was relies on prototypal inheritance, which has little in common with traditional OOP inheritance. In JavaScript, inheritance describes a relationship between objects rather than types. Inheritance for a particular object is determined by the private prototype property, which references the parent object, or
null if there is no parent. A class in JavaScript is simply the set of objects that share a given prototype.
When a property is accessed, it is first sought within the referencing object. If that object has not declared the property, it is sought within the object's prototype. The prototype is another object. If it does not declare the property, its prototype is checked, and so on, until a
null prototype is encountered. In this way, every object inherits all the properties of its ancestors, including methods, throughout the prototype chain. Properties that have not been inherited are called own properties.. If the property is an inherited accessor with a setter, that setter will be called, though any property it assigns will again produce a property in the child that hides the parent value.
An object's prototype is assigned when the object is created. Every function has a
prototype property that references a default prototype object. When the function is used as a constructor, the prototype is automatically assigned to the new object:
function tOpts() { ... }; var oOpts = new tOpts();
Because every function has this property, every function can theoretically be used as a constructor, though seldom to useful effect. The default prototype for each function contains a non-enumerable
constructor property that references the original function. Overwriting the function's prototype breaks this link:
tOpts.prototype = { Ct: function () { ... }, ... };
The
constructor property can be restored manually, or the problem can be avoided by adding custom properties to the default, rather than overwriting it entirely:
tOpts.prototype.Ct = function () { ... };
Every object has a
constructor property that references the constructor that was used to create it. In ordinary usage, this matches the
constructor property in the object's prototype.
The
Object.create method accepts an object parameter, and assigns that parameter as the prototype of the returned object:
var oOpts = Object.create(tOpts.prototype);
When this is used, the object's
constructor is set to match the
constructor property in the prototype. An object can also be created with an object literal, which causes
Object.prototype to be assigned as the object's prototype, and
Object as its constructor.
If the prototype's
constructor property is maintained, all objects in the class will also share a common constructor, at least by default. This allows class-static variables and methods to be defined in and accessed through the constructor. These could not be added to the prototype, as that would cause the values to be inherited and shared.
To summarize the standard usage:
When one class subclasses another, the prototype of the subclass prototype is made to reference the superclass prototype. The subclass prototype
constructor is then set to reference the subclass constructor, rather than the superclass constructor. The subclass constructor typically uses
call to invoke the superclass constructor on the subclass
this.
An object's class is determined by its prototype. The
instanceof operator accepts an instance on the left and a constructor on the right. It returns
true if the instance is an object, and if it inherits from the object referenced by the constructor's
prototype property, whether directly or indirectly. Adding properties to the object does not change this result. By extension, the operator typically returns
true if the right operand is
Object, since all objects inherit from
Object.prototype, at least by default. Similarly, arrays can be identified by setting the right operand to
Array. The
isPrototypeOf function also indicates whether one object is the ancestor of another, though it is invoked on the prototype, and receives the child as an argument.
The object's prototype can be retrieved by passing the object to the
Object.getPrototypeOf method, and it can be set by calling
Object.setPrototypeOf, though this is discouraged for performance reasons. Most browsers also support the non-standard accessor property
__proto__, which provides read and write access to the prototype.
An extensible object is one to which new properties can be added. An object's extensibility can be checked by passing it to
Object.isExtensible. It is made non-extensible by passing it to
Object.preventExtensions, and once this is done, the object cannot be made extensible again.
A sealed object is non-extensible, and its properties are non-configurable as well. To determine whether an object is sealed, pass it to
Object.isSealed. To seal the object, make it non-extensible, then make its properties non-configurable by setting their attributes, or pass the object to
Object.seal. A sealed object cannot be unsealed.
A frozen object is sealed, and all its properties are read-only. To determine whether an object is frozen, pass it to
Object.isFrozen. To freeze the object, seal it, and make its properties read-only by setting their attributes, or pass the object to
Object.freeze. A frozen object canot be unfrozen.
JavaScript arrays inherit from
Array.prototype. They are typically created with array literals, which are comma-delimited value sequences inside square braces:
var oInsPend = [ "A11", "B04", "CXX" ];
When commas are listed without intervening values, succeeding values are indexed and the array length set as though values had been provided. The last trailing comma before the closing brace is ignored, however:
var oInsMark = [ , "NUL", , ]; gAssert(oInsMark[1] === "NUL"); gAssert(oInsMark.length === 3);
Though the array length includes them, the missing values do not define actual with the specified length, but again, without defining actual elements. Passing multiple arguments, or a single non-numeric argument assigns those values as elements, much like an array literal:
var oInsPend = new Array("A11", "B04", "CXX");
JavaScript arrays are untyped, so different types can be mixed in the same instance. Arrays are indexed with 32-bit unsigned integers, allowing over four billion elements to be stored. The element count is given from an object.
The
length property can be modified to truncate or extend the array. Assigning to a valid index that is greater than or equal to the current
length also extends the array, and in both cases, the
length is increased without adding enumerable elements.
Multidimensional arrays must be implemented as arrays of arrays.
The
Array class includes methods such as:
join()
join(delim)
slice(start)
slice(start, next)
concat()
splice, if one or more arguments are themselves arrays, their elements are added, rather than the arrays as a whole.
reverse()
sort()
sort(compare)
splice(start)
splice(start, len)
splice(start, len, ...)
concat, array arguments are inserted as arrays.
push(el, ...)
pop()
unshift(el, ...)
shift()
In ECMAScript 5, additional methods are provided. These include:
indexOf(val)
indexOf(val, start)
lastIndexOf(val)
lastIndexOf(val, start)
The following methods accept a call function that itself accepts up to three values: an element, its array index, and the array as a whole. These array methods also accept an optional this parameter. When this is provided, it is referenced wherever
this is used within call:
forEach(call)
forEach(call, this)
map(call)
map(call, this)
filter(call)
filter(call, this)
true.
some(call)
some(call, this)
trueif call returns
truefor any element.
every(call)
every(call, this)
trueif call returns
truefor every element.
The following methods accept a callAcc function that itself accepts up to four values: an accumulator that stores an ongoing calculation, an element, its array index, and the array as a whole:
reduce(callAcc)
reduce(callAcc, init)
reduceRight(callAcc)
reduceRight(callAcc, init)
Some objects, like the
arguments object stored in instances of the
RegExp class. Instances can be created with the
RegExp constructor:
var oRegCd = new RegExp("A[1-3]");
or with regular expression literals, which surround the expression with forward slashes:]. Additionally, a given control character
ctrl-X can be specified as
\c X.
The trailing slash may be followed by one or more letters that set flags:
var oRegCmds = /F\d\d/ig;
The letters can also be passed as a second parameter to the
RegExp constructor. Flags are used to configure the search:
Expressions can also use character classes, each of which matches one of a number of characters. Enclosing characters with square braces produces a character set, which matches any one of the contained characters:
var oRegNumLot = /[123]/;
Prefixing the characters with a caret negates the set, so that it matches one character that is not within the braces:
var oRegCdLot = /[^123]/;
A range of characters is specified by joining the lower and upper limits with a hyphen:
var oRegDigOct = /[0-7]/;
Neither
. nor
* are treated as special characters within a set, so they need not be escaped.
Other classes include:
Entire sequences can be matched against a set of alternatives by delimiting sub-expressions with the pipe character: between the remainder, and the rest of the expression.
Surrounding characters with parentheses produces a sub-expression that can be modified as a whole by a quantifier or another function:
var oReg = / (XO)+ /;
These capturing parentheses also store the target substring matched by the sub-expression. The substring can be recalled in another part of the expression by prefixing the sub-expression number with a backslash:
var oRegChQuot = /(["']).\1/;
The recalled substring is matched only if the target text contains an exact repetition of the substring that matched the referenced sub-expression. The characters inside non-capturing parentheses are prefixed by
?:.:
The
RegExp class offers methods that search for matches within a string:) {.
The arithmetic operators function mostly as expected. However:
Infinityor
-Infinity. Dividing zero by zero produces
NaN;
%also works with non-integer values, and when it produces a remainder, its sign matches that of the first operand;
+can be used to convert non-numeric types to numbers.
The loose equality operators
== and
!= check for general equivalence, so various type conversions are allowed. By contrast, the strict equality operators
=== and
!== check for equivalence and verify that the operands have the same type. When applied to arrays, functions, and other objects, both varieties check for identity, so distinct but otherwise identical instances are not strictly equal. There is no operator that tells whether distinct objects or arrays contain the same properties and values.
The
void operator accepts a single operand, which it evaluates. It then discards the result and returns
undefined.
As in other languages, the sequence operator evaluates both its operands and returns the value on the right:
var oYOrig = (++oX, ++oY);
Because this operator has the lowest possible precedence, a sequence expression must be parenthesized if its result is to be assigned.
The
typeof operator returns a string that gives the general type of its operand, whether "undefined", "boolean", "number", "object", or "function".. Objects always produce
truewhen converted to booleans.
These conversions are used when comparing values with the
== operator, so
undefined is equal to
null,
"1" is equal to one, and
"0" is equal to
false. When a string is added to any other type with the
+ operator, the non-string type is converted to a string.
Explicit conversions are performed by passing values to the
Boolean,
Number,
String, or
Object constructors. For values other than
undefined and
null, a string can also be produced by invoking the value's
toString method.
Strings can also be converted to numbers with the global
parseFloat function, which trims the string of leading whitespace and trailing non-numeric characters, and returns
NaN if the string is not a valid number. The global
parseInt function works similarly, but it only converts integers, and it accepts hexadecimal input if the string begins with
0x or
0X.
parseInt also allows the number base to be specified.
Variables are declared with the
var keyword. Multiple variables can be declared and optionally initialized in the same line by separating them with commas:
var oX = 0.0, oY;
Uninitialized variables have the
undefined value. Redeclaring a variable has no effect. If the new declaration also initializes the variable, it is simply assigned with the new value..
A variable declared within a function is accessible throughout the function, even from points before its declaration. This effect is called hoisting. If the variable is read before the declaration, its value will be
undefined.
Variables have no type, so a value of one type can be overwritten with another type at any time. loop variables defined within the initialization statement of a
for loop to be accessed outside the loop:
for (var o = 0; o < oCt; ++o) { ... } var oIdxMatch = o;
Because they are hoisted, such variables can even be used before they are declared.
The
for/
in loop iterates over an array, and its loop variable is also accessible from outside:
for (var o in oEls) if (Ck(oEls[o])) break; var oIdxMatch = o;
Note that the loop variable iterates array indices rather than array elements.
for/
in can also iterate the enumerable properties of an object, including those that were inherited. In this case too, it iterates property names rather than values:
for (var oIdxBl in oBls) { for it is permissible to provide a function name, these definitions are typically anonymous:
var gReset = function (aPos, aCkSync) { ...
Function instances can also be created with the
Function constructor: a block. Function expressions can appear anywhere. Like variables, nested function declarations are hoisted, allowing them to be called before they are declared. Although hoisted variables are
undefined before they are initialized, hoisted declarations can be used at any point.
A method is a function that has been assigned to a property in some object. Functions assigned to array elements are also treated as methods. In JavaScript, functions are themselves objects that can contain their own properties, including additional methods.
Functions are sometimes used as namespaces. A global function is defined, variables and functions are declared and used within it, and the containing function is called immediately after. This avoids the name conflicts that can occur when objects are added to the global scope. The pattern is typically known as the Immediately-Invoked Function Expression or IIFE:
(function () { ... }());
Without the outer parentheses, the interpreter would read this as a function declaration, which is required to specify a name. Only expressions are allowed within parentheses. ECMAScript 5, ECMAScript 5, targeted included in a closure, or the function can be wrapped in a bound function that defines its own
this.
Bound functions are created with the
bind method, which is inherited by all functions.
bind returns a new function that wraps the original.
"strict mode" directive is an ordinary string that enables strict mode. This mode offers language and security improvements, including:
ReferenceErrorexception;
thisis
undefinedwithin non-class functions;
withstatement is disallowed;
SyntaxErrorexceptions;
argumentsnor
evalare allowed to be assigned to another object or function;
evalare not added to the containing scope.
The directive must be the first non-comment line in the script; if placed anywhere else, it is silently ignored. It is ignored altogether in versions before ECMAScript 5. throws a
SyntaxError exception.
The
debugger statement pauses script execution and shows the debugger, like a breakpoint.
JavaScript Pocket Reference, 3rd Edition
David Flanagan
2012, O'Reilly Media, Inc.
JavaScript: The Definitive Guide, 6rd Edition
David Flanagan
2011, O'Reilly Media, Inc.
JavaScript & JQuery
Jon Duckett
2014, John Wiley & Sons, Inc.
MDN: String
Retrieved January 2018
MDN: Object.defineProperty()
Retrieved February 2018
MDN: Function.prototype.bind()
Retrieved February 2018
MDN: Regular Expressions
Retrieved February 2018
Stack Overflow: Explain the encapsulated anonymous function syntax
Retrieved February 2018 | http://anthemion.org/js_notes.html | CC-MAIN-2018-39 | refinedweb | 3,921 | 54.83 |
I have a hot tub.
I have a fear that one day the hot tub will quit heating.
I have a fear that when it quits heating it will freeze over and crack.
So I’ve been living in fear for a few years until last week when I discovered 433 MHz devices.
So I took a chance and bought this pool temperature sensor:
$20 risk. It comes with a display which is all well and good but it doesn’t do much for you. It isn’t THAT smart.
So anyway I run a program that snags everything flying around on 433.920 MHz and feeds it to an MQTT server. So I put batteries in my $20 temperature sensor and lo and behold this shows up on my server:
{"time" : "2019-01-18 00:57:24", "model" : "Nexus Temperature", "id" : 174, "channel" : 1, "battery" : "OK", "temperature_C" : 39.900}
The little cheap, no name Chinese clone works like a champ and is compatible with RTL_433 (a program that sniffs out data and decodes it). So now I can dump some code into Home Assistant software but you might note that I placed “temperature_C” above in red.
I have ANOTHER temperature sensor from a weather station that records data with a name of, you guessed it, “temperature_C”
{"time" : "2019-01-18 00:49:51", "model" : "Acurite tower sensor", "id" : 12644, "sensor_id" : 12644, "channel" : "A", "temperature_C" : 7.400, "humidity" : 69, "battery_low" : 0}
So as you might guess the sensor is going to display the first value it sees and this happened:
So both the outside temp and the hot tub temp display as 45.3 degrees F. I don’t think so.
So I had to filter the data in code to make sure that the hot tub temp sensor was only reading from the Nexus Temperature sensor (which has an id number of 174) which, ironically is the designation of the first squadron I was in in the Navy. VA-174 Hallrazors. Hell Yeah! Hellrazors Rule!
So I went into the configuration.yaml file in Home Assistant and set a value_template to filter the data.
sensor: - platform: mqtt state_topic: 'home/rtl_433' name: 'Outdoor Temp' unique_id: '12644' unit_of_measurement: 'F' value_template: > {% if value_json is defined and value_json.id == 12644 %} {{ ((value_json.temperature_C * 1.8) + 32)|round(1) }} {% else %} {{ states('sensor.outdoor_temp') }} {% endif %} - platform: mqtt state_topic: 'home/rtl_433' name: 'Outside Humidity' entity_id: 'sensor.outside_humidity' unit_of_measurement: '%' value_template: "{{ value_json.humidity }}" - platform: mqtt name: 'Hot Tub Temp' state_topic: 'home/rtl_433' unit_of_measurement: 'F' value_template: > {% if value_json is defined and value_json.id == 174 %} {{ ((value_json.temperature_C * 1.8) + 32)|round(1) }} {% else %} {{ states('sensor.hot_tub_temp_2') }} {% endif %}
Wow! Ok I admit I had to seek out help on the interwebs to figure this out. But make no mistake…….I DID FIGURE IT OUT.
Now it looks like this:
103.5 Degrees is more freaking like it. So even now this is not much better than having it display on the fancy screen that comes with the pool temperature floating sensor thingy.
So what I did was to write an automation which will SEND ME A TEXT when the water temperature gets below 95 F.
automation 20: alias: Temp Alarm trigger: platform: numeric_state entity_id: sensor.hot_tub_temp_2 below: 95 action: - service: notify.mypushbullet data_template: title: "Hot Tub Temp Alarm" message: >- Hot Tub Temp Alarm, Bruh
So now when it gets below 95……..this happens (Screen Shot from my phone received a minute or so after taking the sensor out of the water):
So, basically this does not suck at all. I have a Smart AF hot tub that texts me when the water temperature drops below a certain threshold.
You can spend tons of money for such fancy things but hey, I’ll just build it myself.
And Bob is my Uncle. | https://www.hagensieker.com/wordpress/2019/01/18/smart-af-hot-tub-temperature-sensor/ | CC-MAIN-2021-21 | refinedweb | 629 | 74.19 |
Hi,
I am designing an application for which I am thinking of designing the Data Access using the DAO Pattern.
I have a few questions which if anyone could clarify, I would be grateful.
1. DAOs are used so that the client is loosely coupled with the Persistence layer. So, say at a time, you can have only one type of DB at a time, say Oracle OR Sybase OR Sequel etc. So using Factory Pattern, we can create the corresponding DAO Object on the Fly.
But, in my case, I have to talk to different types of DBs at a time. I mean, the DB which is solely to my new application will be one, say Oracle, but the application talks to a few other systems whose DB may be different.
In such a situation, how DAOs can be effectively used? Anybody could help me in this..?
2. Suppose I have various entities in my application domain , say Customer, Order..say a 10 different items.. So according to DAO pattern, I am going to have 10 different types of DAOs..? Is my understanding correct..?
Expecting the replies asap...
Thanks in Advance...
Best Regards
Using DAOs in Design (7 messages)
- Posted by: Narayanan M
- Posted on: November 16 2004 15:59 EST
Threaded Messages (7)
- multiple daos by Richard Cook on November 16 2004 17:29 EST
- multiple daos by Narayanan M on November 16 2004 18:09 EST
- Use of a properties file might help by Shashank Jain on September 17 2006 07:35 EDT
- Using DAOs in Design by Geoffrey Wiseman on November 16 2004 21:05 EST
- Using DAOs in Design by Narayanan M on November 18 2004 15:08 EST
- If you're still interested... by Geoffrey Wiseman on January 07 2005 07:31 EST
- Using DAOs in Design by Kwangshin Oh on November 17 2004 20:49 EST
multiple daos[ Go to top ]
I suggest you have a dao interface. Say CustomerDAO, Then have OracleCustomerDAO, MySQLCustomerDAO, etc. implement this interface. Then using the factory pattern, instantiate the dao's you need for your app.
- Posted by: Richard Cook
- Posted on: November 16 2004 17:29 EST
- in response to Narayanan M
Rich
multiple daos[ Go to top ]
Thanks a lot for ur reply.. But when implememting factory pattern, at a given point of time, I can have only one type of DAO.. either oracle or MySQL or etc.. which will be configured in some place.. (JNDI)
- Posted by: Narayanan M
- Posted on: November 16 2004 18:09 EST
- in response to Richard Cook
But, suppose I need some entities to be read from one type of DB, some other entities from another type of DB, how can I do that..? Can we use multiple factories ?
Use of a properties file might help[ Go to top ]
In the property file you can define what implementation you need for which DAO
- Posted by: Shashank Jain
- Posted on: September 17 2006 07:35 EDT
- in response to Narayanan M
Using DAOs in Design[ Go to top ]
I might be inclined to make use of an O/R mapping layer, but I'm fond of them to begin with.
- Posted by: Geoffrey Wiseman
- Posted on: November 16 2004 21:05 EST
- in response to Narayanan M
If I read you right, you're going to have multiple entities. It's not uncommon to have one DAO per entity, no, although it doesn't have to be that many if you have good reasons to bring them together.
I also gather that you're expecting to be interacting with multiple databases at once. Ignoring questions about things like XA and 2PC, I'm still not sure if you're expecting a single entity to come from more than one database, or different entities to reside in different databases.
That is, are you expecting that Customer will reside in one database and, say, Order in another? That's fine - you could, for instance, have the factory configuration specify the database or the implementation based on the entity requested, or wire the implementations using dependency injection.
If you're expecting a single entity, say, Customer, to reside in more than one database, then it's obviously not a simple as providing a single DAO implementation per entity, and you're into a slightly more complicated territory. In that case, I'd probably need to know more about the deciding factors for a particular datastore are.
Using DAOs in Design[ Go to top ]
Hi Geoffrey,
- Posted by: Narayanan M
- Posted on: November 18 2004 15:08 EST
- in response to Geoffrey Wiseman
Nice to see ur reply... Thanks a lot for spending time to analyze my problem.
You have got it correctly. Say, Customer entity will always be coming from a given DB. and may be Order entity will be coming from a different given DB.
Only thing is that the system talks to different types of DB at a given point of time. ie. If I implement a DAO pattern, and when I ask for Customer DAO, it should give me the implementation class corresponding to the DB I have configured,and similiarly for Order also.. So , in brief, at a time, I should be able to connect to different DBs(ofcourse for different entities).
Now as per my understanding, a factory pattern will, in a given point of time, will provide me one implementation.. ie either Oracle or a 'X' DB imp.
How can I imp the DAO pattern, so that When I need Customer DAO, I want,say,the Oracle Implementation, and when I need a Order DAO, a DB2 implementation..
Expecting to hear from u...
If you're still interested...[ Go to top ]
Sadly, I failed to check up on this thread, so I missed your return query.
- Posted by: Geoffrey Wiseman
- Posted on: January 07 2005 19:31 EST
- in response to Narayanan M
In essence, if you have a factory of some kind creating DAO objects, that factory can supply a connection or datasource to the DAO upon DAO creation.
The factory could then be configured on a DAO by DAO basis to supply one of several datasource based on the DAO being requested.
For instance:
public class Dao
{
private Connection dbConnection;
public Dao( Connection dbConnection ) { this.dbConnection = dbConnection; }
// any other DAO superclass stuff
}
public class CustomerDao
{
public CustomerDao( Connection dbConnection ) { super( dbConnection ); }
// rest of DAO
}
On the factory side, you'd then use some kind of configuration (e.g. file, hard-coded configuration, script, whatever works best for you) to map from a class or dao name (however you make the factory/service locator request) to the DAO class and the appropriate data source.
It's difficult to get much more detail without knowing a lot about how you'd implement the DAO and the factory, but this should start you off in the right direction.
Of course, there are lots of other options here, ranging from accessing your DAOs from a more evolved service location pattern (Spring's IoC, Hivemind, etc.) to using an O/R mapping layer. Some O/R mapping layers may explicitly support multiple datasources, although I can't recall that as a feature in any that I've used.
Using DAOs in Design[ Go to top ]
Hi,
- Posted by: Kwangshin Oh
- Posted on: November 17 2004 20:49 EST
- in response to Narayanan M
Have you read this article?
Core J2EE Patterns - Data Access Object
I have using this pattern for a few years.
I strongly recommend this pattern and article.
Best Regards,
Kwangshin | http://www.theserverside.com/discussions/thread/30008.html | CC-MAIN-2018-05 | refinedweb | 1,263 | 60.04 |
CloudCannon CMS for Jekyll: Building a Multilingual SiteSeptember 22, 2017
In a rush? Skip to tutorial steps or GitHub repo & live demo.
DEV FRIEND: "Static site generators are cool, but I couldn't hook my next client up with, say, Jekyll."
ME: "Why is that?"
DEV FRIEND: "Well, I'd need a Jekyll multilingual site with e-commerce, plus some type of simple CMS for Jekyll so my client wouldn't touch any code. Last I checked all that was less of a hassle with a good ol' CMS."
ME: "It's 11 PM, and I've got a beer to finish, but let me get back to you on that."
The following day, I sat down with our content team and told them about my friend. We decided to come up with a tutorial to ~~prove him wrong~~ help him out.
2-3 years ago, modern static sites were regaining popularity, but suffering heavy backlashes:
No backend! No dynamic functions! No complex data handling! No CMS!
With the rise of the JAMstack, however, things have changed.
Today, I'm going to show how to integrate multiple languages into a Jekyll site and strap an easy-to-use CMS on top of it—CloudCannon.
We'll also be using one of CloudCannon's nifty Jekyll templates with built-in Snipcart e-commerce.
First, a bit of context.
CMS for Jekyll: CloudCannon & alternatives
Created by GitHub co-founder Tom Preston-Werner, Jekyll has positioned itself as the static site generator in the last years. Written in Ruby, it allows developers to quickly transform plain text into full-blown sites & blogs. Its go-to tools:
- Markdown writing
- Liquid templating
- Front matter formatting
- HTML/CSS styling
To get more hands-on with Jekyll, read this popular post of ours.
Is managing content on Jekyll sites easy?
For us developers? Yeah. With Jekyll, we ditch databases and store content in any Git repo—making for faster, secure sites. Now, most of us know their way around Git. We find no challenge in, say, blogging in markdown files and pushing to GitHub. Quite the opposite.
But non-technical folks? Yikes.
Mastering a UI like WordPress' is often a challenge for green content editors. So you can bet they'll hate your guts if you force them into a Git-centric workflow. It's no surprise that the lack of CMS for Jekyll has been a recurring complaint from developers building sites for non-technical clients.
Good news is these complaints are slowly fading. Why?
Because an ecosystem of content management systems for static sites is slowly but surely emerging.
Why use CloudCannon as a CMS for Jekyll?
If you want to see what kind of stree cred' CloudCannon has, take a look at what Ashi Sheth from Netflix has to say:
Clearly it can't be that bad, right? Bragging aside, we (Snipcart) go way back with CloudCannon. However, in the spirit of transparency, I'd like to list a few valuable Jekyll admin solutions.
Jekyll CMS alternatives
→ Supports: roles & permissions, content preview, Markdown or WYSIWYG editor, collections, advanced metadata, custom permalinks, GitHub integration.
→ Hosting: Amazon S3, GitHub Pages, Rackspace, FTP.
→ Supports: roles & permissions, Git integration, mobile management, content preview.
→ Hosting: Amazon S3, GitHub Pages, Fastly, FTP, etc.
→ Supports: roles & permissions, Git integration, collections, advanced metadata.
→ Hosting: Netlify, Amazon S3, GitHub Pages, FTP, etc.
→ Pricing: FREE—open source
→ Supports: roles & permissions, GitHub integration, edition workflow, extendable UI, content preview, flexible content types.
→ Hosting: Easy with Netlify CDN, but host-agnostic.
So why CloudCannon CMS?
Like others above, CloudCannon leverages Git to synchronize website collaboration between non-technical users & developers.
Content editors use the clean graphical interface; developers stay in their chosen repo.
1st scenario: Editor edits content in CloudCannon UI → CloudCannon saves content in GitHub → build
2nd scenario: Developer pushes to GitHub → CloudCannon receives webhook → synchronizes data → build
Marketers get more autonomy; developers save time.
Key sections can be easily edited in-app, and so can meta data with front matter. The CMS will automatically choose the right field type in the UI by binding to the name of your front matter tags: color pickers, date pickers, collections dropdowns, etc.
CloudCannon also pushes the "user friendliness" of content management further with inline editing. The admin can display a visual editor of the Jekyll site where editors simply click on fields they want to edit. These fields have to be pre-determined by developers (docs here).
Its pricing scales super well for freelancers and teams too:
Multilingual Jekyll sites: context
At its core, Jekyll is a "hackable" generator. It's one of the reasons devs love it. If your use case isn't supported out of the box, you just use or build plugins.
Our "advanced" use case here? E-commerce multilingual support.
In our Québec hometown, bilingualism [FR/ENG] is often a must for merchants.
While traditional platforms like WordPress typically offer easy "i18n" plugins & features to support multiple languages, static generators like Jekyll require a bit more work. A small trade-off for their benefits: performance, security, simplicity, scalability.
There a few options available to build a multilingual website with Jekyll. Some use gem plugins, others are hand-made using all the flexibility of Jekyll. The ones I tried (like the Jekyll multiple languages plugins) were interesting but incompatible with most recent Jekyll versions. So for this tutorial, I went with a custom approach. Why? First, so you can use an up-to-date Jekyll and update it later without dealing with gems and Ruby code. Second, because GitHub pages (which we'll use later) won't execute custom Jekyll plugins.
The following demo will show you how to use CloudCannon's Jekyll e-commerce template and:
- Structure & prepare site/templates for multiple languages
- Add a language selector to Jekyll template
- Set up translation fallback for content that hasn't been translated
- Allow permalinks to be 100% translated
Building a Jekyll multilingual site with CloudCannon CMS
When launching a new project on CloudCannon, you can either 1) use their templates, 2) import static files, or 3) sync an existing repo from one of their supported storage (GitHub, Bitbucket, Dropbox).
One of their base templates comes with Snipcart built-in. We'll use it for this multilingual demo, and GitHub for storage.
Prerequisites
- Git, Ruby and bundler installed
- A basic understanding of Jekyll
- A Snipcart account for e-commerce to work (free in test mode)
1. Installing and tweaking the Jekyll template
First, let's clone the repo. Later, we'll deploy to CloudCannon, allowing editors to manage content/products.
git clone my-ecomm-site cd my-ecomm-site
At the project's root, a
Gemfile defines Jekyll's version, which we'll install using bundler. This allows us to make sure we're using the proper Jekyll version:
bundler install bundler exec jekyll serve
Now go to. Local website running, yay!
First thing you should have a look at is
_config.yml. That's where we'll change the main information about the site. Let's start by choosing a great title and set your Snipcart API Key.
To update
_config.yml, you'll have to restart the
bundler exec jekyll serve command. Most other changes should be picked up automatically by Jekyll. Other noteworthy stuff:
_sassfolder: site's styles in SCSS
css,
images&
jsfolders: static assets
_layout&
_includesfolders: templates
_products,
_categories&
_pagesfolders:
- Actual content of your website in multiple subfolders per lang
- A
_defaults.mdfile defining default fields enabling content creation on CloudCannon
2. Organizing Jekyll content for multiple languages in CMS
Organizing site content will define how we work with Liquid templates and how CloudCannon will handle editing. I went with subdirectories per lang since it fits with Jekyll's configuration to set default values.
A few things in
_config.yml for our translation:
langsvariable: list of supported languages
t.default_langvariable: default language
- used to know which language's at the root of the site
- our products' data are fetched from the default language version of the product
t.{en/fr/...}values:
- localization strings where we'll put translations for our templates
- in any Liquid template, we'll be able to use
{{site.t[page.lang].my_translated_string}}
defaultsvalues: filter our content by file path to set default values
Let's have a closer look at the
defaults values' format:
defaults: - scope: path: "_products/fr" values: permalink: "/fr/produits/:title" lang: "fr"
For each supported site lang, we'll add one of these blocks to set language on the subfolder and translate the permalink. That block above basically means:
For any content file in the
_products/fr folder, set the lang to
fr and use
/fr/produits/:title as permalink.
So we can translate the base of our URLs for each lang. Because the
:title parameter is replaced by the
slug variable from our content documents, we can have fully translated URLs! :)
3. Allowing users to switch language on site
An important component of a multilingual site is the ability to switch languages. We'll need an easy-to-use language selector here.
That's where some of the content organization decisions we made come in handy. To identify corresponding pages in different languages, we'll use the file's name. Say you have created a product in
_products/en/burger.md, you'd create its French equivalent in
_products/fr/burger.md.
<ul> <!-- site.langs is the list of supported languages we defined in _config.yml --> {{ for lang in site.langs }} {% if lang == page.lang %} <!-- We are on that lang's page, no need for a link --> <li class="active">{{lang}}</li> {% else %} <li> <!-- extract the file name from its path --> {% assign pageName = page.path | split:'/' | last %} <!-- generate the path of the file in the other language --> {% capture otherPath %}_{{page.collection}}/{{lang}}/{{pageName}}{% endcapture %} <!-- get the page in the other language from its collection --> {% assign otherPage = site[page.collection] | where:'path', otherPath | first %} <!-- getting the page's URL that way allows us to fully translate our page URLs --> {% assign langUrl = otherPage.url %} <a href="{{langUrl}}">{{lang}}</a> </li> {% endif %} {{ endfor }} </ul>
Code might seem a bit complex, but unlike other approaches, it enforces a specific format for each page's language URL. It's what allows us to fully translate every URL.
4. Listing all products—even those without translations
Even with a good CMS and structure, managing many products & languages can become hairy. It's easy to forget a translation. Still, you wouldn't want a product hidden from your customers should that mistake happens.
Or, for instance, if your costs increase and you need to update prices, you don't want to have to pass every products' languages to update prices.
To avoid all that, we'll use price information from the product in your site's default language.
Here's how to list every product and fallback to the site's default language:
<!-- we start with a Jekyll hack for creating an array --> {% assign {% for currentName in productNames %} {% assign mainProduct = null %} {% assign currentProduct = null %} <!-- Okay, not proud of that: algorithm complexity is O(n²) --> {% for product in site.products %} <!-- same way to get the product name again --> {% assign productName = product.path | split:'/' | last | split: '.' | first %} {% if currentName == productName %} {% if product.lang == site.t.default_lang %}<!-- it's the product's data for the default language, we'll use that one for pricing data -->{% assign mainProduct = product %} {% endif %} {% if product.lang == page.lang %}<!-- here's the one we're actually looking for -->{% assign currentProduct = product %} {% endif %} {% if currentProduct == null %}<!-- let's have a fallback in case both the default language and the current one aren't found -->{% assign currentProduct = product %} {% endif %} {% endif %} {% endfor %} {% if mainProduct == null %} {% assign mainProduct = currentProduct %} {% elsif currentProduct.lang != page.lang %} <!-- it's better to use the default language for missing translations than a random one --> {% assign currentProduct = mainProduct %} {% endif %} <!-- enough code here, let's pass that data to another file --> {% include product.html main=mainProduct current=currentProduct lvl=include.lvl %} {% endfor %} </ul>
Two main parts to the code above:
- Getting every product's filename for a category
- Getting the actual product's data from that filtered list
We have to do that because Jekyll's
where_exp is very limited. We can only compare items property with another variable and not a transformed value.
And that's it! That was the most hard stuff to get multilingual. A few ideas to make your site even more awesome:
- Add alternate links in your site's head.
- Add products ordering.
- Add CloudCannon's editor links to your products.
GitHub repo & live demo
Now go ahead, browse our demo site and sift through our open source code!
See Jekyll multilingual e-commerce site
Closing thoughts
The constraints I was against, especially not using plugins, made the multilingual task more complex. Jekyll can be sometimes silent about what's happening. For instance, at some point, I had two pages with the same permalink and the changes I was making would not show up.
CMS-wise, working with CloudCannon was super fun & straightforward!
This tutorial took me definitely more time than I expected (~1 day). To be fair, it was also my first one! I hope I explained enough stuff so that you don't get stuck on all the details I had to account for in building the demo. ;)
Happy coding!
If you've enjoyed this post, please take a second to share it on Twitter. Comments, questions? Hit the section below! | https://snipcart.com/blog/cms-jekyll-cloud-cannon-multilingual | CC-MAIN-2020-05 | refinedweb | 2,241 | 65.42 |
Hi Brett, Here are some comments on your proposal. Sorry this took so long. I apologize if any of these comments are out of date (but also look forward to your answers to some of the questions, as they'll help me understand some more of the details of your proposal). Thanks! > Introduction > /////////////////////////////////////// [...] > Throughout this document several terms are going to be used. A > "sandboxed interpreter" is one where the built-in namespace is not the > same as that of an interpreter whose built-ins were unaltered, which > is called an "unprotected interpreter". Is this a definition or an implementation choice? As in, are you defining "sandboxed" to mean "with altered built-ins" or just "restricted in some way", and does the above mean to imply that altering the built-ins is what triggers other kinds of restrictions (as it did in Python's old restricted execution mode)? > A "bare interpreter" is one where the built-in namespace has been > stripped down the bare minimum needed to run any form of basic Python > program. This means that all atomic types (i.e., syntactically > supported types), ``object``, and the exceptions provided by the > ``exceptions`` module are considered in the built-in namespace. There > have also been no imports executed in the interpreter. Is a "bare interpreter" just one example of a sandboxed interpreter, or are all sandboxed interpreters in your design initially bare (i.e. "sandboxed" = "bare" + zero or more granted authorities)? > The "security domain" is the boundary at which security is cared > about. For this dicussion, it is the interpreter. It might be clearer to say (if i understand correctly) "Each interpreter is a separate security domain." Many interpreters can run within a single operating system process, right? Could you say a bit about what sort of concurrency model you have in mind? How would this interact (if at all) with use of the existing threading functionality? > The "powerbox" is the thing that possesses the ultimate power in the > system. In our case it is the Python process. This could also be the application process, right? > Rationale > /////////////////////////////////////// [...] > For instance, think of an application that supports a plug-in system > with Python as the language used for writing plug-ins. You do not > want to have to examine every plug-in you download to make sure that > it does not alter your filesystem if you can help it. With a proper > security model and implementation in place this hinderance of having > to examine all code you execute should be alleviated. I'm glad to have this use case set out early in the document, so the reader can keep it in mind as an example while reading about the model. > Approaches to Security > /////////////////////////////////////// > > There are essentially two types of security: who-I-am > (permissions-based) security and what-I-have (authority-based) > security. As Mark Miller mentioned in another message, your descriptions of "who-I-am" security and "what-I-have" security make sense, but they don't correspond to "permission" vs. "authority". They correspond to "identity-based" vs. "authority-based" security. > Difficulties in Python for Object-Capabilities > ////////////////////////////////////////////// [...] > Three key requirements for providing a proper perimeter defence is > private namespaces, immutable shared state across domains, and > unforgeable references. Nice summary. > Problem of No Private Namespace > =============================== [...] > The Python language has no such thing as a private namespace. Don't local scopes count as private namespaces? It seems clear that they aren't designed with the intention of being exposed, unlike other namespaces in Python. > It also makes providing security at the object level using > object-capabilities non-existent in pure Python code. I don't think this is necessarily the case. No Python code i've ever seen expects to be able to invade the local scopes of other functions, so you could use them as private namespaces. There are two ways i've seen to invade local scopes: (a) Use gc.get_referents to get back from a cell object to its contents. (b) Compare the cell object to another cell object, thereby causing __eq__ to be invoked to compare the contents of the cells. So you could protect local scopes by prohibiting these or by simply turning off access to func_closure. It's clear that hardly any code depends on these introspection featuresl, so it would be reasonble to turn them off in a sandboxed interpreter. (It seems you would have to turn off some introspection features anyway in order to have reliable import guards.) > Problem of Mutable Shared State > =============================== [...] > Regardless, sharing of state that can be influenced by another > interpreter is not safe for object-capabilities. Yup. > Threat Model > /////////////////////////////////////// Good to see this specified here. I like the way you've broken this down. > * An interpreter cannot gain abilties the Python process possesses > without explicitly being given those abilities. It would be good to enumerate which abilities you're referring to in this item. For example, a bare interpreter should be able to allocate memory and call most of the built-in functions, but should not be able to open network connections. > * An interpreter cannot influence another interpreter directly at the > Python level without explicitly allowing it. You mean, without some other entity explicitly allowing it, right? What would that other entity be -- presumably the interpreter that spawned both of these sub-interpreters? > * An interpreter cannot use operating system resources without being > explicitly given those resources. Okay. > * A bare Python interpreter is always trusted. What does "trusted" mean in the above? > * Python bytecode is always distrusted. > * Pure Python source code is always safe on its own. It would be helpful to clarify "safe" here. I assume by "safe" you mean that the Python source code can express whatever it wants, including potentially dangerous activities, but when run in a bare or sandboxed interpreter it cannot have harmful effects. But then in what sense does the "safety" have to do with the Python source code rather than the restrictions on the interpreter? Would it be correct to say: + We want to guarantee that Python source code cannot violate the restrictions in a restricted or bare interpreter. + We do not prevent arbitrary Python bytecode from violating these restrictions, and assume that it can. > + Malicious abilities are derived from C extension modules, > built-in modules, and unsafe types implemented in C, not from > pure Python source. By "malicious" do you just mean "anything that isn't accessible to a bare interpreter"? > * A sub-interpreter started by another interpreter does not inherit > any state. Do you envision a tree of interpreters and sub-interpreters? Can the levels of spawning get arbitrarily deep? If i am visualizing your model correctly, maybe it would be useful to introduce the term "parent", where each interpreter has as its parent either the Python process or another interpreter. Then you could say that each interpreter acquires authority only by explicit granting from its parent. Then i have another question: can an interpreter acquire authorities only when it is started, or can it acquire them while it is running, and how? > Implementation > /////////////////////////////////////// > > Guiding Principles > ======================== > > To begin, the Python process garners all power as the powerbox. It is > up to the process to initially hand out access to resources and > abilities to interpreters. This might take the form of an interpreter > with all abilities granted (i.e., a standard interpreter as launched > when you execute Python), which then creates sub-interpreters with > sandboxed abilities. Another alternative is only creating > interpreters with sandboxed abilities (i.e., Python being embedded in > an application that only uses sandboxed interpreters). This sounds like part of your design to me. It might help to have this earlier in the document (maybe even with an example diagram of a tree of interpreters). > All security measures should never have to ask who an interpreter is. > This means that what abilities an interpreter has should not be stored > at the interpreter level when the security can use a proxy to protect > a resource. This means that while supporting a memory cap can > have a per-interpreter setting that is checked (because access to the > operating system's memory allocator is not supported at the program > level), protecting files and imports should not such a per-interpreter > protection at such a low level (because those can have extension > module proxies to provide the security). It might be good to declare two categories of resources -- those protected by object hiding and those protected by a per-interpreter setting -- and make lists. > Backwards-compatibility will not be a hindrance upon the design or > implementation of the security model. Because the security model will > inherently remove resources and abilities that existing code expects, > it is not reasonable to expect existing code to work in a sandboxed > interpreter. You might qualify the last statement a bit. For example, a Python implementation of a pure algorithm (e.g. string processing, data compression, etc.) would still work in a sandboxed interpreter. > Keeping Python "pythonic" is required for all design decisions. As Lawrence Oluyede also mentioned, it would be helpful to say a little more about what "pythonic" means. > Restricting what is in the built-in namespace and the safe-guarding > the interpreter (which includes safe-guarding the built-in types) is > where security will come from. Sounds good. > Abilities of a Standard Sandboxed Interpreter > ============================================= > [...] > * You cannot open any files directly. > * Importation > + You can import any pure Python module. > + You cannot import any Python bytecode module. > + You cannot import any C extension module. > + You cannot import any built-in module. > * You cannot find out any information about the operating system you > are running on. > * Only safe built-ins are provided. This looks reasonable. This is probably a good place to itemize exactly which built-ins are considered safe. > Imports > ------- > > A proxy for protecting imports will be provided. This is done by > setting the ``__import__()`` function in the built-in namespace of the > sandboxed interpreter to a proxied version of the function. > > The planned proxy will take in a passed-in function to use for the > import and a whitelist of C extension modules and built-in modules to > allow importation of. Presumably these are passed in to the proxy's constructor. > If an import would lead to loading an extension > or built-in module, it is checked against the whitelist and allowed > to be imported based on that list. All .pyc and .pyo file will not > be imported. All .py files will be imported. I'm unclear about this. Is the whitelist a list of module names only, or of filenames with extensions? Does the normal path-searching process take place or can it be restricted in some way? Would it simplify the security analysis to have the whitelist be a dictionary that maps module names to absolute pathnames? If both the .py and .pyc are present, the normal import would find the .pyc file; would the import proxy reject such an import or ignore it and recompile the .py instead? > It must be warned that importing any C extension module is dangerous. Right. > Implementing Import in Python > +++++++++++++++++++++++++++++ > > To help facilitate in the exposure of more of what importation > requires (and thus make implementing a proxy easier), the import > machinery should be rewritten in Python. This seems like a good idea. Can you identify which minimum essential pieces of the import machinery have to be written in C? > Sanitizing Built-In Types > ------------------------- [...] > Constructors > ++++++++++++ > > Almost all of Python's built-in types > contain a constructor that allows code to create a new instance of a > type as long as you have the type itself. Unfortunately this does not > work in an object-capabilities system without either providing a proxy > to the constructor or just turning it off. The existence of the constructor isn't (by itself) the problem. The problem is that both of the following are true: (a) From any object you can get its type object. (b) Using any type object you can construct a new instance. So, you can control this either by hiding the type object, separating the constructor from the type, or disabling the constructor. > Types whose constructors are considered dangerous are: > > * ``file`` > + Will definitely use the ``open()`` built-in. > * code objects > * XXX sockets? > * XXX type? > * XXX Looks good so far. Not sure i see what's dangerous about 'type'. > Filesystem Information > ++++++++++++++++++++++ > > When running code in a sandboxed interpreter, POLA suggests that you > do not want to expose information about your environment on top of > protecting its use. This means that filesystem paths typically should > not be exposed. Unfortunately, Python exposes file paths all over the > place: > > * Modules > + ``__file__`` attribute > * Code objects > + ``co_filename`` attribute > * Packages > + ``__path__`` attribute > * XXX > > XXX how to expose safely? It seems that in most cases, a single Python object is associated with a single pathname. If that's true in general, one solution would be to provide an introspection function named 'getpath' or something similar that would get the path associated with any object. This function might go in a module containing all the introspection functions, so imports of that module could be easily restricted. > Mutable Shared State > ++++++++++++++++++++ > > Because built-in types are shared between interpreters, they cannot > expose any mutable shared state. Unfortunately, as it stands, some > do. Below is a list of types that share some form of dangerous state, > how they share it, and how to fix the problem: > > * ``object`` > + ``__subclasses__()`` function > - Remove the function; never seen used in real-world code. > * XXX Okay, more to work out here. :) > Perimeter Defences Between a Created Interpreter and Its Creator > ---------------------------------------------------------------- > > The plan is to allow interpreters to instantiate sandboxed > interpreters safely. By using the creating interpreter's abilities to > provide abilities to the created interpreter, you make sure there is > no escalation in abilities. Good. > * ``__del__`` created in sandboxed interpreter but object is cleaned > up in unprotected interpreter. How do you envision the launching of a sandboxed interpreter to look? Could you sketch out some rough code examples? Were you thinking of something like: sys.spawn(code, dict) code: a string containing Python source code dict: the global namespace in which to run the code If you allow the parent interpreter to pass mutable objects into the child interpreter, then the parent and child can already communicate via the object, so '__del__' is a moot issue. Do you want to prevent all communication between parent and child? It's not obvious to me why that would be necessary. > * Using frames to walk the frame stack back to another interpreter. Could you just disable introspection of the frame stack? > Making the ``sys`` Module Safe > ------------------------------ [...] > This means that the ``sys`` module needs to have its safe information > separated out from the unsafe settings. Yes. > XXX separate modules, ``sys.settings`` and ``sys.info``, or strip > ``sys`` to settings and put info somewhere else? Or provide a method > that will create a faked sys module that has the safe values copied > into it? I think the last suggestion above would lead to confusion. The two groups should have two distinct names and it should be clear which attribute goes with which group. > Protecting I/O > ++++++++++++++ > > The ``print`` keyword and the built-ins ``raw_input()`` and > ``input()`` use the values stored in ``sys.stdout`` and ``sys.stdin``. > By exposing these attributes to the creating interpreter, one can set > them to safe objects, such as instances of ``StringIO``. Sounds good. > Safe Networking > --------------- > > XXX proxy on socket module, modify open() to be the constructor, etc. Lots more to think about here. :) > Protecting Memory Usage > ----------------------- > > To protect memory, low-level hooks into the memory allocator for > Python is needed. By hooking into the C API for memory allocation and > deallocation a very rough running count of used memory can kept. This > can be used to prevent sandboxed interpreters from using so much > memory that it impacts the overall performance of the system. Preventing denial-of-service is in general quite difficult, but i applaud the attempt. I agree with your decision to separate this work from the rest of the security model. -- ?!ng | https://mail.python.org/pipermail/python-dev/2006-September/068673.html | CC-MAIN-2017-30 | refinedweb | 2,666 | 56.15 |
I don't want to use the space for the first or last page.
Yes make it optional!!
If you click 10
< 1 2 3 4 5 6 7 8 9 10 >
(numPagesToShowBefore: 0, numPagesToShowAfter: 9, numPagesToShow: 10,)
you get:
< 5 6 7 8 9 10 11 12 13 14 >
(numPagesToShowBefore: 5, numPagesToShowAfter: 4, numPagesToShow: 10,)
If you click 13:
< 8 9 10 11 12 13 14 15 16 17>
(numPagesToShowBefore: 5, numPagesToShowAfter: 4, numPagesToShow: 10,)
If you click 8:
< 3 4 5 6 7 8 9 10 11 12 >
(numPagesToShowBefore: 5, numPagesToShowAfter: 4, numPagesToShow: 10,)
If you click 3:
< 1 2 3 4 5 6 7 8 9 10>
(numPagesToShowBefore: 2, numPagesToShowAfter: 7, numPagesToShow: 10,)
Perhaps:
midPos = int(numPagesToShow / 2)
if currentPage - midPod < 1
numPagesToShowBefore = currentPage - 1
else
numPagesToShowBefore = midPos
numPagesToShowAfter = numPagesToShow - numPagesToShowBefore - 1
To fix I think adding if (this.isValidPage to res.push(currentPage); and // add first and last page will fix this.
if (this.isValidPage
res.push(currentPage);
// add first and last page
If you showFL we can add res.push(after+1);
res.push(after+1);
// add first page if not already there
if (res[0] !== 1) {
res = [1].concat(res);
} else {
if (this.isValidPage(after + 1)) {
res.push(after + 1);
}
}
but perhaps it is better to change the before and after earlier??
before
after
Will respond with coherent thoughts soon
Just uploaded my fixed test version:
for the fix I tried:
if (!this.isValidPage(currentPage)) {
this.send('pageClicked', totalPages);
}
But I don't understand calling an action on a component yet ;-(
I think it is better to change the before and after earlier:
I came across this recent blogpost about pagination, might be useful:
Thanks for the link. I think Mike is building pagination the right way though
Appreciated! Thanks @broerse
How can I keep my itemcontroller's functionality with pagedArray()?
pagedArray()
Previously I had
import Ember from 'ember';
export default Ember.ArrayController.extend({
itemController: 'user',
});
Which worked fine. Now that my templates use
{{#each user in pagedContent}}
My itemcontrollers don't work anymore
{{#if user.hasRoles}}
How do I hook these up?
EDIT: Since it seems the future of Ember is 'no-controllers', I moved the code from my ArrayController to a fresh Component. This works really well by the way! Thanks for the awesome plugin!
can you provide source code for this?
Not sure whet source code you like to see. Perhaps this ?:
thanks, i wanted the code for broerse one.
i'm having problem with using pagination on my project which uses firebase to store the data,so i wanted to see some examples on how its done. BTW i'm a newbie
Sorry I use ember-pouch everywhere so I don't know much about firebase. You can take a look at :
Oh, no problem bro.I'll look into this.Thanks for replying. | https://discuss.emberjs.com/t/new-addon-ember-cli-pagination-looking-to-help-people-get-setup/6283?page=4 | CC-MAIN-2017-17 | refinedweb | 474 | 73.68 |
One of the conveniences offered by Red Hat 3scale API Management is simplified load balancing on API gateways. This article shows how to use a route on Red Hat OpenShift and 3scale API Management to load balance two API gateways installed on an OpenShift instance.
Figure 1 shows the architecture used in this article. This setup is only one of several ways to deploy API gateways. Examples of setups that are not discussed in this article include the following:
- Deploy API gateways inside your corporate network closer to your API, and place a load balancer (registered with 3scale API Management) in your demilitarized zone (DMZ) to handle load balancing, allowing high performance and avoiding a single point of failure. This architecture hides your API gateway from the outside world.
- Install the API gateways via Docker containers along with a load balancer that forwards requests to the Docker containers.
- Use Kubernetes scaling in OpenShift to run the desired number of API gateway pods and have OpenShift’s route feature take care of load balancing.
Prerequisites
Before starting the procedure in this article, you need to:
- Set up 3scale API Management on either SaaS or Red Hat OpenShift.
- Create a back-end product for the default staging and production API gateways.
- Set up a project (namespace) on OpenShift where you'll install the 3scale API gateway operator.
In my configuration, I used the SaaS version for 3scale API Management with an Echo API.
Set up the load balancer
The rest of this article sets up load balancing by taking you through the following steps:
- Install the 3scale APIcast gateway operator.
- Deploy one instance of a self-managed API gateway.
- Deploy a second instance of a self-managed API gateway.
- Configure an OpenShift route for the load balancer.
- Configure a 3scale API Management product using the load balancer route's URL.
- Promote your product API to use the load balancer route's URL in the staging API gateway.
- Test the API.
The following video also walks through the steps. As it shows, the whole process can take less than ten minutes.
Step 1: Install the 3scale APIcast gateway operator
From the OpenShift Operator console, install the Red Hat Integration - 3scale APIcast gateway operator (Figure 2).
Step 2: Deploy one instance of a self-managed API gateway
The "Deploying an APIcast gateway self-managed solution using the operator" section of the 3scale API Management documentation describes this step in detail.
Step 3: Deploy a second instance of a self-managed API gateway
The procedure is just like installing the first instance, except that you should use a different secret. In other words, the secret shown in the following configuration parameter must be different in the two instances:
spec: adminPortalCredentialsRef: name: SOME_SECRET_NAME
The second instance of a self-managed API gateway in the same project (namespace) involves a slight change in how the secret is created.
At this point, you should see the two API gateways in the console (Figure 3).
There are also two pods running, one for each API gateway (Figure 4).
Step 4: Configure an OpenShift route for the load balancer
There are many ways to configure a load balancer. This section uses the OpenShift route to split traffic between services.
Figure 5 shows the services for the API gateways you created previously.
3scalegatewayproject.
While creating the route, configure the two services with equal service weight (Figure 6).
Step 5: Configure a 3scale API Management product using the load balancer route's URL
Go to 3scale API Management → Products → <Product Name> → Integration → Settings. Copy the route URL from Step 4 and set the Staging Public Base URL and Production Public Base URL in 3scale API Management (Figure 7).
Step 6: Promote your product API to use the load balancer route's URL in the staging API gateway
Go to 3scale API Management → Products → <Product Name> → Integration → Configuration and promote the Staging APIcast configuration (Figure 8).
Step 7: Test the API
The APIcast Configuration page shown in Figure 8 contains a cURL command that you can use to test the service. Repeat it to fire up a few requests. You should then see requests sent to both API gateways in a round-robin fashion. Figure 9 highlights the parts of the output that show how both API gateways are responding.
Conclusion
3scale API Management supports multiple deployment strategies with API gateways. For more information, see the following links: | https://developers.redhat.com/articles/2021/08/11/simplify-load-balancing-api-gateways-using-red-hat-3scale-api-management | CC-MAIN-2021-49 | refinedweb | 735 | 53.21 |
The unchecked keyword is used to suppress overflow-checking for integral-type arithmetic operations and conversions.
In an unchecked context, if an expression produces a value that is outside the range of the destination type, the result is truncated. For example:
unchecked
{
int val = 2147483647 * 2;
}:
public int UncheckedAdd(int a, int b)
{
return unchecked(a + b);
}
This sample shows how to use the unchecked statement, using unchecked with constant expressions.
// statements_unchecked.cs
using System;
class TestClass
{
const int x = 2147483647; // Max int
const int y = 2;
static void Main()
{
int z;
unchecked
{
z = x * y;
}
Console.WriteLine("Unchecked output value: {0}", z);
}
}
Unchecked output value: -2
For more information, see the following sections in the C# Language Specification:
5.3.3.2 Block statements, checked, and unchecked statements
7.5.12 The checked and unchecked operators
8.11 The checked and unchecked statements | http://msdn.microsoft.com/en-us/library/a569z7k8(VS.80).aspx | crawl-002 | refinedweb | 144 | 63.29 |
Disclaimer: If you already know Python really well, this post might not be handy for you. However, I’d still love to see your comments and feedback if you have a moment to reply.
Much of my recent work has centered on OpenStack and I’ve found myself overwhelmed by learning Python. Although I don’t have any formal education on anything related to computer science or programming, I’ve worked my way through PHP, Perl and Ruby.
Ruby seems to be the most comfortable language for me to use due to the simplicity of the syntax and the handy features provided by the standard libraries and common gems. Python always caught me as strange due to the forced indenting (I indent my code properly anyway, but it still feels weird to be forced to do so), module namespaces and the overall syntax. Things like list and generator comprehension made my head spin and I avoided Python like the plague.
All of that had to change over the past few months. I’m not an expert in Python by any means but I’ll be glad to share with you how I trekked from the depths of Ruby to the edge of Python.
Zed Shaw’s guide to learning Python has been the primary recommendation from every Python developer I’ve polled at Rackspace. It is clear, concise and accurate; however, I never did finish the HTML guide. Something would end up distracting me or I’d become discouraged by something I couldn’t understand.
That’s when I found the video course on Udemy. The video course costs $29 and comes with the PDF copy of the book. You can watch Zed work through the problems on screen via an easy-to-follow screencast. He even makes common errors on screen and runs the interpreter so you can get familiar with exceptions from common typos.
If it’s in Python or the standard libraries bundled along with it, it’s in the Python documentation. There are plenty of code examples for almost all of the methods from the standard libraries on the site. It’s a good resource to bookmark while you’re learning what certain methods do and which parameters they expect. You can also ensure that your code isn’t importing modules that are deprecated.
This could draw criticism from some, but Stack Overflow is a good resource to find better ways to do things in Python. I’ve written some pretty ugly Python code only to find that I could have called a couple of methods from modules found in Python’s standard libraries. You can find lots of examples of code simplification and recommendations for which modules to use for a particular project.
Keep in mind that some suggestions on the site can be subpar. Some may contain deprecated or insecure code that could hurt your project’s success. Be sure to look through the comments after each answer to ensure that you’re reading a solid solution.
Some of the best resources for learning Python are probably all around you in your office or online. I’m extremely fortunate to be surrounded by gifted and experienced developers at Rackspace who genuinely care about their work and want to share their strategies with others. I’ve always had a tough time understanding lambdas (I couldn’t understand them in Ruby, either), but one of my coworkers took me through some examples as I was leaving work.
If you feel like you might be a bother to your coworkers, try to do some homework on the topic first or give them a specific example of what you’re trying to solve. It will show them that you’ve done your best to understand the topic but that you need some help getting over the hump. A hot cup of their favorite coffee or snack doesn’t hurt either.
Find a problem, make a project and write some Python. Most of us have something we’d like to accomplish if we had the time. Take that idea or problem and write Python to solve it. You’ll pick up new knowledge as you work through the project and you’ll probably back yourself into a corner more than once. When it happens, go back to the documentation, do some Googling and lean on your peers.
I’ve been working with Python for just over a month and these strategies have jump started my learning by leaps and bounds. If you’re struggling, drop me a line and I’ll see what I can do to help. I’m also eager to hear your strategies for learning Python so they can be shared with others. | http://www.rackspace.com/blog/how-i-started-learning-python/ | CC-MAIN-2014-10 | refinedweb | 787 | 69.31 |
Type: Posts; User: logan
In addition to what Edders said, there are numerous codecs out there like G.711, GSM, G.729, iLBC, Speex, etc. And you would need to know and understand all of them.
Hi All,
I want to do a simple ActiveX control, which will basically be a wrapper over a C++ VoIP library/application. The intent is to embed the softphone in a browser so that the application...
#include <iostream>
#include <string>
using namespace std;
int dan ();
int main()
{
//Let's call our function
Use the two pointer approach.
Rough code:
bool ContainsLoop (Node *pNode)
{
Node *pSlowptr = pNode;
Node *pFastptr = pNode->pNext;
Thanks a lot for the replies :). Things are clearer now.
Yes, I understand that it can help avoid the extra code in the release build. All you said makes sense.
So, does the author mean to say that whenever your application asserts then it's a bug and...
Hi,
Steve Maguire in Writing Solid Code mentions how his re-write of an old library, which previously had no assertions, caused so many assertion errors in the code that now used the new library....
Hmmmm, I can't rate. But, thanks a lot Sir!
1) Ok, thanks :).
2) SVN did exactly what I wanted.
Can Visual SourceSafe do what I want?
Hi Guys,
What access level (private, public, protected) should be given to the different message handlers in my application? I generally declare all the variables for the controls as private, but...
Thanks a lot. That does what I need.
Ofcourse, I know that. And, I update my controls by sending a message to the window that created them. But, the question over here is, from an another thread how I get the items selected in the list...
Thanks for the response first of all.
Yes, the property page is created by the main thread. The reason I'm worried about thread safety issues is that I make updates to the list control from a...
Hi Guys,
I have a property page which has a list control on it. I need to know the number of items in the list control and read the text of the items from my main dialog box, so how can I do this...
Thanks, I will now fix it. Between, I'm not able to find your article on Multiton, can please give the link?
Thanks for the reply.
Are there any other ways to make the application thread safe? Or the only way is to send user defined messages to the property page, and ask it to update the list control?
...
CString strValue;
for (int i = 0; i < m_cmbValues.GetCount (); ++i)
{
m_cmbValues.GetLBText (i, strValue);
if (!strValue.CompareNoCase (_T("1")))
{
m_cmbValues.SetCurSel (i);...
Sorry, but your header and implementation files are not correct. On a sidenote, don't be afraid of errors, we all get them.
I have a dialog based application that has two property pages over it. The property page has a list control, basically the app is a softphone and the list control shows the active calls and it's...
Guys, thank you for the responses [:)].
Another thing that you may do is to remove the Accelerator associated with Ctrl + C in your project.
class Foo
{
int data;
public:
Foo (int n):data (n)
{
}
Foo ():data (0)
The errors show that you have not linked with the library.
Right click on the solution->Properties->Linker, in Additional Dependencies enter the name of the library.
Set the Read Only property of the edit box to be TRUE. The DDX/DDV routines work fine even if the edit box is read only.
You can do it this way as well:
CString strText;
GetDlgItem... | http://forums.codeguru.com/search.php?s=25e556ab71a7ff0d3458587aaca58f99&searchid=6639621 | CC-MAIN-2015-14 | refinedweb | 616 | 76.32 |
In today's JavaScript ecosystem, one of the most prevalent barriers to entry appears to be the amount of tooling required to bootstrap a web site or application: we live in an era of transpilers, bundlers and build tools that often need to be understood and tinkered with in order to create rich web experiences..
HyperScript Tagged Markup
HTM (HyperScript Tagged Markup) is a library by Jason Miller that is extremely fast, lightweight and makes use of native JavaScript features — turning the need for compiling your templates away into a very small optimization.
The name HTM contains a reference to HyperScript: a library that enables creating hypertext markup using JavaScript. It exports a single function, whose signature describes the markup to be generated.
h(tag, props, ...children)
HyperScript function signature
If the above function signature looks familiar, it is because it is familiar: it is identical to
React.createElement, which is included in the transpiled output of React JSX.
HTM comes with a number of benefits. Namely,
Small footprint
Since HTM is around 700 bytes, it does not have a significant impact on the size of a compiled bundle. For those interested, we have previously posted such metrics in our related post about serverless SSR.
HTM compiles away, leaving no footprint
Moreover, in some cases, HTM completely disappears after compilation. This means that our λs can be lighter and have smaller requirements, ultimately leading to more affordable, sustainable, and scalable deployments.
Framework agnostic
HTM simply transforms tagged template literals from pure, vanilla JavaScript into a HyperScript-style invocation. It can be bound to any function implementing the HyperScript signature: including
React.createElement, and
hfrom Preact or Vue.
import htm from 'htm' import { createElement } from 'react' // or import { h } from 'preact' // or anything else const html = htm.bind(createElement /* or any hyperscript-style function */) const MyComponent = props => html\` <div>Your name is \${props.name}</div> \`
A sample component implemented with HTM
This makes HTM truly framework agnostic and flexible, allowing components to be described one way, and passed to varying UI renderers.
JavaScript Module Ready
HTM does not require a module bundler, but instead is a JavaScript module. JavaScript modules are relatively new and supported in all major browsers. This allows HTM to be included via a
<script>tag in a browser, further simplifying the development process.
ES Module support landed in all major browsers in May
An example
Given the quick adoption path of HTM, we threw together a Lambda λ that retrieves news from HackerNews using Algolia's search API, and then renders its data using HTM and
vhtml.
HTM λ News: Powered by HTM and Now
The result is a simple web page that looks and feels as though it was written with JSX and then magically transpiled to plain JavaScript, but in actuality, it is a series of simple vanilla JavaScript functions.
const h = require('vhtml') const html = require('htm').bind(h) const getNews = require('./get-news') module.exports = async (req, res) => { const news = await getNews() const NewsLink = props => html\` <li> \${props.title} (<a target="_blank" rel="noopener" href="\${props.url}">link</a>) </li> \` res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' }) res.end(html\` <html> <head> <link href="" rel="stylesheet" /> </head> <body> <div> <h1>HTM λ News</h1> \${news.map(n => html\`<\${NewsLink}\`)} </div> </body> </html> \`) }
The entire HTM News Lambda λ implementation
Conclusion
HTM does a great service to making UI development far more accessible, just as Now serves to make serverless cloud computing accessible to all. When HTM's tiny footprint and simplicity is considered together with Now's pay for what you use model, it makes web and cloud development far more approachable. We are excited to see the great things that our developer communities will build together in the near future. | https://zeit.co/blog/seamless-serverless-markup-htm | CC-MAIN-2019-39 | refinedweb | 631 | 52.8 |
I am trying to install aspell for Python 3 (on MacOS X 10.11), and have encountered an issue (the same one) using both pip and the manual installer (by cloning the git repo). I have already installed aspell using MacPorts (sudo port install aspell) as well as the english dictionary (sudo port install aspell-dict-en).
The error is obvious (aspell.h cannot be found), however I have no idea how to fix it.
Any help would be greatly appreciated.
$ sudo python3 setup.3.py build
running build
running build_ext
building 'aspell' extension
/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Os -I/opt/local/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c aspell.c -o build/temp.macosx-10.11-x86_64-3.5/aspell.o
aspell.c:53:10: fatal error: 'aspell.h' file not found
#include <aspell.h>
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
Asked the same question on the project's GitHub page. Original can be found here. Copied here for convenience.
In case anybody encounters the same issue, I had installed aspell using MacPorts (sudo port install aspell) and had to include the dir '/opt/local/include', which is where the header file for aspell (aspell.h) was located. Hence, my setup.3.py looks like this:
module = Extension('aspell', libraries = ['aspell'], library_dirs = ['/usr/local/lib/'], include_dirs = ['/opt/local/include'], sources = ['aspell.c'] ) | https://codedump.io/share/Wa5UgvIV8M2x/1/installing-aspell-for-python-3-on-macos-x | CC-MAIN-2016-44 | refinedweb | 251 | 53.07 |
Prototype: Easing AJAX's Pain
April 5, 2006.
Why Prototype?
Why didn't I just create a plain old JavaScript object (POJO) for my application,
instead
of introducing an open source library? For one, Prototype includes a nifty collection
of
JavaScript shortcuts that reduce typing and help avoid the reinvention of the wheel.
The
commonly touted shortcut is
$("mydiv"), which is a Prototype function that
returns a Document Object Model (DOM) Element associated with the HTML tag with
id "mydiv". That sort of concision alone is probably worth the cost of
setting up Prototype. It's the equivalent of:
document.getElementById("mydiv");
Another useful Prototype shortcut is
$F("mySelect"), for returning the value
of an HTML form element on a web page, such as a selection list. Once you get used
to
Prototype's austere, Perlish syntax, you will use these shortcuts all the time. Prototype
also contains numerous custom objects, methods, and extensions to built-in JavaScript
objects, such as the
Enumeration and
Hash objects (which I discuss
below).
Finally, Prototype also wraps the functionality of
XMLHttpRequest with its own
Ajax.Request and related objects, so that you don't have to bother with
writing code for instantiating this object for various browsers.
Setting Up
So how do you set up Prototype? First, download it from prototype.conio.net. Prototype is open source and
available under an MIT-style
license. The download includes a file named prototype.js. This is a
JavaScript file that defines the various functions and objects your application will
use.
Add the prototype.js file to your application by using a
script tag in
the HTML code.
<head>... <script src="js/prototype.js" type="text/javascript"> </script> <script src="js/co2.js" type="text/javascript"> </script> <script src="js/eevpapp.js" type="text/javascript"> </script>... </head>
The same directory that holds this application's HTML file contains a directory named js. This js directory contains prototype.js, an object definition in the file co2.js, which this article describes, as well as the rest of the application's client-side code in another file: eevapp.js.
Since the application imports the Prototype file, the JavaScript code in the other
imported
.js files can use Prototype's objects and extensions as if they were declared and
defined locally. JavaScript does not require statements such as
import or
require to use objects from other JavaScript files that the browser commonly
imports.
Climate Change
How is Prototype going to help with our application's requirements? What are the requirements?
The User Interface is a web browser, such as Safari 1.3, Firefox 1.5, Opera 8.5, or Internet Explorer 6. The application is designed to display a small data set of annual atmospheric carbon dioxide (CO2) levels. This is a number, like 377, that represents the parts-per-million CO2 level in the air for a specific year. I decided to store these years and numbers in a JavaScript object that the browser downloads with the application. It is not necessary to use a database to store this data, which is small in size and needs neither security nor authentication. The data is designed for consumption by the interested public. The application does, however, give this JavaScript object the ability to add new data on the fly when necessary.
CO2 Applet
Figure 1-1 shows the browser screen for the application. In the upper left corner is an applet that displays the CO2 level in the atmosphere when the user chooses a year.
This data is derived from the Mauna Loa Observatory, run by the U.S. government in Hawaii. The measurements are taken at high altitude in pristine conditions. Scientists throughout the world use the data in their climate-change research.
There are only 46 different annual levels, associated with the years 1959-2004 (the 2005 level is not available at this time). Therefore, it makes sense to store this information in a JavaScript object. Even if we choose to display the monthly levels associated with those years with this tool (over 500 separate numbers), it still might make sense to store the data on the client. No database or extra server hits are required.
Where Prototype Comes In
The eevapp.js file contains the code that executes when the user selects a year in the selection list widget.
//instantiate an object //defined in the co2.js file var co2lev = new CO2Levels(); //the onload event handler executes //when the browser is finished loading the page. window.onload=function(){ $("co2_select").onchange=function(){ $("co2ppm").innerHTML= co2lev.getYear($F("co2_select")); } };
The value
"co2_select" is the
id value of the selection list that
the user clicks to choose a year.
<select id="co2_select" .../>
The code:
$("co2_select")
returns a DOM Element reference, the equivalent of
document.getElementById("co2_select");.
The code sets the
onchange event-handler attribute of the selection list
element to a JavaScript function, as in:
$("co2_select").onchange=function(){...}.
In simpler terms, when the user chooses a year in the
select tag, the browser
executes the defined function. What does this function do? The function gets a reference
to
an HTML
div element with the
id "co2ppm", once again, using
Prototype's shortcut. The
innerHTML property of this
div element,
representing what the user sees in the browser, is set to the return value of a method
call:
co2lev.getYear($F("co2_select"));
The object named
co2lev is instantiated at the top level of the
eevapp.js file.
var co2lev = new CO2Levels();
This object has a method called
getYear(). This method takes a string
representing a year as a parameter, such as
"1999". The method returns the CO2
level associated with that year.
Pithy Syntax
That dollar sign pops up in the syntax again:
$F("co2_select"). The
$F() Prototype function returns the value of an HTML form element, in this
case the selection list, when I pass its
id into the method as a parameter. The
application uses this function to change the displayed CO2 level each time a user
chooses a
different year.
One tip to remember with
$F(): it won't return a value from a selection list
unless the list's child
option elements have
value attributes, as
in:
<option value="1959">1959</option>. In other words, at least
the Prototype version I was using (1.4.0) would not return a value with
$F() if
I left out the
value="..." part.
Objective View
The
CO2Levels object definition appears in a different JavaScript file, aptly
named co2.js. Figure 1-2 shows a UML class diagram describing the object.
Figure 1-2. UML class diagram
Here is the entire code for the
CO2Levels object. The first line instantiates
a new object, using syntax derived from Prototype. The
levels local variable is
an object, like an associative array, that links years with their CO2 levels. I have
omitted
most of the years for the sake of readability.
var CO2Levels=Class.create(); CO2Levels.prototype = { /* Source: Mauna Loa Observatory, Hawaii */ initialize: function(){ this.levels={ "1959":315.98,"1960":316.91, "1961":317.65,"1962":318.45, "2003":375.64,"2004":377.38}; this.levelsHash=$H(this.levels); }, getYear: function(year){ if (! isNaN(year)) { return this.levelsHash[year]; } else { return 377; } }, keys: function(){ return this.levelsHash.keys(); }, values: function(){ return this.levelsHash.values(); }, inspect: function(){ alert( this.levelsHash.inspect()); }, add: function(year,level){ var tmp = new Object(); tmp[year] = level; this.levelsHash=this.levelsHash.merge(tmp); } }
Creating Prototype Objects
Using the
Class.create() method in Prototype returns a JavaScript object that
automatically provides new instances of this object with an
initialize()
method. This is similar to a constructor method, such as in Java. The
initialize() method will be called each time the code creates a new
CO2Levels object. The rest of the code defines the prototype, or blueprint,
for this
CO2Levels object, including the behavior for its
initialize() method. What does
initialize() do? It creates a
local variable called
levels, which refers to an object that holds all of the
data: the CO2 levels associated with their years. The code then converts this object
to a
Prototype
Hash object, to provide more functionality for the object (such as
the ability to view the object contents and dynamically add new data).
this.levelsHash=$H(this.levels);
Prototype
Hash Object
There's that syntax again:
$H(). This function takes a JavaScript object as
its parameter and returns Prototype's
Hash object. Similar to hash table
structures in other languages, the
Hash has an associative array structure,
along with with several methods that are designed to manipulate its data, as well
as add new
data to the
Hash.
For example, the
Hash.keys() method returns an array of all of the
Hash's keys (such as all of the years in our data). The
values()
method returns an array of values (the CO2 levels). The
merge() method adds new
keys and values to the
Hash.
Delegator
Our own
CO2Levels object uses the concept of delegation, wherein calls to its
own
keys(),
values(), and
add() methods delegate the
real work of these operations to the internal
Hash object. This object is
stored as a local variable: levelsHash.
Let's look at the
getYear() method.
getYear: function(year){ if (! isNaN(year)) { return this.levelsHash[year]; } else { return 377; } }
The built-in JavaScript method
isNaN() returns false if its parameter can be
evaluated as a number (such as
"2000"), and true otherwise (as in
isNaN("hello")). If the
getYear() parameter passes this test,
then the code uses a common JavaScript expression to return the value of a key or
property:
this.levelsHash[year] (for example,
this.levelsHash["2004"]
evaluates to 377.38). The browser then displays this numerical value inside the HTML
div element.
Add Stuff to an Existing Hash
The
CO2Levels object has an
add() method, which can add new keys
and values (additional years and CO2 levels) to the existing data.
add: function(year,level){ var tmp = new Object(); tmp[year] = level; this.levelsHash=this.levelsHash.merge(tmp); }
This method creates a new
Object from its two parameters (representing the
year and CO2 level), which might look like:
{"2005":381}
The code then passes this object to the Prototype
Hash object's
merge() method. This method combines the new object with the
Hash's existing data, essentially merging them into one group of data or
associative array.
The
merge() method returns the existing data with the new property/value
pair(s) appended to the end.
With some refactoring, the code could use
XMLHttpRequest to fetch any new
levels from the Mauna Loa Observatory, then add them to our existing client-side data.
Inspect
Finally, Prototype's
Hash object also has an
inspect() method.
This method creates a readable display of the
Hash's contents, as in Figure
1-3.
Figure 1-3. Looking inside a
Hash
The
CO2Levels object delegates the task of its own
inspect()
method to its internal Prototype
Hash object.
inspect: function(){ alert( this.levelsHash.inspect()); }
This is a useful debugging tool for viewing the current contents of a
Hash
object.
An upcoming article discusses an AJAX caching strategy used with the same application.
It
introduces Prototype's
Ajax.Request object, which reduces the amount of code
that has to be devoted to using the
XMLHttpRequest object. This is the
important top-level JavaScript object used in AJAX applications for making HTTP connections
with a server behind the scenes. | http://www.xml.com/pub/a/2006/04/05/prototype-javascript-ajax.html | CC-MAIN-2017-22 | refinedweb | 1,896 | 57.27 |
GETWCHAR(3P) POSIX Programmer's Manual GETWCHAR(3P)
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
getwchar — get a wide character from a stdin stream
#include <wchar.h> wint_t getwchar(void);
The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1‐2008 defers to the ISO C standard. The getwchar() function shall be equivalent to getwc(stdin).
Refer to fgetwc(3p).
Refer to fgetwc(3p). The following sections are informative.
None..
None.
None.
Section 2.5, Standard I/O Streams, fgetwc(3p), getwcWCHAR(3P)
Pages that refer to this page: wchar.h(0p) | http://man7.org/linux/man-pages/man3/getwchar.3p.html | CC-MAIN-2017-22 | refinedweb | 147 | 60.51 |
10
Face Anchors
Written by Chris Language
This chapter continues from the point where the previous one left off. Thanks to SwiftUI, the AR Funny Face app now sports a very basic UI. In this chapter, you’ll continue to focus on that facial recognition component by using face anchors in RealityKit.
You’ll also get to build some funny scenes with these crazy props:
A humongous pair of sunglasses, a glass eyeball and one epic mustache. With these cool props at one’s disposal, the AR Funny Face app is off to a great start.
Note: Feel free to continue with your own final project from the previous chapter. If you skipped a few things, load the starter project from starter/ARFunnyFace/ARFunnyFace.xcodeproj before you continue.
What are face anchors?
Hanging an anchor from one’s face sounds extremely painful. Luckily, the type of anchor we’re referring to here is an AR Face Anchor — undeniably one of the coolest types of anchors available. Thanks to Reality Composer, creating face anchors is super easy.
By using the TrueDepth front-facing camera, face anchors provide information about the user’s facial position, orientation, topology and facial expression.
Unfortunately, you can only use face tracking if you have a device equipped with a TrueDepth front-facing camera. If the device is Face-Id capable, you’re good to go.
When the camera detects a face, an anchor gets added slightly behind the nose in the middle of the head.
Here, the cute monkey head demonstrates how a face anchor is created after a face is detected.
It’s also important to know that the anchor uses a right-handed coordinate system measured in meters.
Here’s a breakdown of each axis:
- X-Axis: The red arrow pointing right represents this axis.
- Y-Axis: The green arrow pointing up represents this axis.
- Z-Axis: The blue arrow pointing forward represents this axis.
Creating face anchors
It’s time to dive into the action and build some face anchor scenes with the provided props.
Creating multiple scenes
To add more props, you have to create multiple scenes within the Reality Composer project. Each scene will house a single facial prop. To switch between the different props, you simply need to switch the different scenes.
Code generation
Reality Composer is tightly integrated into Xcode. When you build the project, Xcode will inspect all the associated Reality files within the project and generate Swift code.
Fixing the project
You’ll look at the coding side of the project next. When you recompile your project, it generates an error.
arView = ARView(frame: .zero) return arView
Switching to the front-facing camera
When the app starts, you need to manually switch to the front-facing camera. To do that, you’ll need a little help from ARKit.
import ARKit
AR session
Before moving on, you need to learn about the AR session, which you can access via
ARView.session.
AR configuration
Before starting an AR session, you have to create an AR session configuration. You use this configuration to establish the connection between the real world, where your device is, and the virtual 3D world, where your virtual content is.
// 1 let arConfiguration = ARFaceTrackingConfiguration() // 2 uiView.session.run(arConfiguration, options:[.resetTracking, .removeExistingAnchors])
Switching between multiple scenes
Finally, you need to switch between the three scenes when the user presses the Previous or Next buttons.
switch(propId) { case 0: // Eyes let arAnchor = try! Experience.loadEyes() uiView.scene.anchors.append(arAnchor) break case 1: // Glasses let arAnchor = try! Experience.loadGlasses() uiView.scene.anchors.append(arAnchor) break case 2: // Mustache let arAnchor = try! Experience.loadMustache() uiView.scene.anchors.append(arAnchor) break default: break }
Testing the app
Finally, you’re ready to do your very first build and run. Before you do, connect your physical device to your machine and select it in Xcode.
Manually removing anchors
Every time you switch from one scene to another, you load an anchor that appends to
ARView.Scene.anchors. If you continue adding multiple anchors, you’ll end up with multiple props stacked on top of each other.
arView.scene.anchors.removeAll()
Key points
Congratulations, you’ve reached the end of this chapter and your AR Funny Face app looks great. Take some selfies of yourself and some friends and try the funny props. | https://www.raywenderlich.com/books/apple-augmented-reality-by-tutorials/v1.0.ea3/chapters/10-face-anchors | CC-MAIN-2021-04 | refinedweb | 721 | 56.45 |
Details
- Type:
Improvement
- Status: Resolved
- Priority:
Minor
- Resolution: Fixed
- Affects Version/s: Nightly Builds
- Fix Version/s: None
- Component/s: None
- Labels:None
- Environment:
Operating System: other
Platform: All
Description
Config files are loaded from the directory of the configuration.xml instead of
the classpath. This prevents using Configuration where projects use other
projects and the configuration files can be anywhere on the classpath,
including inside JAR files.
Activity
- All
- Work Log
- History
- Activity
- Transitions
I didn't realize it was the working dir. That's even worse than I thought.
I spent an hour going through the code and I just can't figure out where it
loads in the config files. I'm willing to make a patch for it if someone can
just point me in the right direction.
-Michael
I think the problem resides in PropertiesConfiguration, there is no mechanism
there to load the file from the classpath. The ConfigurationFactory creates a
new PropertiesConfiguration, sets the filename from the xml file and then call
load() to populate the configuration.
I haven't checked but I guess we have the same issue with XMLConfigurations
ConfigurationFactory provides means to specify a base path or URL from which
configuration files are loaded. Refer to the API doc of the setBasePath()
method. If this method was not called, the location of the configuration factory
XML file is used as base path. Relative URLs specified in the XML file are
resolved using this base path. It is also possible to specify absolute URLs for
the configuration files to load.
Loading configuration files from the class path is not yet supported and I agree
that this is a useful feature. As Emmanuel pointed out loading of the
configuration files is done by instantiating a Configuration object of the right
type and invoking its load() method.
With the actual design I think it won't be easy to implement loading from class
path as an additional and optional feature. For the long run I would suggest a
more sophisticated mechanism for locating configuration files, e.g. a couple of
ConfigurationLocator classes that know how to find a configuration file in the
class path, at a specified URL, in the user's home directory, relative to
another location etc. And I still propose to separate the loading of
configuration objects from the objects itself by introducing a hierarchy of
ConfigurationLoader classes.
Oliver
I came up with a solution for XML files but I can't get it to work for
properties, it breaks the tests. For XML I did this:
public class HierarchicalDOM4JConfiguration ...
/**
- Loads and parses an XML document. The file to be loaded must have
- been specified before.
- @throws Exception if an error occurs
*/
public void load() throws ConfigurationException {
// first try to find file on the classpath
URL url = getClass().getResource("/" + file);
if (url != null) {
File f = new File(url.getFile());
if (f.exists())
} else {
// file is not on the classpath, so use the old
method
try
catch (MalformedURLException mue){ throw new ConfigurationException("Could not load from " + getBasePath() + ", " + getFileName()); }
}
}
and for properties:
public class PropertiesConfiguration ...
protected InputStream getPropertyStream(String resourceName) throws
IOException {
InputStream resource = null;
resource = getClass().getResourceAsStream("/" + extractFileName
(resourceName));
if (resource != null)
URL url = null;
try
/* try */
catch (MalformedURLException uex)
/* catch */
resource = url.openStream();
setBasePath(url.toString());
setIncludesAllowed(true);
return resource;
}
I hope that helps. I think some serious design rethinking needs to take place
to implement this. I really hope this will be come a priority, I don't find it
very useful that all the config files must be located in the same directory as
the configuration.xml. For now we can work around this by copying our config
files and not embedding them in the JARs but I really don't like this approach.
Michael
Is this the right fix until we rethink the configuration location mechanism ?
This change implies that the file in the classpath overwrites the one in the
local path, but someone may be interested in the opposite behaviour, i.e the
local file overwrites the one in the classpath.
How about this:
If the file exists in the same directory as the configuration.xml, it is used.
This satisfies the current behavior and won't break existing apps.
if the file does not exist in the same directory as the configuration.xml, it
is searched on the classpath. To me this is perfectly logical because if the
file doesn't exist in the same dir, this is a "last ditch effort" to find it
before raising an exception and possibly aborting the program.
I really need to find a solution to this because as it is now the only way for
us to use Configuration is to put all our config files in the same directory.
This causes lots of problems for distribution. For example, our common.jar has
properties used only for tests. Those should not be distributed. I'm really
stuck on this.
If I have time I plan to implement this solution before I leave on vacation.
if anyone else has some ideas please let me know.
Michael
Taking the bug, I'm working on a patch.
File based configurations are now loaded from the classpath if the file is not
found in the base directory. Let us know how it works for you Michael.
Actually they are loaded from the working directory and not the location of the
configuration.xml file. I agree that would be nice to be able to load them from
the classpath. | https://issues.apache.org/jira/browse/CONFIGURATION-213 | CC-MAIN-2015-48 | refinedweb | 915 | 56.15 |
On Friday 12 Mar 2004 2:54 am, George Anzinger wrote:> Amit S. Kale wrote:> > On Wednesday 03 Mar 2004 6:38 am, George Anzinger wrote:> >>Amit S. Kale wrote:> >>>OK to checkin.> >>>> >>>-Amit> >>>> >>>On Saturday 28 Feb 2004 3:24 am, Tom Rini wrote:> >>>>Hello. When we use kgdboe, we can't use it until do_basic_setup() is> >>>>done. So we have two options, not allow kgdboe to use the initial> >>>>breakpoint or move debugger_entry() to be past the point where kgdboe> >>>>will be usable. I've opted for the latter, as if an earlier breakpoint> >>>>is needed you can still use serial and throw> >>>>kgdb_schedule_breakpoint/breakpoint where desired.> >>>>> >>>>--- linux-2.6.3-rc4/init/main.c 2004-02-17 09:51:19.000000000 -0700> >>>>+++ linux-2.6.3-rc4-kgdb/init/main.c 2004-02-17 11:33:51.854388988> >>>> -0700 @@ -581,6 +582,7 @@ static int init(void * unused)> >>>>> >>>> smp_init();> >>>> do_basic_setup();> >>>>+ debugger_entry();> >>> >>It would be nice to not need this. Could it be a side effect of> >>configuring the interface or some such so we don't have to patch> >>init/main.c> >> > I attempted doing this when I was trying to code a netpoll independent> > ethernet interface. I couldn't do without it. I needed one hook to kgdb> > in init to mark completion of smp_init. If an interface was ready, that> > hook called breakpoint. A similar hook was placed in interface> > initialization code, it called breakpoint, if kgdb core was ready on> > account of smp_init completion.>> I guess the real question is why do you need to wait so long? What is it> that needs to be done prior to this call?2.4.x kgdb legacy code! That was needed in some early 2.4 kgdbs. Perhaps we can move it earlier now. If someone tests the patch on an smp machine and confirms that it works, I'll be happy change it.The earlier kgdb is initialized, the better it is.-Amit>> On the other hand, I have a late call (I use module init) to set up the> interrupt handler for the UART, which needs to happen after malloc is> working. This, however, does not cause, of it self, a break.>> > -Amit> >> >>-g> >>> >>>> prepare_namespace();> >>>> >>>-> >> | http://lkml.org/lkml/2004/3/11/349 | CC-MAIN-2016-50 | refinedweb | 371 | 76.11 |
Agenda
See also: IRC log
<ArtB> ScribeNick: ArtB
<scribe> Scribe: Art
Date: 18 February 2010
<Cyril_Concolato> right, even on IRC I don't even remember all the commands :(
AB: the agenda was posted yesterday ( ). Are there any change requests?
MC: I would like to talk about ITS
AB: we can add that to the
P&C agenda topic
... any other requests?
[ No ]
AB: does anyone have any short announcements?
AB: we have invited Cyril
Concolato to join us today to discuss ISO's "Study text of
ISO/IEC FCD 23007-1 (MPEG-U)" (
). Thanks for joining us today Cyril!
... Cyril, perhaps you could first give us a short overview of the group working on widget-related specs
CC: I am not talking on behalf of
MPEG
... I am only giving my personal point of view
AB: OK; thanks for that clarification
CC: MPEG-U is an ISO
standard
... it has multiple parts and only Part #1 deals with widgets
... started Oct 2008
... want solutions for widgets using MPEG technology
... e.g. streaming widgets over MPEG-2
... started with a reqs and context setting
... both of those docs are publicly available
... based on those reqs, MPEG made a RfP
... we got some answers to that RfP and started a spec
... we refer to WebApps' P&C spec and to what is nka TWI spec
... We started a liaison at the end of 2009
... it bounced around a bit (got lost)
... so we sent a new liaision
... we have people working on different MPEG specs e.g. audio, video, 3d, formats, scene description, LaSER, etc.
... besides us, Telecom Italia, ETRI, Samsung, Intel (at one point in time)
... we do ref P&C spec
... expect an MPEG UA should be a P&C UA but also will include some extensions
... We understand WebApps is starting charter discussions
... want to collaborate on new work
... there were two points, one technical
... MPEG should split spec to confine some resualbe functions
... the 2nd issue is IPR
... MPEG does not work with Royalty Free by default
... IPR policy allows for RF but that is not the default
... But MPEG is willing to change its widget spec so that is is RF
... need to clarify something in the minutes
<Cyril_Concolato> CC: MPEG is requesting its members to send patent and licensing declaration forms
<Cyril_Concolato> CC: this form allows MPEG members to declare that they are willing to provide the technology with RF terms
AB: thanks for those
clarifications
... any comments about what CC has said so far?
Scribe+ Josh
<scribe> ScribeNick: timeless_mbp
AB: I propose we go section by section, starting with section 1 ...
<darobin> RB: I have
JS: I haven't had time to read the document
MC: I haven't reviewed it yet
AB: I have only glanced at
it
... Robin, any comments on section 1?
CC: Section 1 is the scope, organization
RB: I have questions...
... that would give people a better idea as they review it
... first question: in your overview, it says that this new (?)
... is meant to make it more compatible with existing ...
... to help with widgets
... to make it more compatible with e.g. flash
CC: ok...
... when we had these requirements, we had several cases in mind
... e.g. streaming
... we wanted a configuration file to be able to point to a stream
... we had a requirement that a widget using mpeg technologies should not require the use of scripting languages
... i think that was the main two
... it shouldn't say packaging format and configuration documents
<darobin> "to ensure that the widget packaging format and configuration documents are compatible with the MPEG media types which can be used to describe widgets"
CC: it should say general
requirements
... the idea is. we wanted to investigate and standardize the additional things required to cope with mpeg media types
RB: the packaging and
configuration shouldn't need to be changed
... scripting is not required at all by P&C
... pointing to a stream could be done with a URI
... another thing is "MPEG-U intends to "ensure that it is targeted for additional domains than Web connected devices, e.g. broadcast, mobile or home networking domains."
CC: the document is somehow related to the web, and you require/assume an http connection?
RB: no, no. not at all
CC: we're contemplating home devices without any internet connection
AB: this has been a concept from day one. e.g. exchanging widgets by bluetooth
BS: as i review this spec, it
seems to be coming from Interactive, multimedia application
based
... more similar to OMA (?)
... scene management
... incorporating discrete content and
... cyril: is the goal here to make a profile more intended for incorporating streaming media into widget types of experiences?
CC: yes, I wouldn't say primarily, but one of the goals is to facilitate the use of widgets in streaming environments
BS: what you're talking about here is a packaging format for those types of applications
CC: there are two aspects
... one is widget communications
... the other is widget packaging
... packaging covers streaming or packaging multimedia files in a container
... the other which covers communication is quite different
RB: a few quick points...
... in terms of intrawidget communication
... i think it might be worth it to look at Post Message (?) and web sockets
... i understand those may not fit the exact use cases
<ArtB> +1 on reuse as much of Web Sockets and Post Message as possible
RB: but they do have the value of
being implemented in existing implementations
... and they have security analysis and acceptance
... the other thing that might be worth looking into is Mozilla Weave
... which I've been asking mozilla to push towards standards
... it's certainly something to look at
... that's all i had for section one
AB: anyone else?
<bsulliva> OMA RME specs I mentioned are at
JS: My word processor doesn't like me
AB: comments on references, definitions, abbreviations, or conventions?
RB: references point to an editors draft?
AB: they're definitely out of date
CC: they need to be updated
AB: the more interesting parts of
the document starts in chapter 7
... a composition section, lifecycle
... perhaps some overlap with our update spec
... robin, do you want to comment?
RB: a brief comment on lifecycle,
table 1
... widget events (?)
... it seems that some of that may overlap with ViewModes
... for instance there's a HideShow (?) event, that's when the widget is hidden
... it might be good to reuse the same stuff
... i know that view modes isn't completely specified at this point
... and it wouldn't cover the entire set of events, because we don't have a life cycle at this point
CC: that's a good comment
... i think there is some overlap with View Modes
... one of the use cases we want to address
... is how do you cope with a widget which has two live representations?
... is this something you cover in view modes?
RB: I don't think so
ABe: to clarify something with
view modes
... i don't see the relevance of separate instantiations
... it's not about synchronizations of views
RB: that's why i said there was
some overlap, but not complete overlap
... something with shown or not
... but there's also stuff which is completely separate
... some people have said they'd like a life cycle specification
... but they haven't put the work into it
... i'm not sure it's needed
AB: i agree with RB
... i think it would be interesting to look at if someone were to contribute it
ABe: i don't see it as a viable working item
AB: if no one puts forward a
proposal, that would be the default
... did you guys, CC work on the update problem?
CC: no. we referenced your update
spec, and when you moved it away
... we didn't really have a way to handle it
... we moved it to the references section
... we didn't know what to do
AB: you didn't do extensions
there?
... I think for some elements you made extensions, but not update?
CC: yes, none for update
BS: about the lifecycle...
... it has more to do with the activation of a scene
... and the synchronization
CC: yes
BS: i think that's more in line
with what i talked about earlier .. rich media environment
OMA
... and i dropped a link earlier
... I think that's been outside the scope of what widgets have focussed on
... i don't think there's anything in widgets that deals with scene at all
... and therefore lifecycle is not relevant
... our view modes deal with window state
... not really the same as multiple synchronized representations
AB: ok, continuing...
... section 7
CC: one comment on
Communication
... using postMessage and
... we had a strong requirement that communication should be possible without scripting
... the idea was to be able to implement it in very limited devices
... e.g. UPnP light bulbs
... should be able to communicate with MPEG widgets
... without any scripting
... that's what drove the design of this communication part
ABe: isn't that down to
protocols
... outside the scope of a widget
<darobin> +1 to Arve
ABe: it's a general web
problem
... what you're looking for is a general protocol problem
CC: i think it's related to the
previous problem
... what the w3 group describes in terms of widgets
... is not related to scene layers
... and that's what the bits we've described is for
ABe: don't misunderstand me
... things like this do fit into the problem of the web
... but i believe that problem should be looked at in a different context than widgets
... if you're looking at the UPnP problem of wanting to turn down lights while watching a movie
... it's a protocol for interacting with limited devices
... i'm a bit unsure if this is in the device api land
... or if it's in the scope of the widget wg
... or if it belongs somewhere else
AB: i briefly looked at 7.3
... and it looks like you could replace widget implementation with web browser
BS: i think this is talking about
concepts again which are well beyond the current functions of a
web browser
... i think this is along the lines of service discovery
... services, i give them URNs
... i run in an environment which discovers services
... peer to peer, media servers, ....
... i think this is more, not a web concept, a UPnP concept
... this is far beyond the concept of a web browser
AB: the point of agreement here
is that the type of functionality described in 7.3 is out of
scope for web apps
... we should move on
... section 7.4. comments?
... i need to look at it in detail
CC: the general idea is that we
serialize preferences that the widgets change / modified
... and we exchange it
... this serialized format is related... using the <preferences> element from P&C
AB: other comments on section
7?
... ok section 8
... RB?
RB: can you clarify the difference between (un?)packaged and the web site?
CC: ok, we want to be able to deliver packages in an MPEG2 carousel
<bsulliva> the difference is in the availability of a manifest - this does not occur for websites
CC: the carousel has the ability
to deliver updates to fragments
... you deliver the carousel
... and then later the broadcaster can deliver an update to one file
... you might also want to be able to request for proper content from a web server
... the config.xml might say that the start file is available in 3 formats
... SVG, XML, HTML
... and depending on the device, you might want to request only one format
<bsulliva> this is actually one of the weaknesses of unpackaged widgets - you can't use the same code for the widget in both cases, or use the config.xml directives in the website
RB: i'm surprised that's not already supported by the spec
CC: there's no mime type for the config.xml file
RB: that's the next question
CC: if you dig up previous
versions of this spec
... we asked if the w3c should standard the mime type of the file
... i asked on the list, and the response was that someone didn't think it was a good idea
... we decided to standardize it, but only when it deals with mpeg extensions
RB: it's generally not a great
idea to register a media type for a file format
... that someone else is handling
CC: i agree, but...
RB: what's wrong with using application/xml ?
ABe: i think application/xml is
the right thing to use here
... serving config.xml over the network has never come up as a use case
... if you're serving single files over the web
... why not call them web applications
... and serve them directly
... if you're trying to use the web directly
... you're going against the reason widgets were created in the first place
CC: we have use cases where files
are not delivered in a zip
... they're delivered in something equivalent to a zip
... in the MP4 file format
... it's similar for the MP2 carousel
... but we need a mime type
... and we need to indicate that the config.xml is not a generic xml file
... but has specific meaning
... i'm open to suggestions
AB: i seem BS is on the queue
BS: I put a couple of points in
the chat
... first, we have a solution for this
... the browser downloads the widget
... and plays the files from the package
... i agree that there's no way to characterize the manifest of a web site
... i agree that there should be no difference between the package you can create using a packaged or unpackaged format
... i think that's a weakness
... maybe you can solve that by downloading and using directly in the browser a widget package
CC: but there are cases when you don't wan to get the whole package
ABe: which cases are that?
... and how are they not solved in the web setup at large?
... (by caching)
BS: if you're asking me, it's
because caching is nondeterministic
... caching is a problematic thing... best effort
ABe: i'm struggling to see
this
... how is this not solved by e.g. html5 offline applications
... ?
... if you want to do this....
... because you are trying to do something which is rather different than what widgets were supposed to be
... the rational needs to be extremely clear
... which use cases are you solving?
... what are you getting by using widgets instead of other container formats?
BS: my use case is that i don't
want to develop my web application twice
... in terms of packaged/unpackaged use
... I discover it on the web, and it's cached using html5 caching directives
... i shouldn't have to develop my web application using two separate semantics
AB: time check
... i want to talk about p&c
... i'd like to stop talking about section 8, and encourage people to continue on the list
... moving to section 9. RB?
<scribe> ScribeNick: ArtB
RB: what formalism is used in
Section 9?
... not Web IDL
CC: you are correct; we can use Web IDL
RB: can you reuse one of the existing stackes re messaging protocols?
CC: for example?
RB: well, there is CORBA
... and other stuff [missed it]
... the spec doesn't cite other related work
CC: the API for comm is coupled
with the XML format
... can take a look at this to see if we can improve it
... but we want it to work without scriptiong
JS: wondering about search
ifce
... but it isn't defined anywhere
CC: used in the example
AB: anything else on section
9?
... let's move then to section 10 Manifest
<timeless_mbp> > For elements defined in W3C WPC, no prefix is used.
RB: small nit about some prefix
usages
... can't really constrain this
CC: agree should be bound to the
namespace defined
... I'll fix it, just let me know
<timeless_mbp> > ‘urn:mpeg:mpegu:schema:widgets:manifest:2010’.
RB: using URN for namespace prefix is considered bad practice
CC: if it is bad practice, we can
change it
... use URL?
RB: yes
CC: not sure if we can modify it
RB: helps with discoverability
for humans and computers
... type attributes, you'd like to see them in the W3C spec?
CC: which element?
<bsulliva> where is that good/bad namespace decl practice identified (URN vs URL)? in a W3C document? that would be useful to know.
AB: which section?
CC: 10.2, the first extension attribute
RB: I don't think we want to add
it to P&C spec
... should make it multi-value
... proc model for multiple instances is a bit fuzzy
... needs to be clearer
CC: OK
RB: also naming and camel case needs some work
CC: ok
RB: not sure about the release
date?
... how does it work with updates?
CC: P&C has version attribute
<timeless_mbp> > Optional. A boolean which indicates if multiple instances of this widget will present different results (multipleInstances==“true”) or not. If not specified, the default value is “false”.
CC: requires number and
name
... we may just have date
RB: can have anything you want in
version
... can verify with MC
MC: it is just a string
AB: we probably tightened it in a later spec
JS: re multiple instances
... think the wording is confusing
CC: yes, that's the same comment as RB
RB: author should be able to define if multiple instances are possible or not
CC: think this is for the UA not author
JS: think the UA should be able to implement it as it wants
CC: this attribute is a hint
RB: not sure the hint is
needed
... e.g. if no prefs
JS: don't like the author to be able to overly constrain the UA
BS: a key extension is on the
<content> element and their new attrs
... think we need to get feedback on multiple content elements
<darobin> [can mw:discardable be ignored by the UA at user option? it's not something that should be enforced]
CC: we will drop width and height
<timeless_mbp> darobin: +1
<darobin> [how is mw:uuid different from @id]
CC: but want multiple content in
the config file
... and want W3C to define it
<timeless_mbp> <content> covers 'types' with locales
AB: where do we submit comments?
<timeless_mbp> i don't think that types and locales are compatible typically
CC: use public-webapps
... if we have any liaison to go back, making it Public is OK
<timeless_mbp> ABe: +1 :)
Arve: what is the IPR
status?
... we need to be careful here
CC: per ISO rules, MPEG has asked
its members to make RF declarations for its widget spec
... we will send more information to WebApps when we have it
Arve: think we should stop discussions until the declarations are made
<timeless_mbp> +1
<timeless_mbp> of note, we required the previous group that joined to play by the same game
CC: I'm not sure when we'll have all of the declaration forms
Arve: I don't think we should continue until we have such delcarations
RB: we can send feedback
... but we cannot use their input without RF declarations
AB: agree with that
<timeless_mbp> the previous group was OMTP
AB: thank Cyril
... if you have comments send them to public-webapps
CC: I can put some demo videos on our web site
AB: the Process Document defines
the entrance criteria for PR (
). The P&C CR's status section defines exit criteria (
). I think we have met both criteria.
... what is the ITS test suite status?
MC: I created ITS tests
<Marcos>
AB: will the impl report separate Mandatory versus Optional tests?
MC: not yet, but it will
... will try to finish that today
AB: when you are done with those edits, will it show 3 impls pass 100% of the Mandatory tests?
MC: yes, that is correct
... we also have the http tests
... no commitments yet to implement ITS
... I created 15 ITS test cases
<Marcos> Test the user agent's ability to handle the its:dir attribute set to 'rtl' on an element in the widget namespace. To pass, the user agent must act as if there was a U+202E RIGHT-TO-LEFT OVERRIDE character at the start of the description element, and a U+202C POP DIRECTIONAL FORMATTING at the end of the element (the rendered text content of the element would look like 'BACKWARDS', but would not actually include the unicode directional characters).
MC: I can't find any place in the
ITS spec anywhere that indicates the above text
... it is underspecified re how we want to use it
... If no one is implementing ITS, perhaps we should drop it
AB: the flip side is that since it is optional
<Marcos> \
MC: my proposal is a new spec
that defines what the bidi element does
... and define a span element in the widget namespace
AB: what are other's thoughts here?
RB: I'm OK with dropping it if we
don't have to go back to LC
... but I could live with going back to CR
... would like to drop it and go to PR
MC: agree with RB
... it was earlier at risk
AB: we can continue to discuss
this with the team to determine with a way forward
... we can drop it then a 2nd decision is if we ever want to specifiy something
MC: without some spec prevents
stuff like intermixed Hebrew with other langs
... we will need this at some point
JS: there must be a way to do
this with just unicode markers
... think we're trying to solve a prob that is already solved with unicode
AB: I don't we can decide if we can drop ITS and go to PR; must talk to Team and defer to Proc Document
AB: postpone Dig Sig until next week as well as View Modes
RB: I have some changes to make for URI scheme spec and then need to start correspondence with IETF
MC: no activity on update spec
AB: any short topics?
MC: hope to get an update of Update spec out next week
AB: next call is February 25; meeting adjourned
<darobin> timeless_mbp: @namespace its ""; its|span::before { content: "\202E"; } its|span::after { content: "\202C"; } actually *works* in Firefox
<darobin> if I were an evil guy I could support this natively in Widgeon
<darobin> muahaha, it works in Opera too! (cc Marcos)
<timeless_mbp> heh
<darobin> and in Chrome/Safari
<darobin> well, if anything I believe that this shows that ITS is actually not really needed, *[dir=ltr] ought to be sufficient
<Marcos> right
This is scribe.perl Revision: 1.135 of Date: 2009/03/02 03:52:20 Check for newer version at Guessing input format: RRSAgent_Text_Format (score 1.00) Succeeded: s/MPEGU would make it possible to/MPEG-U intends to "ensure that it is targeted for additional domains than Web connected devices, e.g. broadcast, mobile or home networking domains."/ Succeeded: s/bryan/BS/g Succeeded: s/post methods/Post Message/ Succeeded: s/MC:/ABe:/ Succeeded: s/files/file/ Succeeded: s/that/that?/ Succeeded: s/reuse/reuse one/ Succeeded: s/search ifc/search ifce/ Succeeded: s/WPC no/WPC, no/ Succeeded: s/son of a bitch/guy/ WARNING: No scribe lines found matching ScribeNick pattern: <Art> ... Found ScribeNick: ArtB Found Scribe: Art Found ScribeNick: timeless_mbp Found ScribeNick: ArtB ScribeNicks: ArtB, timeless_mbp Default Present: +45.81.aaaa, Art_Barstow, Cyril, arve/marcos, darobin, Bryan_Sullivan, Steven, Josh_Soref Present: Art Arve Cyril Marcos Robin Bryan StevenP Josh Regrets: Frederick Marcin DavidR Agenda: Found Date: 18 Feb 2010 Guessing minutes URL: People with action items:[End of scribe.perl diagnostic output] | http://www.w3.org/2010/02/18-wam-minutes.html | CC-MAIN-2016-22 | refinedweb | 3,986 | 74.9 |
This chapter introduces Java servlets and the Oracle9iAS Containers for J2EE (OC4J). Read this chapter if you are not familiar with servlets or if you want to refresh your knowledge of servlets. For more extensive information about servlets, see the Oracle9iAS Containers for J2EE Servlet Developer's Guide.
This chapter covers the following topics:
A servlet is a Java program that runs in a J2EE application server, such as OC4J, and receives and responds to HTTP requests from clients. Think of a servlet as the server-side counterpart to a Java applet. A servlet is one of the four application component types of a J2EE application. Others are applets and application client programs on the client side, and EJBs on the server side. Servlets are managed by the OC4J servlet container; EJBs are managed by the OC4J EJB container. These containers, together with the JavaServer Pages container, form the core of OC4J.
JavaServer Pages (JSP) is another server-side component type. JSP pages also involve the servlet container, because the JSP container itself is a servlet and is therefore executed by the servlet container. The JSP container translates JSP pages into page implementation classes, which are executed by the JSP container but function similarly to servlets. See Chapter 6, "JSP Primer" and the Oracle9iAS Containers for J2EE Support for JavaServer Pages Reference for more information about JSP pages.
Most servlets generate HTML text, which is then sent back to the client for display by the Web browser, or sent on to other components in the application. Servlets can also generate XML, to encapsulate data and send the data to the client or to other components.
A servlet differs from a Java application client in that is has no static
main() method. Therefore, a servlet must execute under the control of a servlet container, because it is the container that calls the methods of the servlet and provides services that the servlet might need when executing.
The servlet itself overrides the access methods (implemented in the
GenericServlet or the
HttpServlet classes) that it needs to process the request and return the response. For example, most servlets override the
doGet() and
doPost() methods (or both) of the
HttpServlet to process
HTTP
GET and
POST requests.
The servlet container provides the servlet easy access to properties of the HTTP request, such as its headers and parameters. In addition, a servlet can use other Java APIs such as JDBC to access a database, RMI to call remote objects, or JMS to perform asynchronous messaging, plus many other Java and J2EE services.
Because servlets are written in the Java programming language, they are supported on any platform that has a Java virtual machine and a Web server that supports servlets. You can use servlets on different platforms without recompiling and you can package servlets together with associated files such as graphics, sounds, and other data to make a complete Web application. This greatly simplifies application development.
It also means that your servlet-based application that was developed to run on another application server can be ported to OC4J with little effort. If your application was developed for an application server that complies with J2EE, then the porting effort is minimal.
Servlets outperform earlier ways of generating dynamic HTML, such as server-side includes or CGI scripts. Once a servlet is loaded into memory, it can run on a single lightweight thread; CGI scripts must be loaded in a different process for every request.
A servlet, along with optional servlet filters, relates to the servlet container and a client, such as a Web browser. When the Web listener is the Oracle HTTP Server, then the connection to the OC4J servlet container is through the
mod_oc4j module. See the Oracle HTTP Server Administration Guide for details.
A good way to learn about servlets and how to code them is to view some simple servlet examples. This section displays the code for two servlets and annotates the code with comments. For simplicity, numbered callouts are located beside sections of code and the corresponding descriptions for each number section appears below the code example.
Here is another "Hello World" demo. But it does serve to show the basic framework you use to write a servlet. This servlet just prints "Hi There!" back to the client.
import java.io.*; // 1. (first comment) import javax.servlet.*; import javax.servlet.http.*; public class HelloWorldServlet extends HttpServlet { // 2. public void doGet (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // 3. resp.setContentType("text/html"); // 4. ServletOutputStream out = resp.getOutputStream(); // 5. out.println("<html>"); // 6. out.println("<head><title>Hello World</title></head>"); out.println("<body>"); out.println("<h1>Hi There!</h1>"); out.println("</body></html>"); // 7. } }
HttpServletclass, which implements the methods that a servlet uses. You override the methods you need for your particular servlet implementation.
doGet()method here overrides the one in the
HttpServletclass, which services HTTP
GETrequests. Like almost all
HttpServletmethods,
doGet()takes request and response objects as parameters. In this example, no methods are called on the request object (
req), because this example requires no input (that is, request) data.
setContentType()method on the response object to set the response content MIME type in the header. Here, it is
text/html, because that is what this servlet generates.
resp) to get a writer that sends the output of the server back to the client. You could also get a
PrintWriterfrom the response object.
<h1>) format.
bodyand
htmltags.
Save this servlet in a file called
HelloWorldServlet.java. Compile the servlet, using a Java 1.3.x compliant compiler:
% javac HelloWorldServlet.java
If you would like to try out this servlet in OC4J, just configure a
web.xml and archive these in a WAR file. Deploy the WAR file using the Deploy WAR File button on the OC4J Home Page. In the wizard, provide the URL servlet context as
/j2ee/hello. Thus, the WAR is deployed into the
/j2ee/hello servlet context. Having made sure that OC4J is up and running, you can invoke this servlet and see its output from a Web browser. Just enter the URL:
http://<apache_host>:<port>/j2ee/hello/servlet/HelloWorldServlet
The /
servlet part of the URI is an OC4J feature that starts up any servlet indicated, which in this case is the
HelloWorldServlet. Alternatively, you could have configured a context for the servlet in the application
web.xml. For example, the
HelloWorldServlet could be mapped to a URL, such as "
world", as follows:
<servlet-mapping> <servlet-name>HelloWorldServlet</servlet-name> <url-pattern>/world</url-pattern> </servlet-mapping>
Thus, you would invoke the servlet as follows:
http://<apache_host>:<port>/j2ee/hello/world
The
<
apache_host
> represents the name of the host that the OC4J server is running on. By default in Oracle9iAS, specify port 7777 for access through the Oracle HTTP Server with Oracle9iAS Web Cache enabled.
If your servlet exists within a package (or packages), you would include the packages in the
<servlet-name> definition. The following shows the
<servlet-name> definition for the
HelloWorldServlet that is included in the "
my" package. If this servlet is included in a nested group of packages, they are separated by a period.
<servlet-mapping> <servlet-name>my.HelloWorldServlet</servlet-name> <url-pattern>/world</url-pattern> </servlet-mapping>
The
HttpServlet methods, such as
doGet() and
doPost(), take two parameters: an
HttpServletRequest object and an
HttpServletResponse object. The servlet container passes these objects to the servlet and receives the response to pass on to the client, to the next servlet in a filter chain, or to another server object such as an EJB.
The request and response objects support methods that enable you to write efficient servlet code. In the preceding example, you saw that you can get a stream writer object from the response and use it to write statements to the response stream.
The
HelloWorldServlet example shows a minimal servlet--it really does not do very much. But the power of servlets comes from their ability to retrieve data from a database. A servlet can generate dynamic HTML: the servlet can get information from a database and send it back to the client.
Of course, a servlet can also update a database, based upon information passed to it in the HTTP request.
In the next example, a servlet gets some information from the client (the Web browser) and queries a database to get information based on the request data.
Although there are many ways that a servlet can get information from its client, this example uses a very common method: reading a query string from the HTTP request.
The Web browser accesses a form in a page that is served through the OC4J Web listener. First, enter the following text into a file. Next, name the file
EmpInfo.html.
<html> <head> <title>Query the Employees Table</title> </head> <body> <form method=GET The query is<br> SELECT LAST_NAME, EMPLOYEE_ID FROM EMPLOYEES WHERE LAST NAME LIKE ?.<p> Enter the WHERE clause ? parameter (use % for wildcards).<br> Example: 'S%':<br> <input type=text <p> <input type=submit> </form> </body> </html>
The servlet that the preceding HTML page calls takes the input from a query string. The input is the completion of the WHERE clause in the SELECT statement. The servlet then appends this input to complete the database query. Most of the complexity of this servlet comes from the JDBC code required to connect to the data server and retrieve the query rows. If you are not familiar with JDBC, see the <!A HREF="../../web.902/a90211/toc.htm">Oracle9i JDBC Developer's Guide and Reference.
Here is the code for the servlet:
import javax.servlet.*; import javax.servlet.http.*; import javax.naming.*; //1. (see comments below) import javax.sql.*; // 2. import oracle.jdbc.*; public class GetEmpInfo extends HttpServlet { DataSource ds = null; Connection conn = null; public void init() throws ServletException { // 3. try { InitialContext ic = new InitialContext(); // 4. ds = (DataSource) ic.lookup("java:comp/env/jdbc/OracleDS"); // 5. conn = ds.getConnection(); // 6. } catch (SQLException se) { // 7. throw new ServletException(se); } catch (NamingException ne) { // 8. throw new ServletException(ne); } } public void doGet (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String queryVal = req.getParameter("queryVal"); // 9. String query = //10. "select last_name, employee_id from employees " + "where last_name like " + queryVal; resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); out.println("<html>"); out.println("<head><title>GetEmpInfo</title></head>"); out.println("<body>"); try { Statement stmt = conn.createStatement(); //11. ResultSet rs = stmt.executeQuery(query); //12. for (int count = 0; ; count++ ) { //13. if (rs.next()) { out.println(rs.getString(1) + " " + rs.getInt(2) + "<br>"); } else { out.println("<h3>" + count + " rows retrieved</h3>"); break; } } rs.close(); //14. stmt.close(); } catch (SQLException se) { //15. se.printStackTrace(out); } out.println("</body></html>"); } public void destroy() { //16. try { conn.close(); } catch (SWLException ignored) { } } }
HttpServlet
init()method to look up a data source and get a database connection using the data source.
OracleDS. This assumes it has been configured in Enterprise Manager using the following element definitions:
" />
You can configure this data source either using the Advanced Properties or the Data Source links in the Administration section of either the OC4J Home Page or the application page.
In Oracle9iAS 9.0.2, it is advisable to use only the
ejb-location JNDI name in the JNDI lookup for a data source. See the Oracle9iAS Containers for J2EE Services Guide for more information about data sources.
try...catchsequence, to catch JNDI naming or SQL errors.
ServletException.
ResultSetobject. This causes the statement to execute the query, and returns a result set, which may be empty, or else contains all the rows that satisfy the query.
getString()and
getInt()methods of the result set instance. See the <!A HREF="../../web.902/a90211/toc.htm">Oracle9i JDBC Developer's Guide and Reference for more information about the result set's
getXXX()methods.
destroy()method closes the database connection.
When your browser invokes
EmpInfo.html, you should see a browser window that looks something like this:
Text description of the illustration gsimg1.gif
Entering
'S%' in the form, and pressing Submit Query calls the
GetEmpInfo servlet, and the results look like this:
Text description of the illustration servpri2.gif
The output from the
GetEmpInfo servlet is not very well formatted. But since the servlet generates HTML, there's no reason why you can't make the output a bit prettier. Just add an HTML
table statement before the Java for statement, and replace the
out.println() code in the for with some
out.println() calls that generate HTML table rows. Here is one way to do this:
out.println("<table border=1 width=50%>"); out.println("<tr><th width=75%>Last Name</th><th width=25%>Employee " +
ID</th></tr>"); for (int count = 0; ; count++ ) { if (rs.next()) { out.println ("<tr><td>" + rs.getString(1) + "</td><td>" + rs.getInt(2) + "</td></tr>"); } else { out.println("</table><h3>" + count + " rows retrieved.</h3>"); break; } }
This simple modification generates better-looking output in a browser window, as shown here:
Text description of the illustration servpri3.gif
Servlets, and their JSP relatives, have come into widespread use for applications like shopping carts. For example, clients search for an item on a web site, then go to a page that describes the item more fully, and then might decide to buy the item, putting in their shopping basket. Finally, they check out, giving credit card details and a shipping address. To implement such a site, the server must be able to track the identity of clients as they migrate from page to page of the Web site.
Several mechanisms have been developed to do this, but the most widely-used is undoubtedly the cookie. A cookie is just a small piece of information, that includes the server session ID, that the server sends back to the client. The client (the Web browser, for example) then returns the cookie to the server on each new HTTP request. So a cookie provides a means to let a client synchronize with a server session to maintain stateful information while still using the stateless HTTP protocol.
In addition to cookies, for client to server communication, the OC4J servlet container supports the
HttpSession object, as described in the servlet specifications. An HTTP session object is scoped over the Web application only. This means that you cannot use session objects to share data between applications, or between different clients. To do these things, you should persist the data in a database or some other location.
The
SessionServlet code below implements a servlet that establishes an
HttpSession object, and uses that object to maintain a counter that records the number of times the session has been accessed. The servlet also prints a lot of information obtained both from the request and the session objects, to illustrate some of the capabilities of the
HttpServletRequest and the
HttpSession classes.
import java.io.*; import java.util.Enumeration; import javax.servlet.*; import javax.servlet.http.*; import java.util.Date; public class SessionServlet extends HttpServlet { public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { HttpSession session = req.getSession(true); // 1. res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println("<head><title> " + "SessionServlet Output " + "</title></head><body>"); out.println("<h1> SessionServlet Output </h1>"); Integer ival = (Integer) session.getAttribute("sessionservlet.counter"); // 2. if (ival==null) { ival = new Integer(1); } else { ival = new Integer(ival.intValue() + 1); } session.setAttribute("sessionservlet.counter", ival); // 3. out.println(" You have hit this page <b>" + ival + "</b> times.<p>"); // 4. out.println("Click <a href=" + res.encodeURL(HttpUtils.getRequestURL(req).toString()) + ">here</a>"); // 5. out.println(" to ensure that session tracking is working even " + "if cookies aren't supported.<br>"); out.println("Note that by default URL rewriting is not enabled" + " due to its large overhead."); out.println("<h3>Request and Session Data</h3>"); // 6. out.println("Session ID in Request: " + req.getRequestedSessionId()); out.println("<br>Session ID in Request is from a Cookie: " + req.isRequestedSessionIdFromCookie()); out.println("<br>Session ID in Request is from the URL: " + req.isRequestedSessionIdFromURL()); out.println("<br>Valid Session ID: " + req.isRequestedSessionIdValid()); out.println("<h3>Session Data</h3>"); // 7. out.println("New Session: " + session.isNew()); out.println("<br> Session ID: " + session.getId()); out.println("<br> Creation Time: " + new Date(session.getCreationTime())); out.println("<br>Last Accessed Time: " + new Date(session.getLastAccessedTime())); out.println("</body>"); out.close(); } public String getServletInfo() { //8. return "A simple session servlet"; } }
getSession(true)method creates a new session if one hasn't already been created.
intvalue. The name
sessionservlet.counteris an arbitrary key name for the attribute that is assigned by this servlet.
getServletInfo()is a method that the container can call when it needs to supply information about what the servlet does. A servlet can override this
GenericServletmethod to provide meaningful information for the container.
When you invoke the SessionServlet from a web browser, you will see something like the following:
Text description of the illustration servpri4.gif
You can use filters to process the requests that servlets receive, process the responses, or do both. For example, an application might need to provide special logging of certain kinds of requests for one or more servlets, or might need to encrypt the output (response objects) of a whole class of servlets.
Unlike servlets, filters do not generally create a response. You use filters to modify the requests or responses, or to perform some other action based on the requests or responses. These actions could include:
The
javax.servlet.Filter interface was added to the Servlet 2.3 specification to allow an application to perform these kinds of tasks. Several filters can be chained together to perform a series of tasks on requests or responses.
This example implements a simple filter that logs the amount of time (in milliseconds) required to process a servlet request. In this example, the filter is deployed to the default Web application, and a time log of each servlet or JSP invocation is written to the
global-application.log file in the
j2ee/home/log directory. To see the results of the filter, just examine this file in a separate window as servlet requests are being processed. On a UNIX-type system, you can use the command:
% tail -f
j2ee/home/log/global-application.log
The log filter implementation is commented, just like the previous examples.
import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class LogFilter implements Filter { //1. FilterConfig config; ServletContext context; public void init(FilterConfig config) { //2. this.config = config; context = config.getServletContext(); //3. } public void destroy() { //4. context.log("Log Filter terminating."); } public //5. void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { long bef = System.currentTimeMillis(); chain.doFilter(req, res); //6. long aft = System.currentTimeMillis(); HttpServletRequest nreq = (HttpServletRequest) req; context.log("Request from " + nreq.getRequestURI() + ": " + (aft-bef)); } }
javax.servlet.Filterinterface:
doFilter(),
init(), and
destroy().
init()method at startup.
ServletContextobject from the configuration, to use writing the to the log file.
destroy()method must be implemented. The container calls
destroy()before terminating the filter, so put any clean-up code, such as closing file handles, here.
doFilter()takes request and response objects as parameters, and a
FilterChainobject that lets the filter pass on the request and response objects (perhaps wrapped) to the next filter in the chain, or at the end of the chain, to the servlet or back to the container. The container calls filters before and after processing the target servlet.
configobject.
This filter is solitary (there is no chain), so the
FilterChain parameter is not used in the
doFilter() invocation.
After the servlet has finished, the filter computes the time required to process the servlet (in milliseconds), and writes the value out to the log file, along with the URI that invoked the servlet for which the filter applies.
Filters are configured in the deployment descriptor of a web application. Create a
<filter> tag in the
web.xml file, indicating a name for the filter and the name of the class that implements the filter. The filter in this example is intended to monitor all servlet requests for the application, so there must be a mapping to indicate that and to have it filter all requests:
'/*'.
Therefore, to deploy this filter in the default Web application, enter the following lines in
web.xml:
<web-app> ... <filter> <filter-name>log</filter-name> <filter-class>LogFilter</filter-class> </filter> <filter-mapping> <filter-name>log</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> ... </web-app>
This sample shows the output that this filter generates. The
PrimeSearcher servlet was initialized by the container, and called a few times, then the server was shut down, but first the container called the filter
destroy() method. The lines that begin "Request from..." are the filter output.
8/1/01 8:50 AM defaultWebApp: 1.0.2.2 Stopped 8/1/01 8:50 AM defaultWebApp: PrimeSearcher: init 8/1/01 8:50 AM defaultWebApp: 1.0.2.2 Started 8/1/01 8:50 AM defaultWebApp: PrimeSearcher: init 8/1/01 8:50 AM defaultWebApp: Request from /servlet/PrimeSearcher: 1 8/1/01 10:10 AM defaultWebApp: Request from /servlet/PrimeSearcher: 1 8/2/01 5:56 AM defaultWebApp: Request from /servlet/PrimeSearcher: 2 8/2/01 2:12 PM defaultWebApp: Log Filter done. 8/2/01 2:12 PM defaultWebApp: 1.0.2.2 Stopped 8/2/01 2:12 PM Stopped (Shutdown executed by admin from 130.35.172.234 (dlsun1497))
For more information about filters, filter chains, and filter deployment, see the Oracle9iAS Containers for J2EE Servlet Developer's Guide.
Your first step in learning more about servlets should be to read the Oracle9iAS Containers for J2EE Servlet Developer's Guide. This guide tells you what you need to know to develop servlets and web-tier applications in the OC4J environment.
To get complete documentation on the servlet APIs, visit the Sun Microsystems Web site at:
You can also find a great deal of tutorial information on servlets as well as other aspects of J2EE application development at this site.
Finally, there are several trade press books that will teach you how to develop servlets, and deploy them in J2EE-compatible applications. In particular, the books from O'Reilly & Associates () and Wrox () are very useful. | http://docs.oracle.com/cd/A97329_03/web.902/a95880/servprim.htm | CC-MAIN-2015-32 | refinedweb | 3,694 | 57.16 |
For most programs, the default settings for the garbage collection parameters should suffice. For programs that have high heap requirements, the default parameters may result in a higher ratio of garbage collection time to run time. These programs should be given more space in which to run.
The
gc_margin is a non-negative integer specifying the desired margin in
kilobytes. For example, the default value of 1000 means that the
heap will not be expanded if garbage collection can reclaim at least
one megabyte. The advantage of this criterion is that
it takes into account both
the user's estimate of the heap usage and the effectiveness of garbage
collecting.
gc_marginhigher than the default will cause fewer heap expansions and garbage collections. However, it will use more space, and garbage collections will be more time-consuming when they do occur.
Setting the margin too large will cause the heap to expand so that if it does overflow, the resulting garbage collection will significantly disrupt normal processing. This will be especially so if much of the heap is accessible to future computation.
gc_marginlower than the default will use less space, and garbage collections will be less time-consuming. However, it will cause more heap expansions and garbage collections.
Setting the margin too small will cause many garbage collections in a small amount of time, so that the ratio of garbage-collecting time to computation time will be abnormally high.
The correct value for the
gc_margin is dependent upon many factors.
Here is a non-prioritized list of some of them:
The algorithm used when the heap overflows is as follows:
if
gcis on and the heap is larger than
gc_marginkilobytes then garbage collect the heap if less than
gc_marginkilobytes are reclaimed then try to expand the heap endif else try to expand the heap endif
The user can use the
gc_margin option of
prolog_flag/3 to
reset the
gc_margin (see ref-lps-ove). If a garbage
collection reclaims at least the
gc_margin kilobytes of heap space
the heap is not expanded after garbage collection completes.
Otherwise, the heap is expanded after garbage collection. This
expansion provides space for the future heap usage that will
presumably occur. In addition, no garbage collection occurs if the
heap is smaller than
gc_margin kilobytes. | http://sicstus.sics.se/sicstus/docs/4.2.3/html/sicstus.html/ref_002dmgc_002dgch.html | CC-MAIN-2014-15 | refinedweb | 379 | 60.14 |
Hi - I have a function that goes as below to query the API which has worked perfectly few weeks ago to extract 1000+ appointments from self_appointments links.
Today I am trying to get ~300,000 profiles (as I need dissolved data too - absent from the bulk data) but I keep getting a 429 error.
raise HTTPError(http_error_msg, response=self)requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: ...
Is there anything wrong with the API, or am I missing something here?
import requests
from requests import ConnectionError
from ratelimit import limits, sleep_and_retry
from backoff import on_exception, expo
KEY = get_key("API_key")
FIVE_MINUTES = 300 # Number of seconds in five minutes.
API_BASE_URL = ""
@sleep_and_retry # if we exceed the ratelimit imposed by @limits forces sleep until we can start again.
@on_exception(expo, ConnectionError, max_tries=5)
@limits(calls=600, period=FIVE_MINUTES)
def call_api(url, api_key):
r = requests.get(url, auth=(api_key, ""))
if not (r.status_code == 200 or r.status_code == 404):
r.raise_for_status()
elif r.status_code == 404:
return dict({"error": "not found"})
else:
return r.json() | https://forum.aws.chdev.org/t/600-ratelimit-not-respected-error-429/2448 | CC-MAIN-2020-10 | refinedweb | 171 | 59.8 |
> From: "Stephen J. Turnbull" <address@hidden> > Tom> cscvs is a separate project and I'm not sure why you'd > Tom> mention it in this context -- but from what I can see, the > Tom> cscvs project uses an unholy marriage of private mail, > Tom> gnu-arch-users mail, and #arch irc traffic as a crude > Tom> approximation of a patch tracker. > Exactly. Although cscvs is an important project to many arch users, > and can benefit from and be hindered by arch changes, it's not in the > arch patch tracker. > So what it comes down to is that the savannah bug tracker is about > access to Tom. It reflects and probably encourages centralization of > decision-making in Tom, and does not help those parts of the community > which are doing something that Tom is not directly involved in. It > encourages Tom to focus on the bug-tracker as the source of patches > and other arch development issues, possibly tending to exclude issues > that relate to third-party projects. > Whether these are good things or not, I don't know. But they are not > decentralizing influences as currently implemented. Sure. I don't mean to impose "make a decentralizing influence" as the primary design constraint. It's interesting that you talk about two distinct but related projects for which it'd be useful to have some kind of "cross linkage" of patch tracking. One obvious question is just what exactly kind of "cross linkage" are we talking about? That's an aspect of the the more general question "What exactly does a patch tracker track"? But leaving those questions aside and just assuming that a patch tracker tracks _something_ worthwhile and that there is _some_form_ of cross linking: Presumably when we have multiple projects coordinated this way we have to think about crossing administrative boundaries. I'll have my patch tracker, you'll have yours, but linkages and so forth have to span the boundary between them. Just as a general principle, that suggests following the arch-like pattern (and usenet-like pattern) of a location-independent global namespace with underlying distributed storage management. > > Making Linus and even the whole gatekeeper collection faster is a > > worthy project. But it seems you think something is going to make it > > possible to get Linus off the critical path. Don't hold your breath. > Tom> I don't have to get Linus off the critical path. That > Tom> happened a few years ago (quite independently of bitkeeper, > Tom> too). > Then why does it matter if Linus drops Miles's patches on the floor? > The fact that the project could continue without Linus is irrelevant > to whether Linus is on the critical path in the current organization. I just think he's not on the critical path in the sense that distributions tend to get ahead of him on this or that feature and (don't they?) display features that propogate other than through him? I think he's not on the critical path for short and medium term distribution releases. Thinking about it, though, he presumably _is_ on the critical path of longer-term cross-cutting architectural issues and on the critical path of getting everyone to more or less agree on "what the state of the kernel is". It doesn't, in my view, matter much that Linus himself drops Miles' patches. It matters that where a database could save Miles' a lot of labor, there is no database, and Miles' labor is substituted to compensate. It's not so much Linus' efficiency I'm concerned with: it's the efficiency of all the contributors. Linus says: "Ok, here is 2.6" and everybody with pending patches has to figure out whether they still apply, whether they're remembered or dropped, etc. A patch tracker can automate much more of that -- what we currently have is a lot of people doing patch-tracker bookkeeping by hand. -t | http://lists.gnu.org/archive/html/gnu-arch-users/2003-10/msg00916.html | CC-MAIN-2014-41 | refinedweb | 654 | 60.24 |
This lab depends on the introductory material earlier in this chapter, particularly keep handy Summary of String Length and Some Instance Methods. Be mindful of the processes developed in class filling in A Creative Problem Solution.
Parts 2 and 4 also depend on Decisions through More Conditional Expressions.
Design, compile and run a single C# program to accomplish all of the following tasks. Add one part at a time and test before trying the next one. The program can just include a Main method, or it is neater to split things into separate methods (all static void, with names like ShowLength, SentenceType, LastFirst1, LastFirst), and have Main call all the ones you have written so far (or for testing purposes, just the one you are working on, with the other function calls commented out). Use the UIF class for user input. You can copy the file into your project.
Alternately practice using an Xamarin Studio library reference: Create a new project in a solution in which you already have added the ui library project. Make the ui project be a reference for the lab project.
Make sure your program has
namespace IntroCS; to match the ui project.
Beware of modifying the sample Program.cs generated by Xamarin Studio - it will use
the project name for a namespace. We are never going to use that.
Read a string from the keyboard and print the length of the string, with a label.
Read a sentence (string) from a line of input, and print whether it represents a declarative sentence (i.e. ending in a period), interrogatory sentence (ending in a question mark), or an exclamation (ending in exclamation point) or is not a sentence (anything else).
This may be the first time you write a conditional
statement. (This needs the next chapter.)
It makes sense to only make small changes at once and build
up to final code. First you might just code it to check if a sentence is
declarative or not. Then remember you can test further cases with
else if (...).
Read a whole name from a single line of user input. Do not ask for
first and last names to be entered on separate lines!
Assume first and last names
are separated by a space (no middle name).
Print last name first followed by a comma
and a space, followed by the first name.
For example, if the input is
"Marcel Proust", the output is
"Proust, Marcel".
Improve the previous part, so it also allows a single name without spaces, like “Socrates”, and prints the original without change. If there are two parts of the name, it should work as in the original version. (This needs syntax from the next chapter.)
Run the program (with parts 1, 2 and 4 active) from a terminal window and show your TA when you are done. You should run it twice to show off both paths through part 4. Alternately have the main program just call part 4 twice! | http://books.cs.luc.edu/introcs-csharp/basicstringops/lab-string-ops.html | CC-MAIN-2019-09 | refinedweb | 497 | 73.17 |
Registers a Prefab with the UNET spawning system.
When a NetworkIdentity object is spawned on a server with NetworkServer.SpawnObject(), and the Prefab that the object was created from was registered with RegisterPrefab(), the client will use that Prefab to instantiate a corresponding client object with the same netId.
The NetworkManager has a list of spawnable Prefabs, it uses this function to register those Prefabs with the ClientScene.
The set of current spawnable object is available in the ClientScene static member variable ClientScene.prefabs, which is a dictionary of NetworkAssetIds and Prefab references.
using UnityEngine; using UnityEngine.Networking;
public class PlantSpawner : NetworkBehaviour { public GameObject plantPrefab;
public override void OnStartClient() { ClientScene.RegisterPrefab(plantPrefab); }
[Server] public void ServerSpawnPlant(Vector3 pos, Quaternion rot) { var plant = (GameObject)Instantiate(plantPrefab, pos, rot); NetworkServer.Spawn(plant); } }
The optional custom spawn and un-spawn handler functions can be used to implement more advanced spawning strategies such as object pools.
Did you find this page useful? Please give it a rating: | https://docs.unity3d.com/2018.3/Documentation/ScriptReference/Networking.ClientScene.RegisterPrefab.html | CC-MAIN-2021-10 | refinedweb | 163 | 50.12 |
Squashed c x let a library writer provide
x in "
c-irrelevant" way to a library user.
{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE RankNTypes #-} module Squash where import Control.Applicative (liftA2) import Control.Monad (void, liftM, liftM2) import Data.Monoid (Sum (..)) import Data.Semigroup (Semigroup (..)) import Data.Tree (Tree (..)) import Data.Set (Set) import qualified Data.Set as Set
The definition is simple:
newtype Squashed c x = Squash { getSquashed :: forall r. c r => (x -> r) -> r }
Squashed is almost like
Cont 1 or
Codensity 2, so
Squashed is a
Monad:
instance Monad (Squashed c) where return x = Squash ($ x) m >>= k = Squash $ \bx -> getSquashed m $ \a -> getSquashed (k a) bx instance Applicative (Squashed c) where pure = return liftA2 = liftM2 instance Functor (Squashed c) where fmap = liftM
Monad-instance allows to work on the wrapped value, for example
squashedTree' :: Squashed Monoid (Tree String) squashedTree' = pure $ Node "x" [ pure "yz", pure "foo" ] squashedTree :: Squashed Monoid (Tree Int) squashedTree = do x <- squashedTree' return (fmap length x)
However, we cannot extract the original value, only as much as the constraint let us:
-- 6 example_1 :: Int example_1 = getSum (getSquashed squashedTree (foldMap Sum)) -- [1,2,3] example_2 :: [Int] example_2 = getSquashed squashedTree (foldMap pure)
This restriction maybe be useful to enforce correctness, without relying on the module system!
Squash c x is a generalised notion of "free
c over
x", e.g.
Monoid as described in Free Monoids in Haskell 3. It should be possible to write
c (Squashed c x) instances for all (reasonable)
c. Or actually
(forall x. c' x => c x) => c (Squashed c' a) after Quantified Constraints -proposal 4 is implemented. (TODO: amend when we have the extension in released GHC).
instance Semigroup (Squashed Semigroup x) where a <> b = Squash $ \k -> getSquashed a k <> getSquashed b k instance Monoid (Squashed Monoid x) where mempty = Squash $ \ _ -> mempty mappend a b = Squash $ \k -> getSquashed a k `mappend` getSquashed b k
As with Singleton containers 5, tell me if you have seen this construction in the wild!
Addendum: As
Iceland_jack pointed on Twitter 6 7 there is a
free-functors 8 package on Hackage, and more is written about
Squash:
Note, that
Squash doesn’t let us turn a thing into something it isn’t...
newtype Squashed1 c f x = Squash1 { getSquashed1 :: forall g. c g => (forall y. f y -> g y) -> g x } squash1 :: f x -> Squashed1 c f x squash1 fx = Squash1 ($ fx) instance Monad (Squashed1 Monad f) where return x = Squash1 $ \ _ -> return x m >>= k = Squash1 $ \f -> getSquashed1 m f >>= \y -> getSquashed1 (k y) f instance Applicative (Squashed1 Monad f) where pure = return liftA2 = liftM2 instance Functor (Squashed1 Monad f) where fmap = liftM
... though we can foolishly think so:
intSet' :: Squashed1 Monad Set Int intSet' = squash1 $ Set.fromList [1, 2, 3] intSet :: Squashed1 Monad Set Int intSet = intSet' >>= \ _ -> return 5 -- [5,5,5] intList :: [Int] intList = getSquashed1 intSet Set.toList
So
Squash let’s only forget, not to "remember" anything new.
By the way, this post is genuine Literate Haskell file, using LaTeX, not Markdown. If interested on how, check the gists repository 9. I’m weird, as after some point of markup complexity, I actually prefer LaTeX.↩︎↩︎↩︎↩︎↩︎↩︎↩︎↩︎↩︎ | https://oleg.fi/gists/posts/2018-05-28-squash.html | CC-MAIN-2021-25 | refinedweb | 529 | 66.88 |
From: Doug Stewart [mailto:address@hidden Sent: Tuesday, April 30, 2019 10:45 AM To: John Donoghue Cc: Octave Maintainers List Subject: Re: arduino package testing On Sat, Apr 27, 2019 at 7:37 PM Doug Stewart <address@hidden> wrote: On Fri, Apr 26, 2019 at 6:36 PM John Donoghue <address@hidden> wrote: On 4/26/19 3:00 PM, JohnD wrote: > > From: > > Running on my setup, I can get it programmed without the rotary encoder if I use default libraries, but if I run as: arduinosetup ('libraries', listArduinoLibraries('core')) .. It programs the rotary endcoder as well. Note that currently, if the propertyname isnt a known one (ie: was spelt wrong) it will silently ignore it, which would then mean it would program the default libraries (ie: no rotary encoder) When the arduino IDE is open, it you look at the sources settings.h file, there should be an uncommented #define USE_ROTARYENCODER Here is a little scope prog that I wrote I will see what I can find about the rotaryencoder and report here. I found this in the file called octave: #ifdef USE_ROTARYENCODER #include "OctaveRotaryEncoderLibrary.h" OctaveRotaryEncoderLibrary lib5(octavearduino); #endif so it should work. I did not find a file called: settings.h -------------------------- Can you verify that: > listArduinoLibraries('core') returns with rotaryencoder in it and then retry running: > arduinosetup ('libraries', listArduinoLibraries('core')) reprogram it, and verify that > a = arduino() Then lists rotaryencoder as one of its libraries | https://lists.gnu.org/archive/html/octave-maintainers/2019-05/msg00008.html | CC-MAIN-2021-25 | refinedweb | 239 | 51.72 |
8. Making the pyboard act as a USB mouse¶
The pyboard is a USB device, and can configured to act as a mouse instead of the default USB flash drive.
To do this we must first edit the
boot.py file to change the USB
configuration. If you have not yet touched your
boot.py file then it
will look something like this:
# boot.py -- run on boot-up # can run arbitrary Python, but best to keep it minimal import pyb #pyb.main('main.py') # main script to run after this one #pyb.usb_mode('VCP+MSC') # act as a serial and a storage device #pyb.usb_mode('VCP+HID') # act as a serial device and a mouse
To enable the mouse mode, uncomment the last line of the file, to make it look like:
pyb.usb_mode('VCP+HID') # act as a serial device and a mouse
If you already changed your
boot.py file, then the minimum code it
needs to work is:
import pyb pyb.usb_mode('VCP+HID')
This tells the pyboard to configure itself as a VCP (Virtual COM Port, ie serial port) and HID (human interface device, in our case a mouse) USB device when it boots up.
Eject/unmount the pyboard drive and reset it using the RST switch. Your PC should now detect the pyboard as a mouse!
8.1. Sending mouse events by hand¶
To get the py-mouse to do anything we need to send mouse events to the PC. We will first do this manually using the REPL prompt. Connect to your pyboard using your serial program and type the following:
>>> hid = pyb.USB_HID() >>> hid.send((0, 10, 0, 0))
Your mouse should move 10 pixels to the right! In the command above you are sending 4 pieces of information: button status, x, y and scroll. The number 10 is telling the PC that the mouse moved 10 pixels in the x direction.
Let’s make the mouse oscillate left and right:
>>> import math >>> def osc(n, d): ... for i in range(n): ... hid.send((0, int(20 * math.sin(i / 10)), 0, 0)) ... pyb.delay(d) ... >>> osc(100, 50)
The first argument to the function
osc is the number of mouse events to send,
and the second argument is the delay (in milliseconds) between events. Try
playing around with different numbers.
Exercise: make the mouse go around in a circle.
8.2. Making a mouse with the accelerometer¶
Now lets make the mouse move based on the angle of the pyboard, using the
accelerometer. The following code can be typed directly at the REPL prompt,
or put in the
main.py file. Here, we’ll put in in
main.py because to do
that we will learn how to go into safe mode.
At the moment the pyboard is acting as a serial USB device and an HID (a mouse).
So you cannot access the filesystem to edit your
main.py file.
You also can’t edit your
boot.py to get out of HID-mode and back to normal
mode with a USB drive...
To get around this we need to go into safe mode. This was described in the [safe mode tutorial](tut-reset), but we repeat the instructions here:
-
main.py.
(Leave
boot.py as-is, because we still want to go back to HID-mode after
we finish editing
main.py.)
In
main.py put the following code:
import pyb switch = pyb.Switch() accel = pyb.Accel() hid = pyb.USB_HID() while not switch(): hid.send((0, accel.x(), accel.y(), 0)) pyb.delay(20)
Save your file, eject/unmount your pyboard drive, and reset it using the RST switch. It should now act as a mouse, and the angle of the board will move the mouse around. Try it out, and see if you can make the mouse stand still!
Press the USR switch to stop the mouse motion.
You’ll note that the y-axis is inverted. That’s easy to fix: just put a
minus sign in front of the y-coordinate in the
hid.send() line above.
8.3. Restoring your pyboard to normal¶
If you leave your pyboard as-is, it’ll behave as a mouse everytime you plug
it in. You probably want to change it back to normal. To do this you need
to first enter safe mode (see above), and then edit the
boot.py file.
In the
boot.py file, comment out (put a # in front of) the line with the
VCP+HID setting, so it looks like:
#pyb.usb_mode('VCP+HID') # act as a serial device and a mouse
Save your file, eject/unmount the drive, and reset the pyboard. It is now back to normal operating mode. | https://docs.micropython.org/en/v1.10/pyboard/tutorial/usb_mouse.html | CC-MAIN-2022-05 | refinedweb | 788 | 75.71 |
Post your Comment
expand the column out line
expand the column out line
...
out line for rows and columns. Finally we expand the column outline.
Code... between + and - linked with state line .Then at last we expand the out
line.
setting out line
for column.
You can create the out line for both rows and columns. The out line...
setting out line
...
out line for rows and columns.
Code description
The package we need
expand the row out line
expand the row out line
...;create
out line for rows and columns. Finally we expand the row outline. ... can create the out line for both rows and columns. The out line is shown
Count number of characters in a column.
Count number of characters in a column. I just need you suggestions. Am from Biology Back ground. I just need to find out number of characters in a column i.e, if i have a file with text in this manner
ACGT
GCTA
GCTA
i need
COMMAND LINE ARGUMENTS
COMMAND LINE ARGUMENTS JAVA PROGRAM TO ACCEPT 5 COMMAND LINE ARGUMENTS AND FIND THE SUM OF THAT FIVE.ALSO FIND OUT LARGEST AMONG THAT 5
Hi Friend,
Try the following code:
import java.util.*;
Jdbc Get Column Names
of method to be carried out in order to get Column
Properties -Importing...
Jdbc Get Column Names
The JDBC Get
Column Names return you the property of the retrieved
Setting the Column Header in JTable
Setting the Column Header in JTable
... the creation of
JTable without column headers. In this example you will learn how to set the column headers in JTable using
JTableHeader. Java provides some
Command Line Arguments in Java
line argument provides an convenient way passage to check out the behaviour...Command Line Arguments in Java
The ongoing Java application can accept any number of arguments from the command line but it is command line argument, which
Setting Grid Line in JTable
Setting Grid Line in JTable
... JTable that contains predefined grid line with black color. But in
this Java programming tutorial, you will learn how to set the colored grid line
in JTable
extracting column and sorting csv data alphabetically
extracting column and sorting csv data alphabetically hi
here... {
String csv = "d:\\country.csv";
String line = "";
String splitby...));
while ((line = br.readLine()) != null) {
String[] country
column matrix
column matrix columan wise total matrix
Blob column
Blob column Hi all...
How to store an excel file in Blob column? I m using oracle 11 g database
line graph
line graph I have developed an application and in that i have to compare 2 reports using line graph from the data taken from ms access database?please help
Draw Line
Draw Line sir i want to draw a moving line in j2me.That line should also show arrow in moving direction. How can we do so
on line exam
on line exam how we can upload the data on the server from any site
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable. ... = new String[allRows.size()];
// Get column names and values...] + ",");
}
}
// Strip out last comma
log out how do i create a log out on a project without it exiting system so it does not reload again
Post your Comment | http://www.roseindia.net/discussion/19889-expand-the-column-out-line.html | CC-MAIN-2015-18 | refinedweb | 554 | 75 |
Bleu#
- class ignite.metrics.Bleu(ngram=4, smooth='no_smooth', output_transform=<function Bleu.<lambda>>, device=device(type='cpu'), average='macro')[source]#
Calculates the BLEU score.
where is the order of n-grams, is a sentence brevety penalty, are positive weights summing to one and are modified n-gram precisions.
More details can be found in Papineni et al. 2002.
In addition, a review of smoothing techniques can be found in Chen et al. 2014
updatemust receive output of the form
(y_pred, y)or
{'y_pred': y_pred, 'y': y}.
y_pred (list(list(str))) - a list of hypotheses sentences.
y (list(list(list(str))) - a corpus of lists of reference sentences w.r.t hypotheses.
Remark :
This implementation is inspired by nltk
- Parameters
ngram (int) – order of n-grams.
smooth (str) – enable smoothing. Valid are
no_smooth,
smooth1,
nltk_smooth2or
smooth2. Default:
no_smooth..
average (str) – specifies which type of averaging to use (macro or micro) for more details refer Default: “macro”
Examples
For more information on how metric works with
Engine, visit Attach Engine API.
from ignite.metrics.nlp import Bleu m = Bleu(ngram=4, smooth="smooth1") y_pred = "the the the the the the the" y = ["the cat is on the mat", "there is a cat on the mat"] m.update(([y_pred.split()], [[_y.split() for _y in y]])) print(m.compute())
tensor(0.0393, dtype=torch.float64)
New in version 0.4.5.
Changed in version 0.4.7:
updatemethod has changed and now works on batch of inputs.
added
averageoption to handle micro and macro averaging modes.
- | https://pytorch.org/ignite/v0.4.9/generated/ignite.metrics.Bleu.html | CC-MAIN-2022-27 | refinedweb | 253 | 60.21 |
# Vue.js Best Practices For Web Development
I am a full-stack developer at [Syncrasy Tech (IT solutions company)](https://syncrasytech.com/). I love writing React codes. But why I am telling you this as we are here to discuss the Vue.js best practices for web development. I am telling you this so that you can understand my background and why I’m discussing here the Vue.js.
I love working on React codes, but I hate reading them. This is the reason where I fail to code. Even with the best code review practices, I can’t figure out the nesting of React components that simply helps to create more complex UI structures in web apps.
The solution to this problem is Vue that is now not so new in the block of web app development. I have heard a lot about Vue async components, server-side rendering, tools, and libraries. Perhaps you find this myriad of terms to be confusing. Believe me, you’re not alone in that, many developers of all levels feel the same way when they don’t know the Vue best practices.
A few days later, I finally decided to get my codes into it. What I am sharing here are the numerous best practices that I have learned through my experience with Vue. I’m ready to share what I’d find.
#### Let’s Start
Try to learn everything at once on Vue can be overwhelming. Let’s start with the numbers. Today Vue has 147K Github’s stars leaving behind the JS giants like Angular (50.6k stars) and React (135k stars).
**I have split Vue’s best practices into four categories:**
**Vue Functionalities**
Vue’s functionalities have a lot of stuff to discuss under the hood automatically. Vue.js is a simple view-oriented platform that is its first main advantage. All information in coding is valid only if it interacts correctly with the named and nested named views.
Creating a single view is pretty simple in Vue, you only have to load the interface and add JavaScript to start the development of your web app.
```
let vm = new Vue({
el: "#my-webapp",
data: {
firstName: "MyFamous",
lastName: "Magazine",
}
})
```
**Then, a bit of markup to get the final view:**
```
Hello, {{firstName}} {{lastName}}!
==================================
```
**What does the above code reveal?**
The above coding example shows how Vue automatically renders elements without using codes. Simple syntax is used to send the data to view directly. Adding instance properties can be used for Vue elements rendering.
Vue systems such as JQuery keep the information in DOM and for all the additional changes developers need to perform rendering and modification of the related parts. Let’s move onto the other parts of Vue functionalities.
**Components**
For web apps, Vue developers can use components just like other libraries by using Vue.compoment. A component can include a name, configuration or identifier.
```
Vue.component('component-name', {
/* options */
})
```
The single-file components work very well for small to medium-sized web development projects. It is pretty easy to use Vue components in a single file and because of the benefits of JavaScript logic, CSS styling, and HTML code template. Also, see an example:
```
{{ hi }}
export default {
data() {
return {
hi: 'Hi Folks!'
}
}
}
p {
color: yellow;
}
```
Vue single file components use WebPack to provide the ability to use and apply modern web features to your web app. Coders can specify a template built using Pug using preprocessors:
TypeScript
SCSS
Sass
Less
PostCSS
Pug
Vue `v-bind` function allows components to accept data from the parent components (Props) that can be seen in the array of strings:
```
props:{
title: String,
likes: Number,
isPublished: Boolean,
commentIds: Array,
author: Object,
callback: Function,
contactsPromise: Promise // or any other constructor
}
```
This will not only document your components but will also warn you when you pass a wrong code type in the browser’s JavaScript console.
In short, Vue offers great flexibility to web app developers that suits different development strategies and also facilitates the interaction with different Vue libraries.
**Events and Handlers to Handle Errors in Vue**Vue JS is a progressive JS framework that focuses on the view layer and a system of supporting libraries. For all stages of web app development that use Vue, events are created on the directives `v-on` and colons that are used to identify the event type such as `v-on` click.
**A simple example of v-on can be this:**
```
Add 1
The button above has been clicked {{ counter }} times.
```
**Some examples of HTML DOM Events in Vue:**
on change
on click
on hover
on load
on mouse-out
on mouse-over
on load
**Event Handlers in Vue JS**
Handlers are assigned to deal with the errors occur in the Events. It allows a developer to write the code when a specified event is triggered.
**Conditional Rendering and Loops in Vue**
Conditional rendering in Vue means to remove or add some elements from the DOM if a specified value is true. This is the best way for conditional data binding that allows developers to connect information when a particular condition is true. You can use `v-if` directive for conditional rendering.
**See an example:**
```
Hello Vuejs
===========
Click
export default{
data:function(){
return{
isActive:false
}
}
}
```
**You can use v-else to extend the v-if directive:**
```
Hello Vuejs
===========
Hey Vuejs
=========
```
**You can extend it further by using v-else-if block:**
```
Hello Vuejs
===========
You're vuejs
============
Hey Vuejs
=========
```
If the value that a programmer wants to evaluate is true, then run the `v-if` template. For further extensions, `v-else` or `v-if-else` directive is triggered.
Vue JS contains a simple API protocol that allows making space for the v-for directive that renders a list of items into the DOM.
**Example:**
```
* {{user.name}}
export default{
data:function(){
return{
users:[
{id:1,name:"samuel"},
{id:2,name:"queen"},
{id:3,name:"rinha"},
]
}
}
}
```
In the above coding, a loop runs through the code in the form of the array using `v-for` directive. The array refers to objects that allow users to see properties present inside the array.
**Output:**
```
samuel
queen
rinha
```
**Two-way data binding to speed up the development process**
One of the main features of Vue is its reactive two-way binding that keeps your data, arrays, and variables in sync with DOM without requiring you to do anything else. Vue uses `v-model` directive for two-way binding. The `v-model` directive binds the input element to the name property using `v-model` directives that update the input field and also updates the name property field linked to it.
**How does it work?**
```
{{name}}
export default{
data:function(){
return{
name:""
}
}
}
{{name}}
export default{
data:function(){
return{
name:""
}
}
}
```
The `v-model` directive comes with the option of `.lazy` modifier that updates the data property after change event occurs.
You can also use `.trim` function to remove the white space from your code.
The option of `.number` modifier is there if you want to accept numbers to the input field.
Finally, these are key strengths of Vue.js that you can use to code your web apps correctly. So, if you are starting out a new web development project, then Vue.js is your choice. It leads the game with its elegant features, style guidelines, easy coding, and also save your efforts. | https://habr.com/ru/post/465409/ | null | null | 1,225 | 62.27 |
Writing Automated Acceptance Tests with Spec Flow
Introduction to Acceptance Testing, Gherkin and Spec Flow
Acceptance or functional testing is a type of testing where a system is tested to see if the required specifications are met. These tests are a type of black-box testing where the internal implementation is irrelevant. The acceptance tests only check to see if the system abides by the specification.
Look at the specification below for a login feature for a website:
Feature: Login
In order to access my account
As a user of the website
I want to log into the website
Scenario: Logging in with valid credentials
Given I am at the login page
When I fill in the following form
| field | value |
| Username | xtrumanx |
| Password | P@55w0Rd |
And I click the login button
Then I should be at the home page
Pretty readable, isn't it? The above specification is written using the Gherkin language. Gherkin is a domain specific language that lets us describe how our applications should behave without having to explain implementation details. Most of the above specification is free-text; there are only a few Gherkin specific keywords: Feature, Scenario, Given, When, And and Then. Everything else is free-text and is practically our documentation of how the feature is used.
Gherkin is a line-oriented language with each line in the scenario called a step. The first step in the "Logging in with valid credentials" scenario is "Given I am at the login page". The step needs a step definition so our test runner will know how to accomplish this step. A step definition in Spec Flow is simply a method with an attribute that contains the text of the step. All step definition methods need to be within a class that has a Binding attribute.
[Binding]
class LoginStepDefinitions
{
[Given("I am at the login page")]
public void GivenIAmAtTheLoginPage()
{
// TODO
}
}
The above class and method names are arbritrary. What's important are the attributes applied to the class and method. Without them, Spec Flow can't figure out which step definition methods should be bound to which steps.
All that's left is the step definition implementation. That's where WatiN and NUnit come into the picture.
WatiN is a browser automation tool. We're going to be using it to open an instance of IE, navigate to URLs, fill forms, click buttons or links, etc. We'll be using NUnit to assert our expectations. WatiN and NUnit are not compulsory; you could use Selenium for browser automation and virtually any unit testing framework for your assertion. You could even use Windows application automation library, like White, and write automated acceptance tests for your Windows Forms or WPF applications.
Let's try building an actual acceptance test for an actual application. For this article, we'll be using this sample application. Grab a copy of the application repository here. The repository also contains the completed acceptance test project, though I'd suggest creating your own acceptance test code by following along with the rest of this article.
Prerequisites
Spec Flow delegates the heavy lifting of actually running the acceptance tests to any of the supported 3rd party test runners. As mentioned earlier, we'll be using NUnit to run our tests and WatiN to automate our browser. Here's an example (from the WatiN website) on how you can use WatiN to automate the browser to perform a google search for WatiN.
[Test]
public void SearchForWatiNOnGoogle()
{
using (var browser = new IE(""))
{
browser.TextField(Find.ByName("q")).TypeText("WatiN");
browser.Button(Find.ByName("btnG")).Click();
Assert.IsTrue(browser.ContainsText("WatiN"));
}
}
The test above creates a new instance of IE and passes Google's URL to the constructor which will make the browser go to Google. Then a text field with the name of 'q' is searched for. That text field happens to be the one you type your search query into. The text field that is found then has the word 'WatiN' typed into it. Next, a button with the name of 'btnG' is searched for and is clicked. Finally, an assert is made to confirm that the text 'WatiN' exists (anywhere) on the page.
The above code gives a glimpse on how easy it is to automate WatiN to do regular tasks you'd want to perform on the browser window like filling in textboxes and pressing buttons.
Next, go ahead and create a new class library project in Visual Studio for your acceptance tests. You'll need to add the necessary DLLs to your acceptance tests project once you've downloaded NUnit and WatiN. Add a reference to nunit.framework.dll from your NUnit download to your acceptance tests project. For WatiN, you'll need to add references to two DLLs into your acceptance tests project; Interop.SHDocVw.dll and WatiN.Core.dll.
I should mention you could get both projects via NuGet. They're both easily discoverable via NuGet which will automatically add them to your project so if you already use NuGet in your projects, you might as well use it to download NUnit and WatiN.
Grab a copy of Spec Flow and install it into your system. Unlike NUnit and WatiN, you'll need to install Spec Flow rather than simply copy DLLs onto your system. Spec Flow comes with some tooling and whenever you add a feature file to your project it creates a code-behind file for it. Plus there's some syntax highlighting and other tweaks available when editing your feature files.
After successfully installing Spec Flow, check out the installation directory (defaulting to the Program Files). There's a bunch of DLLs within but only one needs to be added to your project as a reference; TechTalk.SpecFlow.dll.
Setting Up Your Acceptance Tests Project
Before we dive into writing our acceptance tests, we're going to need to setup our acceptance tests project. Within the project we're going to add a few folders just to keep things organized.
- Features
- This is where we'll be keeping all our specifications.
- StepDefinitions
- The step definitions for our scenario steps will be placed here.
- StepHelpers
- All helper classes will be added here.
Creating a Spec Flow feature file
Add a new Spec Flow feature file named Login.feature into the Features folder. It's going to come with the specification for an Addition feature with one scenario. Remove all of it and add the following text into our Login feature.
Feature: Login
Feature is a keyword in Gherkin. It should appear once in every feature file. It is followed by a colon and the title of the feature. You can then use any number of lines of free-text to describe the feature. To keep things simple, Gherkin's creators recommended keeping your documentation short and to follow the following format:
In order to realize a named business value
As an explicit system actor
I want to gain some beneficial outcome which furthers the goal
Personally, I tend to skip the above description for self-descriptive features like the Login feature we're working on it can get confusing trying to write your description to fit the specified format; sometimes it isn’t clear what the difference is between the "named business value" in the first line and the "beneficial outcome" you’re supposed to write in the third line. Remember, it's all free-text and you can write it however you want to. Let's skip it for now and write our scenario.
Feature: Login
Scenario: Logging in with valid credentials
Like Feature, Scenario is a Gherkin keyword and is followed by a colon and the title of the scenario. Unlike a feature, a scenario isn't complete in just one line but must be followed up with the steps needed to complete the scenario. Let's think it through; what do we need to do to successfully login with valid credentials?
- Fill in the login form
- Click the login button
But hold on, before we can fill in the login form, we need to be at the page the login form is presented. Afterwards, we're going to have to check that we've successfully logged in. Let's assume that if we've been redirected to the home page after logging in, that means we've been successfully logged in.
Now we have a pre-condition for our scenario (i.e. we must be at the login page) and a post-condition (i.e. we're at the home page). In Gherkin, pre-conditions should start with the keyword Given and post-conditions should start with the keyword When.
Feature: Login
Scenario: Logging in with valid credentials
Given I am at the 'Login' page
When I fill in the following form
| field | value |
| Username | testuser |
| Password | testpass |
And I click the 'Login' button
Then I should be at the 'Home' page
Notice the table-like structure. Spec Flow will automatically italicize the first row in a pipe-delimited line that begins with a pipe. That first row is considered the header of the table. Each column in subsequent rows is referred to by whatever text was used in the header row. For instance, the text Password is in the field column of the second row and the text testuser is in the value column of the first row.
Also, notice the step that begins with the word And. The And keyword can be used after any step and will automatically be assumed to be of the same type of the previous step. An And step that follows a Given step is also considered a Given step. In the above example, our And step is considered a When step. When steps are not to be used for pre or post conditions but for the actual steps needed to run the scenario.
Create your first step definition
Right now we've got our specification for our Login feature complete but our test runner has no idea on how execute each step in our feature's scenario. We'll need to define the step definitions for each of our 4 steps in our Login feature's scenario. To do so, we're going to create a class within the Steps directory. We're call this class LoginSteps. To let Spec Flow know that this class contains step definitions, we're going to apply the Binding attribute to the class. The Binding attribute is part of the TechTalk.SpecFlow namespace.
using TechTalk.SpecFlow;
[Binding]
class LoginSteps
{
}
Next, we'll need to make a method for each of our steps. This method will let Spec Flow know how to execute each of our steps. For now, we'll just be providing a Step Definition for our first step, "Given I am at the 'Login' page"
[Given("I am at the 'Login' page")
public void GivenIAmAtTheLoginPage()
{
// TODO
}
Notice the method has an attribute applied to it. This attribute lets Spec Flow know this method maps to the step that matches the attribute. Any step in any feature file beginning with the Given keyword and is followed by the text "I am at the 'Login' page" is going to be mapped to this method.
Now we need to write the implementation for this step definition. What we need to do is to tell WatiN to startup the browser and visit our app's login page. Before we do so, we're going to need to create an instance of a browser. We're also going to need to make sure the same instance of the browser is used for all the remaining steps in our scenario. To make sure we use the one browser instance for all our scenario's steps, we're going to create an instance of a browser object and store it in the ScenarioContext dictionary. The ScenarioContext dictionary can be used to store data during the execution of a Scenario. We're going to create a helper class called WebBrowser which will hold the browser instance that will be used during the execution of the scenario.
using TechTalk.SpecFlow;
using WatiN.Core;
static class WebBrowser
{
public static IE Current
{
get
{
if(!ScenarioContext.Current.ContainsKey("browser"))
ScenarioContext.Current["browser"] = new IE();
return ScenarioContext.Current["browser"] as IE;
}
}
}
Our helper class above has a Current property which fetches the current browser for the currently executing scenario. If it doesn't find a browser instance contained in the ScenarioContext dictionary, it creates a new browser instance and adds it to the dictionary. Afterwards, the browser instance contained in the dictionary is returned.
Finally, we can go back and implement our step definition. In our example application, the login page is located at. We're going to implement our step definition by making our current scenario's browser instance navigate to that URL. We could implement our step definition by making our browser instance go to the home page and click the login link but this seems simplest for now. Later on, we're going to refactor our step definitions so we can have one step definition handle navigation to any page of our application.
[Given("I am at the 'Login' page")
public void GivenIAmAtTheLoginPage()
{
// Make sure to add the namespace the WebBrowser class is inside
WebBrowser.Current.GoTo("");
}
Loose Ends
We're now ready to attempt to run our acceptance test. We've yet to complete all the step definitions but we want to make sure we've got everything wired up correctly before carrying on. Before running the test, make sure you've got all the assemblies we've added to our project set to Copy Local. The Interop.SHDocVw DLL will have its Embed Interop property set to true if you've added WatiN via NuGet so make sure you set the Embed Interop property to false so you can set its Copy Local property to true.
We'll also need to make NUnit run in a single-threaded apartment state otherwise we won't be able to automate Internet Explorer. We're using IE instead of Firefox because Firefox's constant major version changes keeps breaking WatiN's Firefox hook.
Setting NUnit's apartment state will require the use of a configuration file. Add an app.config file to the project and add the following configuration>
Run Your Acceptance Test
Your Login.feature file has a code-behind file called Login.feature.cs (or .vb). That file contains the class with the TestFixture attribute required so NUnit can figure out which class to test. If you've got NUnit test runner plug-in installed in Visual Studio, like TestDriven.Net or ReSharper, Login.feature.cs is the file you're going to ask it to run the tests for. If you don't have a test runner plugin that can do so, open the test runner that comes with the NUnit installation located in your programs menu and point it to the assembly generated by our acceptance test project and it'll locate the test fixture located within Login.feature.cs
Make sure the application's server is up and running then run your tests. A new instance of IE should open up and navigate to the login page. If it does, everything is wired up correctly and we can move on to completing the rest of our step definitions. If IE didn’t open up and navigate to the login page, it's time to roll up your sleeves and debug.
Complete the rest of your step definitions
Writing the rest of the step definitions is going to be simple. You'll need to know a thing or two about the WatiN API so you can figure out how to tell WatiN to fill a form or how to find a button or link and click it.
First, let's try doing the second step in our scenario, "When I fill in the following Form". You'll need to create a method in your LoginSteps class and given it an attribute to bind it to the step we're currently working on.
[When("I fill in the following form")]
public void WhenIFillInTheFollowingForm(TechTalk.SpecFlow.Table table)
{
// TODO
}
Notice the parameter we passed into this step definition. This Table object will contain the values we've writtern in our scenario file. WatiN also has a Table class in its namespace so to avoid conflict I've used the fully qualified name for this Table. The Table object will be made up of rows. Each column in the row can be accessed by index or column name. Our column names are defined by the first row of the table within the scenario file.
[When("I fill in the following form")]
public void WhenIFillInTheFollowingForm(TechTalk.SpecFlow.Table table)
{
foreach(var row in table.Rows)
{
var textField = WebBrowser.Current.TextField(Find.ByName(row["field"]));
if(!textField.Exists)
Assert.Fail("Expected to find a text field with the name of '{0}'.", row["field"]);
textField.TypeText(row["value"]);
}
}
That's it. In 5 lines of code, we've written our step definition for filling out a web form. We first loop through the rows within the table; then we attempt to find text fields with a name attribute matching the current row's field column value. If we don't find a matching text field, we fail the test explicitly (and leave a helpful message for ourselves). If we do find a matching text field, we instruct WatiN to type in the text we find in the current row's value column.
The rest of our step definitions will be written similarly. Here's the code for our next step, "And I click the 'Login' button".
[When("I click the 'Login' button")]
public void AndIClickTheLoginButton()
{
var loginButton = WebBrowser.Current.Button(Find.ByValue("Login"));
if(!loginButton.Exists)
Assert.Fail("Expected to find a button with the value of 'Login'.");
loginButton.Click();
}
For our last step, we need to figure out how to test if we are at the home page. We could inspect the document's title and see if it matches our expected title. Or perhaps we can inspect the URL and see if it matches the expected URL for the homepage. We'll inspect the URL, but keep in mind the implementation of our step definitions can depend entirely on our application. If we're making heavy use of Ajax to navigate around pages, the URL may not be updated and thus may not be useful to confirm if we are in fact on the correct page.
[Then("I should be at the 'Home' page")]
public void ThenIShouldBeAtTheHomePage()
{
var expectedURL = "";
var actualURL = WebBrowser.Current.Url;
Assert.AreEqual(expectedURL, actualURL);
}
Run your acceptance test again and this time it should run to completion. If it did, congratulations; you've written and successfully passed your first acceptance test using Spec Flow.
Refactor Your Test Code
Now that we have our step definitions working, let's take a moment and review them. We've got a step definition for clicking a login button. We're probably going to have a ton of other buttons in our applications. Are we going to have step definitions for every button involved in our acceptance test suite? The only thing that will be changing for each of those step definitions will be the text that WatiN will search for when finding the expected button on the page. Here's an example:
[When("I click the 'Login' button")]
public void AndIClickTheLoginButton()
{
var loginButton = WebBrowser.Current.Button(Find.ByValue("Login"));
if(!loginButton.Exists)
Assert.Fail("Expected to find a button with the value of 'Login'.");
loginButton.Click();
}
[When("I click the 'Register' button")]
public void AndIClickTheRegisterButton()
{
var registerButton = WebBrowser.Current.Button(Find.ByValue("Register"));
if(!registerButton.Exists)
Assert.Fail("Expected to find a button with the value of 'Register'.");
registerButton.Click();
}
Luckily, Spec Flow has a way to avoid this problem. You can use regular expressions within the string passed to the binding attribute so you can have different steps bound to the same step definition. Any text captured by the regular expression can then be passed to the step definition method as a parameter. Here's an example:
[When("I click the '(.*)' button")]
public void AndIClickAButton(string buttonText)
{
var button = WebBrowser.Current.Button(Find.ByValue(buttonText));
if(!button.Exists)
Assert.Fail("Expected to find a button with the value of '{0}'.", buttonText);
button.Click();
}
The above step definition will match any of the following steps:
- And I click the 'Login' button
- And I click the 'Register' button
- And I click the 'Some Arbitrary Text' button
You can use this technique to make all your step definitions reusable. It is a good idea to make all your step definitions reusable and you should try to avoid writing step definitions tied only to one specific scenario. This will allow you to write scenarios that work immediately as you would have a reusable step definition already available. Don't try getting ahead of yourself and writing reusable step definitions before you need them though. Just write them when you need them. For the most part, your tests will be doing pretty much the same thing; navigating to a page, filling out a form, clicking something, etc. You'll rarely need to write a specific step definition for a scenario unless you testing something out of the ordinary like checking if the jQuery UI calendar popped up after click a textbox that needed a date value.
I'll leave it as an exercise to you to refactor your step definitions so each of them is reusable. After doing so, you could write a new feature file navigate to a link and submits a form that would just work immediately since the step definitions needed are already prepared. Of course, you're probably going to need more step definitions to automate different actions (like clicking a link) and you may need to refine your current step definitions to make them work in different scenarios. You'll notice our form filling step definition only handles filling a form with textboxes. If you want to tick checkboxes, find buttons by their value or by ID, or do other form related actions, you'll need to add the relevant logic to the form filling step definition.
Conclusion
Well, that's it for this tour of writing acceptance tests using Spec Flow. There's more to discover on your own, however. For instance, Spec Flow also has a tagging mechanism so you can tag a specific feature to run some code before or after a specific feature, scenario or step. This is useful if you want to logout after completing a scenario involving login, priming the database before the tests or simply want to close the browser window after each test completes.
As you create more tests, you'll notice the amount of time it takes to complete your acceptance test suite increases. The quicker your tests run, the faster you can get feedback and find bugs. You want your tests to run as fast as possible. One approach you can take is to parallelize your tests so instead of running sequentially, they run simultaneously and finish sooner. Spec Flow doesn't come with parallelization functionality so you'll have to look elsewhere. If you're using NUnit, you may want to look into PNUnit for your parallelization needs.
Gherkin, the DSL used to write our specifications, was designed to bridge the gap between your technical and non-technical stakeholders so they are able to come to an agreement on how a particular feature should work. Some have gone as far as to get their non-technical stakeholders to write the actual specification using the Given-When-Then syntax. As you can imagine, it wouldn't be that hard to train folks to do so, but your mileage may vary.
Others have taken their use of Spec Flow further. They start all new feature development by writing the specification first, then move on to their unit tests, and finally the actual code. They then work through the usual TDD red-green-refactor cycle until their unit tests pass and finally their acceptance tests pass. If you're already practicing TDD, you should give Acceptance Test Driven Development a go if you are planning to write acceptance tests for your project.
Whichever path you take, make sure it works for you and your project. If you're prototyping and constantly changing how your application works, keeping your acceptance test updated may hold you back. It's up to you to decide when the right time to write your acceptance tests; just don't let it be never..
Missing the point
by
Dennis Doomen
Re: Missing the point
by
Dzmitry Lahoda
Feature: Login
In order to access my account
As a user of the application
I want to login into the application
Scenario: Login with valid credentials
Given I am going to login
When I input "xtrumanx" user name
And I input "P@55w0Rd" password
And I click the login button
Then I should be at login state
No website or home page, application and some evidence of login state.
I applied SpecFlow to Component tests. Seems these either should be written around functional provided without mentioning concrete interfaces or current implementation.
Re: Missing the point
by
Edwin McConnel
Otherwise, I agree that the spec should be oriented around the functional, use case scenario. That way SpecFlow is useful to drive the implementation of the domain, and ensure it's validity before bringing the delivery mechanism into the mix. Later on, the the specs can be re-purposed with a new driver layer to test against the delivery mechanism (web or otherwise) for valuable acceptance/regression testing.
But let's face it (I know I'm cynical, but its from experience), most developers wouldn't know how to begin a project without firing up a web app first and then hacking out an UI. So including WaTiN early in the process will appeal to a large audience (that would have difficulty thinking about a "login" process outside of a web context).
SpecFlow Resources
by
Jason Roberts
Gherkin Cheat Sheet: bit.ly/gherkincheat
SpecFlow Cheat Sheet: bit.ly/specflowcheat
Automated Acceptance Testing with SpecFlow and Gherkin course: bit.ly/psspecflow
SpecFlow Tips and Trick course: bit.ly/psspecflowtips | http://www.infoq.com/articles/Spec-Flow/ | CC-MAIN-2014-42 | refinedweb | 4,396 | 61.67 |
Introduction
"With Great Power Comes Great Responsibility." -- Spider Man's Uncle
This document is a tutorial about Nim's macro system. A macro is a function that is executed at compile-time and transforms a Nim syntax tree into a different tree.
Examples of things that can be implemented in macros:
- An assert macro that prints both sides of a comparison operator, if the assertion fails. myAssert(a == b) is converted to if a != b: quit($a " != " $b)
- A debug macro that prints the value and the name of the symbol. myDebugEcho(a) is converted to echo "a: ", a
- Symbolic differentiation of an expression. diff(a*pow(x,3) + b*pow(x,2) + c*x + d, x) is converted to 3*a*pow(x,2) + 2*b*x + c
Macro Arguments
The types of macro arguments have two faces. One face is used for the overload resolution and the other face is used within the macro body. For example, if macro foo(arg: int) is called in an expression foo(x), x has to be of a type compatible to int, but within the macro's body arg has the type NimNode, not int! Why it is done this way will become obvious later, when we have seen concrete examples.
There are two ways to pass arguments to a macro, an argument can be either typed or untyped.
Untyped Arguments
Untyped macro arguments are passed to the macro before they are semantically checked. This means the syntax tree that is passed down to the macro does not need to make sense for Nim yet, the only limitation is that it needs to be parsable. Usually, the macro does not check the argument either but uses it in the transformation's result somehow. The result of a macro expansion is always checked by the compiler, so apart from weird error messages, nothing bad can happen.
The downside for an untyped argument is that these do not play well with Nim's overloading resolution.
The upside for untyped arguments is that the syntax tree is quite predictable and less complex compared to its typed counterpart.
Typed Arguments
For typed arguments, the semantic checker runs on the argument and does transformations on it, before it is passed to the macro. Here identifier nodes are resolved as symbols, implicit type conversions are visible in the tree as calls, templates are expanded, and probably most importantly, nodes have type information. Typed arguments can have the type typed in the arguments list. But all other types, such as int, float or MyObjectType are typed arguments as well, and they are passed to the macro as a syntax tree.
Static Arguments
Static arguments are a way to pass values as values and not as syntax tree nodes to a macro. For example for macro foo(arg: static[int]) in the expression foo(x), x needs to be an integer constant, but in the macro body arg is just like a normal parameter of type int.
import std/macros macro myMacro(arg: static[int]): untyped = echo arg # just an int (7), not `NimNode` myMacro(1 + 2 * 3)
Code Blocks as Arguments
It is possible to pass the last argument of a call expression in a separate code block with indentation. For example, the following code example is a valid (but not a recommended) way to call echo:
echo "Hello ": let a = "Wor" let b = "ld!" a & b
For macros this way of calling is very useful; syntax trees of arbitrary complexity can be passed to macros with this notation.
The Syntax Tree
In order to build a Nim syntax tree one needs to know how Nim source code is represented as a syntax tree, and how such a tree needs to look like so that the Nim compiler will understand it. The nodes of the Nim syntax tree are documented in the macros module. But a more interactive way to explore the Nim syntax tree is with macros.treeRepr, it converts a syntax tree into a multi-line string for printing on the console. It can be used to explore how the argument expressions are represented in tree form and for debug printing of generated syntax tree. dumpTree is a predefined macro that just prints its argument in a tree representation, but does nothing else. Here is an example of such a tree representation:
dumpTree: var mt: MyType = MyType(a:123.456, b:"abcdef") # output: # StmtList # VarSection # IdentDefs # Ident "mt" # Ident "MyType" # ObjConstr # Ident "MyType" # ExprColonExpr # Ident "a" # FloatLit 123.456 # ExprColonExpr # Ident "b" # StrLit "abcdef"
Custom Semantic Checking
The first thing that a macro should do with its arguments is to check if the argument is in the correct form. Not every type of wrong input needs to be caught here, but anything that could cause a crash during macro evaluation should be caught and create a nice error message. macros.expectKind and macros.expectLen are a good start. If the checks need to be more complex, arbitrary error messages can be created with the macros.error proc.
macro myAssert(arg: untyped): untyped = arg.expectKind nnkInfix
Generating Code
There are two ways to generate the code. Either by creating the syntax tree with expressions that contain a lot of calls to newTree and newLit, or with quote do: expressions. The first option offers the best low-level control for the syntax tree generation, but the second option is much less verbose. If you choose to create the syntax tree with calls to newTree and newLit the macro macros.dumpAstGen can help you with the verbosity.
quote do: allows you to write the code that you want to generate literally. Backticks are used to insert code from NimNode symbols into the generated expression.
macro a(i) = quote do: let `i` = 0 a b
A custom prefix operator can be defined whenever backticks are needed.
macro a(i) = quote("@") do: assert @i == 0 let b = 0 a b
The injected symbol needs accent quoted when it resolves to a symbol.
macro a(i) = quote("@") do: let `@i` == 0 a b
Make sure to inject only symbols of type NimNode into the generated syntax tree. You can use newLit to convert arbitrary values into expressions trees of type NimNode so that it is safe to inject them into the tree.
import std/macros type MyType = object a: float b: string macro myMacro(arg: untyped): untyped = var mt: MyType = MyType(a:123.456, b:"abcdef") # ... let mtLit = newLit(mt) result = quote do: echo `arg` echo `mtLit` myMacro("Hallo")
The call to myMacro will generate the following code:
echo "Hallo" echo MyType(a: 123.456'f64, b: "abcdef")
Building Your First Macro
To give a starting point to writing macros we will show now how to implement the myDebug macro mentioned earlier. The first thing to do is to build a simple example of the macro usage, and then just print the argument. This way it is possible to get an idea of what a correct argument should look like.
import std/macros macro myAssert(arg: untyped): untyped = echo arg.treeRepr let a = 1 let b = 2 myAssert(a != b)
Infix Ident "!=" Ident "a" Ident "b"
From the output, it is possible to see that the argument is an infix operator (node kind is "Infix"), as well as that the two operands are at index 1 and 2. With this information, the actual macro can be written.
import std/macros macro myAssert(arg: untyped): untyped = # all node kind identifiers are prefixed with "nnk" arg.expectKind nnkInfix arg.expectLen 3 # operator as string literal let op = newLit(" " & arg[0].repr & " ") let lhs = arg[1] let rhs = arg[2] result = quote do: if not `arg`: raise newException(AssertionDefect,$`lhs` & `op` & $`rhs`) let a = 1 let b = 2 myAssert(a != b) myAssert(a == b)
This is the code that will be generated. To debug what the macro actually generated, the statement echo result.repr can be used, in the last line of the macro. It is also the statement that has been used to get this output.
if not (a != b): raise newException(AssertionDefect, $a & " != " & $b)
With Power Comes Responsibility
Macros are very powerful. A piece of good advice is to use them as little as possible, but as much as necessary. Macros can change the semantics of expressions, making the code incomprehensible for anybody who does not know exactly what the macro does with it. So whenever a macro is not necessary and the same logic can be implemented using templates or generics, it is probably better not to use a macro. And when a macro is used for something, the macro should better have a well-written documentation. For all the people who claim to write only perfectly self-explanatory code: when it comes to macros, the implementation is not enough for documentation.
Limitations
Since macros are evaluated in the compiler in the NimVM, macros share all the limitations of the NimVM. They have to be implemented in pure Nim code. Macros can start external processes on the shell, but they cannot call C functions except those that are built in the compiler.
More Examples
This tutorial can only cover the basics of the macro system. There are macros out there that could be an inspiration for you of what is possible with it.
Strformat
In the Nim standard library, the strformat library provides a macro that parses a string literal at compile time. Parsing a string in a macro like here is generally not recommended. The parsed AST cannot have type information, and parsing implemented on the VM is generally not very fast. Working on AST nodes is almost always the recommended way. But still strformat is a good example for a practical use case for a macro that is slightly more complex than the assert macro.
Ast Pattern Matching
Ast Pattern Matching is a macro library to aid in writing complex macros. This can be seen as a good example of how to repurpose the Nim syntax tree with new semantics.
OpenGL Sandbox
This project has a working Nim to GLSL compiler written entirely in macros. It scans recursively through all used function symbols to compile them so that cross library functions can be executed on the GPU. | https://nim-lang.github.io/Nim/tut3.html | CC-MAIN-2021-39 | refinedweb | 1,707 | 61.97 |
Michael Langford wrote: > for subscript,line in enumerate(file("file.csv")): > s = line.split(",")[1] > try: > f = float(s) > locals()["x%i" % subscript]=f > except: > locals()["x%i" % subscript]=s Don't do this! For one thing, writing to locals() doesn't always work. Specifically, writing to locals() inside a function does *not* affect the local namespace: In [28]: def foo(): ....: locals()['x'] = 1 ....: print x ....: ....: In [29]: foo() ------------------------------------------------------------ Traceback (most recent call last): File "<ipython console>", line 1, in <module> File "<ipython console>", line 3, in foo <type 'exceptions.NameError'>: global name 'x' is not defined Writing to globals() might be marginally better but not much. (When not in a function, locals() is actually the same as globals() and the above code will work.) In most cases where someone is trying to assign a bunch of names like this, a better solution is to use a dictionary (or possibly a list) to hold the data. Kent | https://mail.python.org/pipermail/tutor/2008-January/059627.html | CC-MAIN-2016-50 | refinedweb | 157 | 64.1 |
Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
You can subscribe to this list here.
Showing
2
results of 2
Ray Phillips wrote:
> I thought I'd report the result when I tried to install smartmontools
> 5.39.1 on a NetBSD/i386 5.0.1 machine from source code. configure
> seemed to complete without problems but make failed:
>
>
>
Could not reproduce this with a fresh install of NetBSD/i386 5.0.2.
There is only an unrelated problem in the build rule for the man pages
when BSD make instead of GNU make is used (Now fixed on trunk).
> ...
> %
> % cat make.log
> make all-recursive
> Making all in .
> ...
> g++ -DHAVE_CONFIG_H -I. - -DSMARTMONTOOLS_SYSCONFDIR='"/usr/local/etc"' -g -O2 -Wall -W
> -fno-strict-aliasing -MT os_netbsd.o -MD -MP -MF .deps/os_netbsd.Tpo
> -c -o os_netbsd.o os_netbsd.cpp
> /usr/include/prop/prop_object.h:60: error: expected unqualified-id
> before '/' token
> ...
> /usr/include/prop/prop_ingest.h:85: error: expected unqualified-id
> before '/' token
> /usr/include/sys/device.h:143: error: expected unqualified-id before '/' token
> ...
>
The syntax error is reported from the system include sys/device.h which
is the first file included by os_freebsd.h. Are one of these system
includes probably broken?
Could you please try to compile a source which only contains:
#include <sys/device.h>
Thanks,
Christian
On Tue, 16 Feb 2010 20:41:22 +0100
Christian Franke <Christian.Franke@...> wrote:
> Smartctl provides also limited functionality (-c, -i without serno, -A
> without thresholds) for normal users through two I/O controls which do
> not require admin rights.
Yes, I have that problem with GSmartControl too (it does provide some
non-admin functionality, albeit very limited).
> Running with elevated privileges through UAC unfortunately does not work
> like e.g. running a setuid program would work.
>
> At least on Vista, a "requireAdministrator" level in a smartctl manifest
> effectivly prevents interactive use from both normal and admin user's
> console. After the UAC confirmation prompt, smartctl is started within a
> new console with new cwd, new environment and stdio not inherited. Then
> smartctl output is invisible and cannot be redirected.
>
> It only works if console is itself started with full admin rights.
> Without a manifest, it works in all cases on Vista.
Seems to be the case under win7 too (I just tested it). I should have tested
this before writing the original e-mail, sorry. :)
> > Windows 7 changed the default behaviour of "unmanifested"
> > executables. Vista would just run them in compatibility mode,
> > effectively giving them administrative rights. Windows 7, on
> > the other hand, runs them in "user" mode (even if the logged
> > in user is the administrator), denying them access to system
> > resources.
>
> Is this also true if smartctl is run from cmd.exe (or gsmartcontrol.exe)
> which is explicitly started with full admin rights?
> In this case it may help to add a manifest which requests the default
> "asInvoker" level to prevent this behaviour.
It seems that when running from an admin-launched program
(gsmartcontrol with admin rights, or cmd), smartctl inherits its
permissions, so no problem there. Additional manifest doesn't
seem to be required (or used, in terms of UAC).
> Unfortunately I don't have a Win 7 for testing.
>
> For testing on Vista, I also successfully used external manifest files,
> see attachment. This may also work on Win 7 if the .exe itself doesn't
> contain a manifest. If this is the case, external manifests may be a
> more flexible alternative.
MS documentation was really unclear about those, and it appeared
that they didn't work when I tested them.
Now that I tested them again, turns out Windows caches
them in a way that the edits (and even creating / removing them)
don't get picked up by the system unless you rename the whole
directory or reboot a computer. So I kind of missed the whole feature
when I wrote the first e-mail.
To summarize the problems of the smartmontools distribution when
running under win7, they are:
* The drive right-click commands don't work (permission denied).
* The items in start menu don't work (permission denied).
An external manifest (with admin requirements) should fix all that.
But it introduces these problems:
* Vista users won't be able to run it in non-admin cmd window (not sure about this).
* Regular users won't be able to use non-admin functionality.
Having two exe files (one with manifest, one not) is probably an overkill, I guess.
Maybe some kind of a wrapper (like runas command) should be used?
Thanks,
Alexander | http://sourceforge.net/p/smartmontools/mailman/smartmontools-support/?viewmonth=201002&viewday=18&style=flat | CC-MAIN-2015-14 | refinedweb | 769 | 58.58 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.