jqGrid doesn't have very good documentation. You have to get everything from the demos, but the actual demo files are hidden in ajax code. This file is the data file used to build the demo navigation menu on the left. It has the name of the individual demo .html files along with the visible text. There is a corresponding .js file for each demo. All the files are in the http://trirand.com/blog/jqgrid/ directory.
Example: http://trirand.com/blog/jqgrid/searching.html http://trirand.com/blog/jqgrid/searching.js
The first thing I did was create a "gvoice.py" module with several helpful classes. These allow you to:I am by no means a seasoned Python developer, but what I have created works well for my purposes. I tried to make the classes as loosely coupled with the UI as possible in case I want to put a GUI around it sometime, but for now I am doing everything at the command line (which I often prefer).
- Log in
- Gather all Google Contacts into separate groups
- Selectively narrow down the contacts in a group
- Gather the phone numbers that you have entered
- Send SMS messages
- Place Calls
# Server program from socket import * # Set the socket parameters host = "localhost" port = 21567 buf = 1024 addr = (host,port) # Create socket and bind to address UDPSock = socket(AF_INET,SOCK_DGRAM) UDPSock.bind(addr) # Receive messages while 1: data,addr = UDPSock.recvfrom(buf) if not data: print "Client has exited!" break else: print "nReceived message '", data,"'" # Close socket UDPSock.close()
# Client program
from socket import *
# Set the socket parameters
host = "localhost"
port = 21567
buf = 1024
addr = (host,port)
# Create socket
UDPSock = socket(AF_INET,SOCK_DGRAM)
def_msg = "===Enter message to send to server===";
print "n",def_msg
# Send messages
while (1):
data = raw_input('>> ')
if not data:
break
else:
if(UDPSock.sendto(data,addr)):
print "Sending message '",data,"'....."
# Close socket
UDPSock.close()
/*send the packet*/
send_result = sendto(s, buffer, ETH_FRAME_LEN, 0,
(struct sockaddr*)&socket_address, sizeof(socket_address));
if (send_result == -1) { errorhandling... }
Example 1.6. Receive a RAW ethernet frame
void* buffer = (void*)malloc(ETH_FRAME_LEN); /*Buffer for ethernet frame*/
int length = 0; /*length of the received frame*/
...
length = recvfrom(s, buffer, ETH_FRAME_LEN, 0, NULL, NULL);
if (length == -1) { errorhandling .... }
* is Unix
Jacob Kaplan-Moss
October 7, 2009
via http://twitter.com/programmingjoy Javascript as Compiler Target: Clamato, GWT Smalltalk, Python, Scheme http://www.infoq.com/news/2009/09/javascript-compilation-target (require moby/stub/world) (define WIDTH 320) (define HEIGHT 480) (define (render w) (place-image (text "Hello World" 10 "Black") 20 20 (empty-scene WIDTH HEIGHT))) (big-bang WIDTH HEIGHT 10 0) (on-redraw render)
After a few minutes of poking around, I was able to compile this to Java and then run it on the Android Emulator:
//dirt cheap wireless TX
//generates 38kHz carrier wave on pin 9 and 10
//sends data via TX every 500ms
void setup()
{
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
// Clear Timer on Compare Match (CTC) Mode
bitWrite(TCCR1A, WGM10, 0);
bitWrite(TCCR1A, WGM11, 0);
bitWrite(TCCR1B, WGM12, 1);
bitWrite(TCCR1B, WGM13, 0);
// Toggle OC1A and OC1B on Compare Match.
bitWrite(TCCR1A, COM1A0, 1);
bitWrite(TCCR1A, COM1A1, 0);
bitWrite(TCCR1A, COM1B0, 1);
bitWrite(TCCR1A, COM1B1, 0);
// No prescaling
bitWrite(TCCR1B, CS10, 1);
bitWrite(TCCR1B, CS11, 0);
bitWrite(TCCR1B, CS12, 0);
OCR1A = 210;
OCR1B = 210;
Serial.begin(2400);
}
void loop()
{
Serial.println("testing testing testing");
delay(500);
}
To decode what the remote was sending, I used an oscilloscope and a small photodiode. The photodiode generates a small amount of voltage when light hits it, and responds to changes in light level quickly enough that the oscilloscope can draw a really nice plot of the signal. I have a Parallax USB oscilloscope, which is perfect for showing the command pulses and is just fast enough to find the modulation frequency. As an aside, I’m really happy with the Parallax oscilloscope for projects like this. It is simple to use and I love being able to save images to share with people.
Here’s what two of the commands from the dimmer remote look like. The top signal is the “fade lights up” command, and the bottom one is “fade lights down”:
![]()
I'm working on a project that uses data in JSON format (www.json.org). It took me a while to get it going in processing, so I thought I'd post what I did here. If there's a better way (which undoubtedly there is!), please let me know.
Andrew Odewahn
--
Here are the steps I took (on Windows):
1. Download http://www.json.org/java/json.zip from json.org. Save it in a some directory, which I'll call %DOWNLOAD_HOME%.
2. Unzip it. Be sure you preserve the archive's directory structure (/org/json/) when you unzip the file.
3. Change directory into %DOWNLOAD_HOME%orgjson
Left to right: John Maloney (MIT/Scratch), Golan Levin (CMU), Tom McMail (Microsoft Research), Ira Greenberg (Miami U. Ohio), Hans-Christoph Steiner (NYU/ Pure Data), Evelyn Eastmond (MIT/Scratch), Casey Reas (UCLA/Processing), Zachary Lieberman (Parsons/openFrameworks), Theodore Watson (openFrameworks), Ben Fry (Seed Visualization Lab/Processing), Arturo Castro (openFrameworks), Sebastian Oschatz (Meso/VVVV), Daniel Shiffman (NYU), Luke DuBois (NYU/Cycling74), Dr. Woohoo (ExtendScript), Why the Lucky Stiff (Hackety Hack). Not pictured but also presenting: Don Slater (CMU/Alice), Wanda Dann (CMU/Alice).
1. $(document).ready () All The Way
2. Use $(window).load ()
3. Load Only What You Really Need
4. Learn What The ‘data’ Method Is And Use It
5. Built-In Custom Selectors
6. Flag With Classes
7. Don’t Call the Same Selector Hundreds of Times
8. Chain (Almost) Everything
9. toggleClass Utility
10. Store jQuery Results
var $p = $('p.hello');
$p.css ('color', '#000000');
$p.text ('hello');
$p.addClass ('paragraph');
$p.fadeTo (1000, 1);
$('p.hello').css ('color', '#000000').text ('hello').addClass ('paragraph').fadeTo (1000, 1);
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="simple image gadget" />
<UserPref name="myname"
display_name="Module title"
default_value="Image"
required="true"/>
<UserPref name="targetimg"
display_name="URL of your image"
default_value="http://www.google.com/images/logo_sm.gif"
required="true"/>
<UserPref name="imgwidth"
display_name="Width"
default_value="100%"
required="true"/>
<Content type="html"><![CDATA[
<!-- Simplification of bashennekam.googlepages.com/google_gadget_image.xml -->
<div align="center">
<a href="__UP_targetimg__" target="_blank">
<img src="__UP_targetimg__" border="0" align="center" width="__UP_imgwidth__">
</a>
</div>
]]></Content>
</Module>
void httpRequest()
{
byte theByte;
xPortSerial.print("GET ");
xPortSerial.print(PHP_PAGE_LOCATION);
// value0 = 123 and value1 = 456
// You should change these to be your sensor values or whatever you want to send
// (see php code if you want to add more values or change the names value0/value1
xPortSerial.print("?value0=123&value1=456");
xPortSerial.print(" HTTP/1.1n");
xPortSerial.print(WEB_HOST);
while(!xPortSerial.available()) {} // Just loop until available
theByte = xPortSerial.read();
if (theByte != 0)
Serial.println("Passed.");
else
Serial.println("Failed.");
}
....nolist ; We don't want to actually include defs in our listing file. .include "m168def.inc" ; m168def.inc defines all the pins on the Mega168 so we can ; use them by their names rather than addresses (not fun). .list ; We DO want to include the following code in our listing ;D rjmp main ; You usually place these two lines after all your main: ; directives. They make sure that resets work correctly. ldi r16,0xFF ; LoaD Immediate. This sets r16 = 0xFF (255) out DDRB,r16 ; Out writes to SRAM, which is one way of accessing ; pins. DDRB controls PORTB's in/out state. ldi r16,0x00 ; r16 is where we'll store current LED state ; 0x00 means all off. This is preserved over loops.
You need to tell subversion what mime-type to use. Just use the command: svn propset svn:mime-type 'text/html' FILENAME or svn propset svn:mime-type 'image/jpeg' FILENAME For more info: http://svnbook.red-bean.com/en/1.4/svn.advanced.props.file-portability.html#svn.advanced.props.special.mime-type It's also possible to configure your Subversion client to automatically set each file's mime-type. For example, by modifying ~/.subversion/config to resemble [miscellany] enable-auto-props = yes [auto-props] *.html = svn:mime-type=text/html For more info: http://svnbook.red-bean.com/en/1.1/ch07.html#svn-ch-7-sect-1.3.2
Using a device called a trampoline, a function could return a function which needs to be called. Observe:
function add ($x, $y) {
if ($y > 0) {
return array (”add”, $x + 1, $y - 1);
} else {
return $x;
}
}
$f = array (”add”, 6, 5);
do {
$func = $f[0];
$f = $func($f[1], $f[2]);
} while (is_array ($f));It’s hardly pretty (though implicit evaluation improves this drastically over other methods) but it’s not awful and makes some things in PHP possible that would otherwise require writing an extension in another language.
google.visualization.Query.setResponse({
version: '0.6',
status: 'ok',
sig: '202289222',
table: {
cols: [{
id: 'A',
label: 'Name',
type: 'string',
pattern: ''
},
{
id: 'B',
label: 'Value',
type: 'number',
pattern: '#0.###############'
}],
rows: [{
c: [{
v: 'One'
},
{
v: 1.0,
f: '1'
}]
},
{
c: [{
v: 'Ten'
},
{
v: 10.0,
f: '10'
}]
}]
}
});
( pretty printed by http://jsbeautifier.org/ )
Represents a query that is sent to a data source.
google.visualization.Query(dataSourceUrl, opt_options)
Parameters
google-app-engine-samples googleappengine gae-sqlite google-app-engine-codelab app-engine-tutorial Project membership: feedparser gdata-python-client doctype skiaUsername: joe.gregorio Type the characters you see in the picture below. Letters are not case-sensitive Project ownership: feedvalidator robaccia mimeparse httplib2 uri-templates atompub-mulitpart-spec
This scheme produces a sampled sine waveform with 12 samples per cycle. In addition to the desired frequency component, f0, this waveform contains higher-frequency components at (12k+1)f0 and (12k−1)f0, k=1,2,3, and so forth. The lowpass filter comprising IC2B, R7, R8, C3, and C4 easily filters out these undesired components of smaller amplitude. Listing 1 is the assembly-program code that implements the Bell 202 FSK standard. When the control input Data In is high, the output frequency is 1200 Hz; when the control is low, the output frequency is 2200 Hz. The transition from one frequency to the other occurs in a manner that retains phase continuity.
; LEDblink.asm - M. Covington 2006
; For ATtiny13.
; Blinks the LEDs attached to PB0 and PB1.
.include "tn13def.inc"
.def temp = R16
.def temp1 = R17
.def temp2 = R18
.def mask = R19
start: ldi temp,0b00000010
out PORTB,temp ; initialize port B
ser mask
out DDRB,mask ; port B all outputs
blink:
; Delay 0.1 sec (1.2 MHz)
ldi temp1,200 ; outer loop count
L1: ldi temp2,199 ; inner loop count
L2: dec temp2
brne L2
dec temp1
brne L1
; Toggle PB0 and PB1
ldi mask,0b00000011
eor temp,mask
out PORTB,temp
rjmp blink
; End of program
void setup(){
pinMode(13, OUTPUT);
}
void loop(){
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}
First, we configure pin 13 for output by setting a bit in Data Direction Register B. Then we turn pin 13 by setting its bit in PORTB. Then we delay 500 milliseconds by marking the current value of timer0, converted into milliseconds, and letting the counter be incremented repeatedly at each clock cycle and overflowed into ever larger holders until the new value of timer0 represents an elapsed time of 500ms. Next we set the bit for pin 13 in PORTB low to turn the LED off. We do the delay dance again and we're home.
void branch(float h) {
h *= (float) $('#val_size_1').val();
// All recursive functions must have an exit condition!!!!
// Here, ours is when the length of the branch is 2 pixels or less
if (h > 5) {
pushMatrix(); // Save the current state of transformation (i.e. where are we now)
rotate(theta); // Rotate by theta
line(0,0,0,-h); // Draw the branch
translate(0,-h); // Move to the end of the branch
//ellipse(0, 0, 40, 40);
branch(h); // Ok, now call myself to draw two new branches!!
popMatrix(); // Whenever we get back here, we "pop" in order to restore the previous matrix state
// Repeat the same thing, only branch off to the "left" this time!
pushMatrix();
rotate(-theta);
line(0,0,0,-h);
translate(0,-h);
branch(h);
popMatrix();
}
}
// just type here
// and click "submit" when done
void setup(){
size(301,301);
}
void draw() {
background(290, mouseX, 50);
noStroke();
fill(mouseX, 139, mouseY);
rect(45, 45, 45, 45);
fill(20, mouseY, mouseX);
rect(50, 50, 35, 35);
fill(mouseX, 139, mouseY);
rect(100, 100, 100, 100);
fill(mouseX, 20, mouseY);
rect(50, 50, 35, 35);
fill(mouseX, mouseY, 139);
rect(200, 200, 200, 200);
fill(20, mouseY, mouseX);
rect(50, 50, 35, 35);
fill(mouseX, mouseY, mouseY);
rect(100, 100, 100, 100);
fill(20, mouseY, mouseX);
rect(50, 50, 35, 35);
}
javascript:location.href='http://del.icio.us/url?v=1&url='+encodeURIComponent(location.href)
(define db (quote (
((content)(tags))
((here is an example of content) (example content))
((an entry is a list containing two lists. The first list is the content. The second list is tags) (explanation tags))
)))
(define get-content (lambda (entry) (car entry)))
(define get-tags (lambda (entry) (cadr entry)))
(define subset? (lambda (keys lat)
(cond ((null? keys) #t)
((memq (car keys) lat) (subset? (cdr keys) lat))
(#t #f))))
(define tag-query (lambda (tags db)
(cond ((null? db) '())
((subset? tags (get-tags (car db))) (cons (car db) (tag-query tags (cdr db))))
(#t (tag-query tags (cdr db))))))
% /home/cs1721/bin/emu /home/cs1721/public_html/05s2/emu/examples/iota.hex Emu Reference Implementation v0.? > program 0000: e000 LDI R16,0 0001: e081 LDI R24,1 0002: 2fa0 MOV R26,R16 0003: e7f0 LDI R31,112 0004: e0e0 LDI R30,0 0005: 9509 ICALL 0006: e011 LDI R17,1 0007: 0f01 ADD R16,R17 0008: e614 LDI R17,100 0009: 1b10 SUB R17,R16 000a: f7b1 BRBC 1,-10 000b: e080 LDI R24,0 000c: e7f0 LDI R31,112 000d: e0e0 LDI R30,0 000e: 9509 ICALL > registers PC=0000 SP=1100 SR=[C=0,Z=0,N=0,V=0] r00-r0f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r10-r1f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > step 0000: e000 LDI R16,0 PC=0001 SP=1100 SR=[C=0,Z=0,N=0,V=0] r00-r0f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r10-r1f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > run 0 1 ... 8 9 > restart > run 0 1 ... 9 > registers PC=000f SP=1100 SR=[C=0,Z=1,N=0,V=0] r00-r0f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r10-r1f 0a 00 00 00 00 00 00 00 00 00 09 00 00 00 00 70
Example: sum of first 4 integers.
sum = 0;
for (i = 1; i <= 4; ++i)
sum += i*i;
can be translated to
sum = 0;
i = 1;
loop:
if (i == 5) goto end;;
sum = sum + i;
i = i + 1;
goto loop;
end:
can be translated to
; sum in R16
; i in R17
; R18,R19 used for temporary values
LDI R16, 0
LDI R17, 1
LDI R18, 5
SUB R18, R17
BRBS 1, 22
ADD R16, R17
LDI R19, 1
ADD R17, R19
JMP 2
SLEEP
(define (eval exp env)
(cond ((self-evaluating? exp) exp)
((variable? exp) (lookup-variable-value exp env))
((quoted? exp) (text-of-quotation exp))
((assignment? exp) (eval-assignment exp env))
((definition? exp) (eval-definition exp env))
((if? exp) (eval-if exp env))
((lambda? exp)
(make-procedure (lambda-parameters exp)
(lambda-body exp)
env))
((begin? exp)
(eval-sequence (begin-actions exp) env))
((cond? exp) (eval (cond->if exp) env))
((application? exp)
(apply (eval (operator exp) env)
(list-of-values (operands exp) env)))
(else
(error "Unknown expression type -- EVAL" exp))))
- There is a pseudo-function called "print()" (not part of javaScript) that allows data to be placed in the output window. See examples for its use.
We want to write a function that generates accumulators-- a function that takes a number n, and returns a function that takes another number i and returns n incremented by i.
TITLE 'DEMOAST1 - READ AND PRINT'
*
* AUTHOR. DON HIGGINS.
* DATE. 12/30/82.
* REMARKS. PC/370 DEMO TO ILLUSTRATE ASSIST DUMP AND LOG OUTPUT.
*
* THIS PROGRAM READS CARDS FROM DEMOAST1.DAT AND LISTS THEM ALONG
* WITH SELECTED DUMPS OF REGISTERS AND STORAGE ON DEMOAST1.LOG.
*
* MAINTENANCE
*
* 05/18/87 CONVERTED TO R2.0 XFILI/XFILO PATH/FILENAME FORMAT
*
*
DEMOAST1 CSECT
USING *,R15
XFILI =C'DEMOAST1.DAT'
XFILO =C'DEMOAST1.LOG'
XDUMP
LOOP EQU *
XREAD CARD
BNZ EOF
XPRNT CARD,80
B LOOP
EOF EQU *
XDUMP CARD,80
XDUMP CARD
SVC EXIT
R15 EQU 15
EXIT EQU 0
CARD DC CL80' '
END DEMOAST1
/pre>
1 SEE DEMO invoke full screen editor to
create DEMO.ALC 370 assembler
source file.
2 DEMO CSECT first line - define section
3 USING *,15 second - define base register
4 LA 2,=C'HELLO$' third - address of msg. text
5 SVC 209 fourth - request console msg.
6 BR 14 fifth - exit to MS-DOS
7 END sixth - end of program
8 enter escape key to save DEMO.ALC
and exit to MS-DOS
9 A370 DEMO/LX assemble DEMO.ALC and create
DEMO.OBJ object code file and
DEMO.PRN listing with symbol
cross reference.