| I l@ve RuBoard |
2.3 System Scripting OverviewThe next two sections will take a quick tour through sys and os, before this chapter moves on to larger system programming concepts. As I'm not going to demonstrate every item in every built-in module, the first thing I want to do is show you how to get more details on your own. Officially, this task also serves as an excuse for introducing a few core system scripting concepts -- along the way, we'll code a first script to format documentation. 2.3.1 Python System ModulesMost system-level interfaces in Python are shipped in just two modules: sys and os. That's somewhat oversimplified; other standard modules belong to this domain too (e.g., glob, socket, thread, time, fcntl), and some built-in functions are really system interfaces as well (e.g., open). But sys and os together form the core of Python's system tools arsenal. In principle at least, sys exports components related to the Python interpreter itself (e.g., the module search path), and os contains variables and functions that map to the operating system on which Python is run. In practice, this distinction may not always seem clear-cut (e.g., the standard input and output streams show up in sys, but they are at least arguably tied to operating system paradigms). The good news is that you'll soon use the tools in these modules so often that their locations will be permanently stamped on your memory.[1]
The os module also attempts to provide a portable programming interface to the underlying operating system -- its functions may be implemented differently on different platforms, but they look the same everywhere to Python scripts. In addition, the os module exports a nested submodule, os.path, that provides a portable interface to file and directory processing tools. 2.3.2 Module Documentation SourcesAs you can probably deduce from the preceding paragraphs, learning to write system scripts in Python is mostly a matter of learning about Python's system modules. Luckily, there are a variety of information sources to make this task easier -- from module attributes to published references and books. For instance, if you want to know everything that a built-in module exports, you can either read its library manual entry, study its source code (Python is open source software, after all), or fetch its attribute list and documentation string interactively. Let's import sys and see what it's got: C:\...\PP2E\System> python >>> import sys >>> dir(sys) ['__doc__', '__name__', '__stderr__', '__stdin__', '__stdout__', 'argv', 'builtin_module_names', 'copyright', 'dllhandle', 'exc_info', 'exc_type', 'exec_prefix', 'executable', 'exit', 'getrefcount', 'hexversion', 'maxint', 'modules', 'path', 'platform', 'prefix', 'ps1', 'ps2', 'setcheckinterval', 'setprofile', 'settrace', 'stderr', 'stdin', 'stdout', 'version', 'winver'] The dir function simply returns a list containing the string names of all the attributes in any object with attributes; it's a handy memory-jogger for modules at the interactive prompt. For example, we know there is something called sys.version, because the name version came back in the dir result. If that's not enough, we can always consult the __doc__ string of built-in modules: >>> sys.__doc__ ... ...lots of text deleted here... ... count for an object (plus one :-)\012setcheckinterval( ) -- control how often the interpreter checks for events\012setprofile( ) -- set the global profiling function\012settrace( ) -- set the global debug tracing function\012" 2.3.3 Paging Documentation StringsThe __doc__ built-in attribute usually contains a string of documentation, but may look a bit weird when printed -- it's one long string with embedded line-feed characters that print as \012, not a nice list of lines. To format these strings for more humane display, I usually use a utility script like the one in Example 2-1. Example 2-1. PP2E\System\more.py######################################################### # split and interactively page a string or file of text; ######################################################### import string def more(text, numlines=15): lines = string.split(text, '\n') while lines: chunk = lines[:numlines] lines = lines[numlines:] for line in chunk: print line if lines and raw_input('More?') not in ['y', 'Y']: break if __name__ == '__main__': import sys # when run, not imported more(open(sys.argv[1]).read( ), 10) # page contents of file on cmdline The meat of this file is its more function, and if you know any Python at all, it should be fairly straightforward -- it simply splits up a string around end-of-line characters, and then slices off and displays a few lines at a time (15 by default) to avoid scrolling off the screen. A slice expression lines[:15] gets the first 15 items in a list, and lines[15:] gets the rest; to show a different number of lines each time, pass a number to the numlines argument (e.g., the last line in Example 2-1 passes 10 to the numlines argument of the more function). The string.split built-in call this script employs returns a list of sub-strings (e.g., ["line", "line",...]). As we'll see later in this chapter, the end-of-line character is always \n (which is \012 in octal escape form) within a Python script, no matter what platform it is run upon. (If you don't already know why this matters, DOS \r characters are dropped when read.) 2.3.4 Introducing the string ModuleNow, this is a simple Python program, but it already brings up three important topics that merit quick detours here: it uses the string module, reads from a file, and is set up to be run or imported. The Python string module isn't a system-related tool per se, but it sees action in most Python programs. In fact, it is going to show up throughout this chapter and those that follow, so here is a quick review of some of its more useful exports. The string module includes calls for searching and replacing: >>> import string >>> string.find('xxxSPAMxxx', 'SPAM') # return first offset 3 >>> string.replace('xxaaxxaa', 'aa', 'SPAM') # global replacement 'xxSPAMxxSPAM' >>> string.strip('\t Ni\n') # remove whitespace 'Ni' The string.find call returns the offset of the first occurrence of a substring, and string.replace does global search and replacement. With this module, substrings are just strings; in Chapter 18, we'll also see modules that allow regular expression patterns to show up in searches and replacements. The string module also provides constants and functions useful for things like case conversions: >>> string.lowercase # case constants, converters 'abcdefghijklmnopqrstuvwxyz' >>> string.lower('SHRUBBERRY') 'shrubberry' There are also tools for splitting up strings around a substring delimiter and putting them back together with a substring between. We'll explore these tools later in this book, but as an introduction, here they are at work: >>> string.split('aaa+bbb+ccc', '+') # split into substrings list ['aaa', 'bbb', 'ccc'] >>> string.split('a b\nc\nd') # default delimiter: whitespace ['a', 'b', 'c', 'd'] >>> string.join(['aaa', 'bbb', 'ccc'], 'NI') # join substrings list 'aaaNIbbbNIccc' >>> string.join(['A', 'dead', 'parrot']) # default delimiter: space 'A dead parrot' These calls turn out to be surprisingly powerful. For example, a line of data columns separated by tabs can be parsed into its columns with a single split call; the more.py script uses it to split a string into a list of line strings. In fact, we can emulate the string.replace call with a split/join combination: >>> string.join(string.split('xxaaxxaa', 'aa'), 'SPAM') # replace the hard way 'xxSPAMxxSPAM' For future reference, also keep in mind that Python doesn't automatically convert strings to numbers, or vice versa; if you want to use one like the other, you must say so, with manual conversions: >>> string.atoi("42"), int("42"), eval("42") # string to int conversions (42, 42, 42) >>> str(42), `42`, ("%d" % 42) # int to string conversions ('42', '42', '42') >>> "42" + str(1), int("42") + 1 # concatenation, addition ('421', 43) In the last command here, the first expression triggers string concatenation (since both sides are strings) and the second invokes integer addition (because both objects are numbers). Python doesn't assume you meant one or the other and convert automatically; as a rule of thumb, Python tries to avoid magic when possible. String tools will be covered in more detail later in this book (in fact, they get a full chapter in Part IV), but be sure to also see the library manual for additional string module tools.
2.3.5 File Operation BasicsThe more.py script also opens the external file whose name is listed on the command line with the built-in open function, and reads its text into memory all at once with the file object read method. Since file objects returned by open are part of the core Python language itself, I assume that you have at least a passing familiarity with them at this point in the text. But just in case you've flipped into this chapter early on in your Pythonhood, the calls: open('file').read( ) # read entire file into string open('file').read(N) # read next N bytes into string open('file').readlines( ) # read entire file into line strings list open('file').readline( ) # read next line, through '\n' load a file's contents into a string, load a fixed size set of bytes into a string, load a file's contents into a list of line strings, and load the next line in the file into a string, respectively. As we'll see in a moment, these calls can also be applied to shell commands in Python. File objects also have write methods for sending strings to the associated file. File-related topics are covered in depth later in this chapter. 2.3.6 Using Programs Two WaysThe last few lines in the more.py file also introduce one of the first big concepts in shell tool programming. They instrument the file to be used two ways: as script or library. Every Python module has a built-in __name__ variable that is set by Python to the string __main__ only when the file is run as a program, not when imported as a library. Because of that, the more function in this file is executed automatically by the last line in the file when this script is run as a top-level program, not when it is imported elsewhere. This simple trick turns out to be one key to writing reusable script code: by coding program logic as functions instead of top-level code, it can also be imported and reused in other scripts. The upshot is that we can either run more.py by itself, or import and call its more function elsewhere. When running the file as a top-level program, we list the name of a file to be read and paged on the command line: as we'll describe fully later in this chapter, words typed in the command used to start a program show up in the built-in sys.argv list in Python. For example, here is the script file in action paging itself (be sure to type this command line in your PP2E\System directory, or it won't find the input file; I'll explain why later): C:\...\PP2E\System>python more.py more.py ######################################################### # split and interactively page a string or file of text; ######################################################### import string def more(text, numlines=15): lines = string.split(text, '\n') while lines: chunk = lines[:numlines] More?y lines = lines[numlines:] for line in chunk: print line if lines and raw_input('More?') not in ['y', 'Y']: break if __name__ == '__main__': import sys # when run, not imported more(open(sys.argv[1]).read( ), 10) # page contents of file on cmdline When the more.py file is imported, we pass an explicit string to its more function, and this is exactly the sort of utility we need for documentation text. Running this utility on the sys module's documentation string gives us a bit more information about what's available to scripts, in human-readable form: >>> from more import more >>> more(sys.__doc__) This module provides access to some objects used or maintained by the interpreter and to functions that interact strongly with the interpreter. Dynamic objects: argv -- command line arguments; argv[0] is the script pathname if known path -- module search path; path[0] is the script directory, else '' modules -- dictionary of loaded modules exitfunc -- you may set this to a function to be called when Python exits stdin -- standard input file object; used by raw_input( ) and input( ) stdout -- standard output file object; used by the print statement stderr -- standard error object; used for error messages By assigning another file object (or an object that behaves like a file) to one of these, it is possible to redirect all of the interpreter's I/O. More? Pressing "y" (and the Enter key) here makes the function display the next few lines of documentation, and then prompt again unless you've run past the end of the lines list. Try this on your own machine to see what the rest of the module's documentation string looks like. 2.3.7 Python Library ManualsIf that still isn't enough detail, your next step is to read the Python library manual's entry for sys to get the full story. All of Python's standard manuals ship as HTML pages, so you should be able to read them in any web browser you have on your computer. They are available on this book's CD (view CD-ROM content online at http://examples.oreilly.com/python2), and are installed with Python on Windows, but here are a few simple pointers:
However you get started, be sure to pick the "Library" manual for things like sys; Python's standard manual set also includes a short tutorial, language reference, extending references, and more. 2.3.8 Commercially Published ReferencesAt the risk of sounding like a marketing droid, I should mention that you can also purchase the Python manual set, printed and bound; see the book information page at http://www.python.org for details and links. Commercially published Python reference books are also available today, including Python Essential Reference (New Riders Publishing) and Python Pocket Reference (O'Reilly). The former is more complete and comes with examples, but the latter serves as a convenient memory-jogger once you've taken a library tour or two.[2] Also watch for O'Reilly's upcoming book Python Standard Library.
|
| I l@ve RuBoard |


--- # Feel free to add content and custom Front Matter to this file. # To modify the layout, see https://jekyllrb.com/docs/themes/#overriding-theme-defaults layout: default pagination: enabled: true --- Total posts: {% comment %} * * Counter: This include counts your jekyll posts * {% endcomment %}{% assign counter = 0 %}{% for item in site.posts %}{% unless item.published == false %}{% assign counter=counter | plus:1 %}{% endunless %}{% endfor %}{{ counter }} {% for post in paginator.posts %}


An avid music and language enthusiast who enjoys travel and foreign cultures (6 languages, 6 insturments and 32 countries so far). I'm originally Scottish but was born and spent most of my life living in Belgium.
At the time of writing (October 2014) I am about to start an 8 week program with the Startup Institute in London which could be considered an accelerated MBA for the startup world.
I'll be embarking on the Product and Design track at the Startup Institute where we'll be learning how to rapidly iterate websites using..


Holds a diploma in social and cultural anthropology, philosophy and computer science and is a policy associate at the Centre for Internet and Society, based in Bangalore. She is also a so-called hacktivist as an active member of one of the oldest hacker associations in the world, the Chaos Computer Club, and a member of the CryptoParty movement, organizing CryptoParties in India and teaching how to protect oneselfs online activities.
We have privacy in our day-to-day offline life, in a natural way. How can I apply my own way to protect my expressions in the offline environment to the online world and my activities there? Why is someone interested in this data, what is it worth? What choice do we have? Everyone has to define privacy for oneself.


Grandpa is Famous
问题描述 :
The whole family was excited by the news. Everyone knew grandpa had been an extremely good bridge player for decades, but when it was announced he would be in the Guinness Book of World Records as the most successful bridge player ever, whow, that was astonishing!
The International Bridge Association (IBA) has maintained, for several years, a weekly ranking of the best players in the world. Considering that each appearance in a weekly ranking constitutes a point for the player, grandpa was nominated the best player ever because he got the highest number of points.
Having many friends who were also competing against him, grandpa is extremely curious to know which player(s) took the second place. Since the IBA rankings are now available in the internet he turned to you for help. He needs a program which, when given a list of weekly rankings, finds out which player(s) got the second place according to the number of points.
The International Bridge Association (IBA) has maintained, for several years, a weekly ranking of the best players in the world. Considering that each appearance in a weekly ranking constitutes a point for the player, grandpa was nominated the best player ever because he got the highest number of points.
Having many friends who were also competing against him, grandpa is extremely curious to know which player(s) took the second place. Since the IBA rankings are now available in the internet he turned to you for help. He needs a program which, when given a list of weekly rankings, finds out which player(s) got the second place according to the number of points.
输入:
The input contains several test cases. Players are identified by integers from 1 to 10000. The first line of a test case contains two integers N and M indicating respectively the number of rankings available (2 <= N <= 500) and the number of players in each ranking (2 <= M <= 500). Each of the next N lines contains the description of one weekly ranking. Each description is composed by a sequence of M integers, separated by a blank space, identifying the players who figured in that weekly ranking. You can assume that:
- in each test case there is exactly one best player and at least one second best player,
- each weekly ranking consists of M distinct player identifiers.
The end of input is indicated by N = M = 0.
输出:
For each test case in the input your program must produce one line of output, containing the identification number of the player who is second best in number of appearances in the rankings. If there is a tie for second best, print the identification numbers of all second best players in increasing order. Each identification number produced must be followed by a blank space.
样例输入:
4 5 20 33 25 32 99 32 86 99 25 10 20 99 10 33 86 19 33 74 99 32 3 6 2 34 67 36 79 93 100 38 21 76 91 85 32 23 85 31 88 1 0 0
样例输出:
32 33 1 2 21 23 31 32 34 36 38 67 76 79 88 91 93 100
解题代码:
//* @author<EMAIL_ADDRESS>import java.io.*; import java.util.*; import java.util.Map.Entry; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { InputStreamReader is=new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); HashMap< Integer,Integer> ts=new HashMap< Integer,Integer>(); while(true) { String[] ss=in.readLine().split(" "); int x=Integer.parseInt(ss[0]); int y=Integer.parseInt(ss[1]); if(x==0&&y==0)break; for(int i=0;i< x;i++) { ss=in.readLine().split(" "); for(int j=0;j< y;j++) { int u=Integer.parseInt(ss[j]); ts.put(u, ts.containsKey(u)?ts.get(u)+1:1); } } List< Map.Entry< Integer, Integer>> ww= new ArrayList< Map.Entry< Integer, Integer>>(ts.entrySet()); Collections.sort(ww,new Comparator< Map.Entry< Integer, Integer>>(){ @Override public int compare(Entry< Integer, Integer> arg0, Entry< Integer, Integer> arg1) { int r1=arg1.getValue(); int r0=arg0.getValue(); if(r1!=r0) return r1-r0; else return arg0.getKey()-arg1.getKey(); } }); int k=ww.get(1).getValue(); System.out.print(ww.get(1).getKey()); for(int i=2;i< ww.size();i++) { if(ww.get(i).getValue()==k) System.out.print(" "+ww.get(i).getKey()); else break; } System.out.println(); ts.clear(); } } }
(adsbygoogle = window.adsbygoogle || []).push({});
还是有些难度的！
这个后缀数组不是常用的那个.
正解，已改正。应该都是protected
想问下computeLSPArray那里，if(len!=0) len=lps[len-1]是什么意思
什么破题，题意好难懂啊
为什么暴力求解方法循环到sqrt(n) 就可以了呢
即为打印出的组合的个数C(n,r)，假设print函数复杂度为O(1)
使用代码高亮的插件，再修改下css
L（X [0 .. M-1]，Y [0 .. N-1]）= 1 + L（X [0 .. M-2]，Y [0 .. N-1]）这个地方也也有笔误
应改为L（X [0 .. M-1]，Y [0 .. N-1]）= 1 + L（X [0 .. M-2]，Y [0 .. N-2]）
第二个方法很不错啊
#include <stdio.h>
int main()
{
int n,p,t[100]={1};
for(int i=1;i<100;i++)
t =i;
while(scanf("%d",&n)&&n!=0){
if(n==1)
printf("Printing order for 1 pages:nSheet 1, front: Blank, 1n");
else {
if(n%4) p=n/4+1;
else p=n/4;
int q=4*p;
printf("Printing order for %d pages:n",n);
for(int i=0;i<p;i++){
printf("Sheet %d, front: ",i+1);
if(q>n) {printf("Blank, %dn",t[2*i+1]);}
else {printf("%d, %dn",q,t[2*i+1]);}
q–;//打印表前
printf("Sheet %d, back : ",i+1);
if(q>n) {printf("%d, Blankn",t[2*i+2]);}
else {printf("%d, %dn",t[2*i+2],q);}
q–;//打印表后
}
}
}
return 0;
}
这个问题应该是有一般性的解决方法
编辑的时候有些不小心了
为什么暴力求解方法循环到sqrt(n) 就可以了呢


Item 1.
A graph with years from 400,000 years ago on the horizontal axis and atmospheric CO2 in parts per million (ppm) on the vertical axis. The graph shows that atmospheric CO2 has fluctuated between about 180 and 300 ppm for the last 400,000 years, but has soared from less than 300 ppm to over 400 ppm in the last century.in-context


class SelectorKnobAnimator
extends android.os.AsyncTask<java.lang.Void,java.lang.Void,java.lang.Void>
SelectorSwitch
to animate the rotation of its knob when
the mode of the switch is changed.SelectorSwitch
,
SelectorKnob
| Modifier and Type | Field and Description |
|---|---|
private float |
rotateBy
The angle to rotate the knob by.
|
private SelectorKnob |
selectorKnob
The selector knob being animated.
|
private SelectorSwitch |
selectorSwitch
The selector switch whose knob has to be animated.
|
private float |
stepAngle
The angle increment in which the rotation proceeds.
|
| Constructor and Description |
|---|
SelectorKnobAnimator(SelectorSwitch selectorSwitch,
SelectorKnob selectorKnob,
float rotateBy,
float stepAngle)
Create an Async task to animate the knob's rotation.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Void |
doInBackground(java.lang.Void... params)
Animates the knob by rotating it in increments and waiting 250ns between each increment,
until the knob has been rotated by the desired angle
rotateBy at which moment
the animation is completed. |
protected void |
onProgressUpdate(java.lang.Void... values)
Rotates the knob by a specified step angle.
|
private SelectorSwitch selectorSwitch
SelectorSwitch
private SelectorKnob selectorKnob
SelectorKnob
private float rotateBy
private float stepAngle
SelectorKnobAnimator(SelectorSwitch selectorSwitch, SelectorKnob selectorKnob, float rotateBy, float stepAngle)
selectorSwitch
- SelectorSwitch : The SelectorSwitch whose knob has
to be animated.selectorKnob
- SelectorKnob : The SelectorKnob to be animated.rotateBy
- float : The angle to rotate the knob by.stepAngle
- float : Angle increment to rotate the knob until
the ending angle has been reached.SelectorSwitch
,
SelectorKnob
protected java.lang.Void doInBackground(java.lang.Void... params)
rotateBy
at which moment
the animation is completed. The method call to the knob, for the actual rotation, is in
the AsyncTask.onProgressUpdate(Object[])
. This method only controls the time delay between
each step increment in the knob's angle.doInBackground
in class android.os.AsyncTask<java.lang.Void,java.lang.Void,java.lang.Void>
params
- Parameters used. ( None used here. )protected void onProgressUpdate(java.lang.Void... values)
AsyncTask.doInBackground(Object[])
until the knob has been rotated by a net desired
angle rotateBy
.onProgressUpdate
in class android.os.AsyncTask<java.lang.Void,java.lang.Void,java.lang.Void>
values
- Values used. ( None used here. )SelectorKnob.rotateBy(float)


Section is under construction. Please use the API to order food or visit canteen and order food there.


| mfl_connect {ffscrapr} | R Documentation |
This function creates a connection object which stores parameters and gets a login-cookie if available
mfl_connect( season = NULL, league_id = NULL, APIKEY = NULL, user_name = NULL, password = NULL, user_agent = NULL, rate_limit = TRUE, rate_limit_number = NULL, rate_limit_seconds = NULL, ... )
season |
Season to access on MFL - if missing, will guess based on system date (current year if March or later, otherwise previous year) |
league_id |
league_id Numeric ID parameter for each league, typically found in the URL |
APIKEY |
APIKEY - optional - allows access to private leagues. Key is unique for each league and accessible from Developer's API page (currently assuming one league at a time) |
user_name |
MFL user_name - optional - when supplied in conjunction with a password, will attempt to retrieve authentication token |
password |
MFL password - optional - when supplied in conjunction with user_name, will attempt to retrieve authentication token |
user_agent |
A string representing the user agent to be used to identify calls - may find improved rate_limits if verified token |
rate_limit |
TRUE by default, pass FALSE to turn off rate limiting |
rate_limit_number |
number of calls per |
rate_limit_seconds |
number of seconds as denominator for rate_limit |
... |
silently swallows up unused arguments |
a connection object to be used with ff_*
functions
mfl_connect(season = 2020, league_id = 54040) mfl_connect(season = 2019, league_id = 54040, rate_limit = FALSE)


Demo
Click on the button corresponding to the interface/control type you would like to try.
Arrow interface with press/release transitions
Arrow interface with click transitions
Drag interface with press/release transitions
Drag interface with click transitions
Ring click interface
Target drag with press/release transitions
Target drag with click transitions
Panel press/release interface
Panel click interface


Start typing...
I want to stay here forever.
- ◊
- ζ
- ∴
Where are the forests?
No timber here. Too cold. Ice, no trees.
Oh details! I'm sick of details
- ∩
- ∅
- ℵ
I want to make a new world here. So that I never have to go home again.


Gibbons
"Leaping from branch to branch gibbons decide which one to take in a split second"
Gibbons is a Node.js module which helps in managing user groups and user permissions with bitwise
efficiency.
In applying ArrayBuffers and bitwise operations it tries to use minimal resources.
API Documentation and tutorial
See: Gibbons Docs
How do I get set up?
npm install gibbons
Details
Prerequisites to contribute
- Clone this repository, and check out the develop branch
- Ensure Node Version Manager is installed and operational
nvm install
npm install -g gulp
Linting
For this project ESLint is applied.
Execute: gulp lint
Currently the linter conforms to defaults from: eslint-plugin-node and some minor tweaks (see: .eslint.js
).
Unit tests
Every path should be covered and can be checked after the unit test is executed, according to a coverage report.
Execute: gulp test
In the end, a brief version of the coverage report is shown. For the more extensive one, see: test/coverage/lcov-report/index.html
.
API Documentation
A Gulp plugin: gulp-jsdoc3 is applied to generate the API documentation.
It's expected to write extensive comments in the code itself when contributing.
Every time code is updated, we need to ensure the documentation is in sync with the code.
Execute: gulp docs
The result is generated at: docs/index.html
Contribution guidelines
- When adding new features / code, creating corresponding unit tests are mandatory
- Code review will be done by means of pull requests to the
develop
branch, preferably with the following pull request template:
h1. I ensured:
* [ ] I've updated the unit tests and covered enough parts of the code (`gulp lint` and `gulp test`)
* [ ] I've updated the API documentation within the code and generated a fresh export (`gulp docs`)
Changes
Meta data
- Maintainer: Ivo Cazemier
- Bitbucket or Github
- API documentation and tutorial
(License: MIT, See the LICENSE file)


Udacity project using Python
Udacity project using HTML and CSS
I like baking and trying out healthy recipes!


Tutorials
These tutorials will step you through some basic demos to get you up to speed quickly using rtc.io. If you are looking for more advanced demos check our demos page or see the full list of modules for detailed documentation.
Getting Started
Use the bundled rtc module to create a simple video chat with shared text box.
rtc.io Component Demos
rtc.io components are CommonJS modules which can be installed via npm and included as dependencies in your project using require()
. We'll need to use Browserify to bundle our app with it's dependencies to run in the browser - see the Browserify site for usage instructions.
Establishing a connection with rtc-quickconnect
Capturing user video and audio with rtc-media
Stream Processing
Extablishing video connections with rtc-quickconnect
Signalling Server
In the above examples, we have been using "//switchboard.rtc.io" as the signalling server. You can run your own signalling server using the rtc-switchboard module.
Further Reading
Some presentations on the core capabilities of the rtc.io toolset:
http://rtc.io/presentations/lca_2014_webrtc/. More info about this in Silvia's blog post, though we have since deprecated rtc-glue and are now recommending the use of rtc.
http://rtc.io/presentations/WDCNZ2014/. This presentation uses rtc for its demos.


Valverde explains why he picked Dembele over Ansu Fati vs. Slavia
The coach feels that Ansu is currently better coming from the bench
by sport.esFC Barcelona coach Ernesto Valverde explained on Friday his reason for picking Ousmane Dembele over Ansu Fati against Slavia Prague.
"It was a game for both players," Valverde said in a news conference ahead of the weekend's La Liga game against Celta Vigo at Camp Nou.
"Dembele started, but it was very tight and that made it difficult to run. In the second half, it was better, but I opted to change it."
As for Ansu Fati, he commented that "I'm seeing him better coming on off the bench with the game already going than from the start."
"HE DOEs amaZINg THIngS"
Sticking with Dembele, who Barça played 105 million for in 2017, Valverde added that "he does amazing things and we want him to do them all the time."
He continued: "He has to toughen up when he receives the ball, especially when he receives it with his back to the opponent. We have a great player (in Dembele), he gives us a lot and we hope for more."


“Ye ime satta bojjhaṅgā,
maggā nibbānapattiyā;
Bhāvitā te mayā sabbe,
yathā buddhena desitā.
Of the seven awakening factors,
the path for attaining extinguishment,
I have developed them all,
just as the Buddha taught.
Suññatassānimittassa,
lābhinīhaṁ yadicchakaṁ;
Orasā dhītā buddhassa,
nibbānābhiratā sadā.
I attain the meditations on emptiness
and signlessness whenever I want.
I am the Buddha’s rightful daughter,
always delighting in quenching.
Sabbe kāmā samucchinnā,
ye dibbā ye ca mānusā;
Vikkhīṇo jātisaṁsāro,
natthi dāni punabbhavo”ti.

Transmigration through births is finished,
now there’ll be no more future lives.
… Aparā uttamā therī ….


Introduction
This documentation is for Version 3 of CANDY HOUSE’s Sesame API. You can find documentation for Version 1/Version 2 here.
Welcome to the CANDY HOUSE Developer Site! We use RESTful API to provide basic manipulation of the Sesame smart lock, including:
- Get Sesame lock/unlock status
- Get battery status
- Lock and unlock Sesame
- Sync Sesame status
- Get results for lock, unlock, and sync commands
Many new functions are still under development and will be coming soon, so stay tuned!
Please note that in order to enable API for your Sesame, you must be the owner of Sesame and have it paired with the Wi-Fi Access Point.
To set up your Wi-Fi Access Point, follow these instructions to link your Wi-Fi Access Point to your home Wi-Fi network and pair it with your Sesame.
IMPORTANT: Once you have linked your Sesame to the Wi-Fi Access Point, go to Sesame Status > Change Settings > Integration and toggle this setting to ON to enable the API.
If you would like to suggest changes to the documentation or if you find any bugs, please feel free to contact us.
Endpoint
All requests should be prefixed with:
https://api.candyhouse.co/public
Parameters
Pass parameter in json body
curl -H "Content-Type: application/json" \
-X POST -d '{"param1":"value1", "param2":"value2"}'
Pass parameter in query strings
curl "https://api.candyhouse.co/public?param1=value1¶m2=value2"
Always pass parameters in json body for POST and query strings for GET.
Authentication
curl -H "Authorization: YOUR_AUTH_TOKEN"
Please create the your auth token by logging into the CANDY HOUSE Dashboard with your CANDY HOUSE account. Click on “API Settings” in the sidebar, verify your identity, then add a new API key. This API key is your auth token. Every request must have the auth token set in the Authorization
header.
Sesame API
Get Sesame list
curl -H "Authorization: YOUR_AUTH_TOKEN" \
https://api.candyhouse.co/public/sesames
[
{
"device_id": "00000000-0000-0000-0000-000000000000",
"serial": "ABC1234567"
"nickname": "Front door",
}, {
"device_id": "00000000-0000-0000-0000-000000000001",
"serial": "DEF7654321"
"nickname": "Back door",
}
]
GET /sesames
Response Fields
| Parameter | Type | Description |
|---|---|---|
| array | Array of Sesames | |
[i].device_id |
UUID |
Sesame unique ID |
[i].serial |
string |
Sesame serial |
[i].nickname |
string |
Sesame nickname |
Get Sesame status
curl -H "Authorization: YOUR_AUTH_TOKEN" \
https://api.candyhouse.co/public/sesame/00000000-0000-0000-0000-000000000001
{
"locked": true,
"battery": 100,
"responsive": true
}
GET /sesame/{device_id}
Response Fields
| Parameter | Type | Description |
|---|---|---|
locked |
boolean |
Sesame is locked or not |
battery |
integer | Sesame battery status |
responsive |
boolean | Sesame is responsive now or not |
Control Sesame
curl -H "Authorization: YOUR_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-X POST -d '{"command":"lock"}' \
https://api.candyhouse.co/public/sesame/00000000-0000-0000-0000-000000000001
{
"task_id": "01234567-890a-bcde-f012-34567890abcd"
}
POST /sesame/{device_id}
Post Body
| Parameter | Type | Description |
|---|---|---|
command |
string |
(required) lock , unlock or sync . Sync command will force the server to update Sesame status. NOTE: Frequent use of the sync command will reduce Sesame’s battery life. |
Response Fields
| Parameter | Type | Description |
|---|---|---|
task_id |
string |
Task ID which can be used to query execution result. |
Query Execution Result
curl -H "Authorization: YOUR_AUTH_TOKEN" \
https://api.candyhouse.co/public/action-result?task_id=01234567-890a-bcde-f012-34567890abcd
{
"status": "terminated",
"successful": true
}
GET /action-result?task_id={task_id}
Query Parameters
| Parameter | Type | Description |
|---|---|---|
task_id |
string |
(required) Task ID from command result. |
Response Fields
| Parameter | Type | Description |
|---|---|---|
status |
string |
Can be “processing” or “terminated”. |
successful |
boolean |
This parameter only appears when the status is terminated. Indicates whether the execution was successful or not. |
error |
string |
Indicates the reason execution failed. |
Errors
All errors contain an error attribute indicating the error details.
400 Bad Request
{
"error": "BAD_PARAMS"
}
{
"error": "DEVICE_IS_BUSY 35"
}
BAD_PARAMS
Your request paremeters are invalidCLOUD_INTEGRATION_NOT_ENABLED
Please enable cloud integration in Sesame app under Sesame > Change Settings.LOW_BATTERY
Your device cannot be operated because its batteries are low.DEVICE_IS_BUSY
Your device cannot be operated because it is occupied by other requests.DEVICE_IS_BUSY :seconds
Your device cannot be operated because the device is occupied by other requests. The:seconds
is an integer indicating the max duration you have to wait until you can send the next request.
401 Unauthorized
UNAUTHORIZED
Your API key is missing or invalid.
403 Forbidden
Forbidden
ORACCESS_DENY
You IP address has been blocked due to repeatedly exceeding our rate limits by a significant amount. The exact rate limit is subject to change as it is automatically determined by an algorithm, but request rates at 1 request per second (or lower) will not be restricted. If you receive this error, please cease requests for 30 minutes before trying again. If the error persists, please email us at<EMAIL_ADDRESS>for assistance and provide your IP address.
429 Throttled
THROTTLED
Your request rate has exceeded the limit. The request rate limit is based on both user account and IP address. Each API endpoint has an absolute rate limit. Please email us at<EMAIL_ADDRESS>if you have any questions or requests for an exception.
500 Internal Error
INTERNAL_ERROR
Server cannot handle your request. These errors tend to be temporary; if it persists, please email<EMAIL_ADDRESS>to let us know.
Sesame Webhook
You can set up a webhook URL at the CANDY HOUSE Dashboard by accessing your API Settings.
Method
- The webhook now supports GET and POST methods.
URL
- The webhook URL is limited to 256 characters.
- The webook URL supports variables; for example, when using
http://example.com/device={device_id}
,{device_id}
will be replaced by the device UUID. - Variables Reference
- *
{device_id}
: Device UUID - *
state
:locked
orunlocked
Trigger
- The webhook will be triggered when Sesame’s lock status has changed.
- The webhook will not retry if the HTTP request fails.
Third-Party Libraries & Plugins
We love seeing what awesome things Sesame users are doing with our cloud API!
Have something to share? Email us and we’ll be happy to add it to the list!
Libraries using V3 API
Pysesame2
by Anonymous
Sesame.NET
by Ben Randall
“A .NET client for the Sesame API.”
Homebridge-Sesame
“Homebridge plugin for the Sesame smart lock.”
Sesame/SmartThings Integration
by tobycth3
“Integration between Sesame API and SmartThings.”
GSuiteScript for Sesame API
by Jerming Gu
“Integrate Google Apps with Sesame and lock/unlock Sesame from Google Sheets.”
Home Assistant Sesame
“The sesame platform allows you to control your Sesame smart locks made by CANDY HOUSE, Inc.”
Libraries using V1 & V2 API
Pysesame
by Albert Lee
“Python API for controlling Sesame smart locks made by CANDY HOUSE, Inc.”
QSesame
by Brendan
“QSesame is a Homebridge plugin that allows you to control Sesame smart locks with Siri by integrating with HomeKit.”
Sesame Ruby
“This gem provides a simple Ruby wrapper around the CANDY HOUSE Sesame API to control Sesame Bluetooth and Internet-connected locks.” (source)
Tutorial 1: API (Postman)
Introduction
In this tutorial, you will learn how to get status updates for your Sesame, lock and unlock your Sesame, sync status, and check the results of your API commands. You will do so by making GET and POST requests to Sesame’s RESTful API using the free Postman app.
To complete this tutorial, you must have the following:
- Sesame smart lock
- Wi-Fi Access Point
- Computer with internet access
Before You Start
You must be the owner of Sesame to enable the API.
You must have a Wi-Fi Access Point properly set up and paired with your Sesame (instructions here).
Make sure to enable cloud integration for your Sesame under Status > Change Settings > Integration.
Keep the Sesame app closed while using the API; if it’s open it will prevent the API from connecting to your Sesame. Only one device can connect to Sesame at a time.
Obtain Your API Key
Login to your CANDY HOUSE Account on the CANDY HOUSE Dashboard with your email and password or Google account.
Click on API Settings in the sidebar. To access your API Settings, you will need to enter a verification code. Click SEND CODE and your verification code will be sent to the email address you used to login. Enter the code and then click CONFIRM.
Once you’ve entered the verification code, you will be able to access your API settings. Click ADD to add a new API Key. Please note that the full key will no longer be visible once you refresh or logout, so be sure to save a copy somewhere. You can also delete existing keys and create additional keys as needed.
Get Postman
Download the free Postman app and create an account. Make sure you’ve downloaded the latest version.
Create an account if you haven’t already, then login to the app. We recommend unchecking “Show this window on launch.” Close the launch screen to begin.
Save Your API Key as a Preset
Save your API key as a preset so you won’t need to keep copy/pasting it in the header over and over for each of the following steps. On your emply tab, do the following:
- Select the Headers tab
- Click Presets
- Click Manage Presets
- Click Add
Enter the following information:
- Give your Preset a name, such as: Sesame Token
- Enter the name of your key: Authorization
- Copy and paste the API key from the CANDY HOUSE Dashboard.
- When you’re done, click Add.
- Click the X in the upper right corner once you’re done.
The next time you want to use your authorization token, go to Header, click Preset, and select Sesame Token to automatically input the token. The token must be included for each of the following requests. Do so now as you will need it for the next step.
Request Sesame List
Next, we will check if the token is correct by requesting a list of Sesames for which you are the owner. Please note that you will only be able to use the API for Sesames for which you are the owner. In your current tab, enter the following information:
- Leave GET as GET
- Enter the request URL:
https://api.candyhouse.co/public/sesames
Once you’ve confirmed all of the above is correct, click the blue Send button. If your request is successful, the API will return status 200 plus a list of Sesames owned by your CANDY HOUSE account, as well as the following information for each Sesame:
- Device ID
- Serial
- Nickname
Copy the Device ID for the following steps, then click on the plus sign next to your current tab to open a new tab.
Request Sesame Status
Next, we will request the status for a Sesame in your list using its device ID. On your new tab, enter the following information:
- Leave GET as GET
- For the request URL, enter the following but change
*DEVICE_ID*
to the actual ID of a Sesame you own:https://api.candyhouse.co/public/sesame/*DEVICE_ID*
- Select the Headers tab
- Add your Sesame Token preset
Once you’ve confirmed everything is correct, click the blue Send button. If your request is successful, the API will return status 200 plus the following information for your Sesame:
- Locked (true = locked, false = unlocked)
- Battery percentage
- Responsive (true = responsive, false = unresponsive)
Lock Sesame
Next, we will pass a command to lock Sesame. Duplicate the “Get Sesame Status” tab by clicking the three circles next to the plus sign, then click Duplicate Current Tab.
On your duplicated tab, do the following:
- Change GET to POST
- Select the Body tab
- Select raw
- Select JSON (application/json)
- In the text field, type the following:
{"command":"lock"}
Make sure the information in both the Headers and Body sections are correct, then click the blue Send button. If your request is successful, the API will return status 200 plus the task ID. Copy the Task ID for the next step.
Query Task Result
- Next, we will check whether the command was successfully carried out by Sesame. Receiving the task ID merely indicates that our servers successfully received the request, but it doesn’t necessarily mean that Sesame was actually locked. Querying the status will let you know if the commane was successfully executed, and if not, the reason for failure. To begin, open a new tab, then enter the following information:
- Leave GET as GET
- For the request URL, enter the following but change
*TASK_ID
to the actual task ID for your lock Sesame command:https://api.candyhouse.co/public/action-result?task_id=*TASK_ID*
- Select the Headers tab
- Add your Sesame Token preset
- Make sure the information in both the Headers and Body section is correct, then click the blue Send button. If your request is successful, the API will return the status of your task. If the status is terminated, the API will also return whether the command was successful, and if not, why it failed.
Unlock Sesame
Now it’s time to unlock Sesame. Find the tab you used to lock Sesame, then duplicate the tab by clicking the three cirlces and Duplicate Current Tab. Next, do the following:
- Select the Body tab
- In the text field, change the content to the following:
{"command":"unlock"}
Click the blue Send button. If the request is successful, the API will return status 200 and the task ID. You can copy this task ID and query its status if you’d like.
Sync Sesame Status
In addition to the lock and unlock commands, you can also use the sync command to force the server to update Sesame status. To do so, duplicate your unlock Sesame tab by clicking the three cirlces and Duplicate Current Tab. Next, do the following:
- Select the Body tab
- In the text field, change the content to the following:
{"command":"sync"}
Click the blue Send button. If the request is successful, the API will return status 200 and the task ID. You can copy this task ID and query its status if you’d like.
Saving Your Requests
If you haven’t already, be sure to save each of your requests by clicking the Save button and giving the request a name that describes its function.
You will also need to create a collection in which to save all your requests. Click Create Collection, give your collection a name, then click the checkmark.
Once you’ve done so, select your collection and click Save.
After you save your first request in a collection, the collection sidebar will open. Click the X on the upper right to close this sidebar. Once you’ve done so, you can continue saving your other requests.
The next time you’d like to send a request, you can either click on the existing tab or find your request in your Sesame collection. Click the Send button to make the request.
Support
We hope you found our tutorial helpful! If you have any feedback or questions for us, please feel free to email<EMAIL_ADDRESS>and we’ll be happy to answer your questions! You can also check out the CANDY HOUSE forum for API-related discussions - just sign in with your CANDY HOUSE account email and password.
Tutorial 2: API & Webhook (IFTTT)
Introduction
In this tutorial, you will learn how to turn Sesame being locked or unlocked into an IFTTT trigger (“If This”) as well as lock or unlock Sesame as an IFTTT action (“Then That”). You will use both the Sesame RESTful API as well as the Sesame Webhook as well as the IFTTT platform.
To complete this tutorial, you must have the following:
- Sesame smart lock
- Wi-Fi Access Point
- Computer or mobile device with internet access
Before You Start
You must be the owner of Sesame to enable the API.
You must have a Wi-Fi Access Point properly set up and paired with your Sesame (instructions here).
Make sure to enable cloud integration for your Sesame under Status > Change Settings > Integration.
Keep the Sesame app closed while using the API; if it’s open it will prevent the API from connecting to your Sesame. Only one device can connect to Sesame at a time.
You will need to create an account at IFTTT in order to create IFTTT applets.
Obtain Your API Key and Device ID
Login to your CANDY HOUSE Account on the CANDY HOUSE Dashboard with your email and password or Google account.
Click on API Settings in the sidebar. To access your API Settings, you will need to enter a verification code. Click SEND CODE and your verification code will be sent to the email address you used to login. Enter the code and then click CONFIRM.
Once you’ve entered the verification code, you will be able to access your API Settings. Click ADD to add a new API Key. Please note that the full key will no longer be visible once you refresh or logout, so be sure to save a copy somewhere. You can also delete existing keys and create additional keys as needed.
To obtain your Device ID, click on Sesame List in the sidebar, then click on your Sesame. The device ID will be in the URL. Select the alphanumerical string after the last slash in the URL; you will use this as the device ID later, so keep the tab open or copy it to a safe place.
Lock or Unlock Sesame as an IFTTT Action
First, make sure you go to the Webhook service and click CONNECT to add this service to your IFTTT account.
Next, go to your IFTTT account and click on the New Applet button.
Click on +this and select the trigger you would like to use. For our example, we chose the Button Widget and selected “Button press” as our trigger.
Click on +that and search for the Webhooks widget. Select “Make a web request”.
Enter the following information to create your action:
- In the URL field, enter:
https://api.candyhouse.co/public/partners/ifttt
- For the Method field, select POST.
- For Content Type, select application/json.
- In the Body section, enter:
{"command": "*COMMAND*", "apikey": "*API_KEY*", "device_id": "*DEVICE_ID*"}
. Be sure to replace*COMMAND*
with either lock or unlock depending on whether you want the applet to lock or unlock. Be sure to also replace*API_KEY*
with your actual API key, and replace*DEVICE_ID*
with your actual device ID.
- In the URL field, enter:
Once finished, click Create Action, edit the name of the applet if you’d like, then click Finish and your new Sesame applet is good to go!
Trigger Actions when Sesame is Locked or Unlocked
First, go to the Webhook service on IFTTT and make sure it is connected to your account (if not, click on CONNECT to do so). Click on Documentation to obtain your IFTTT Maker Key.
In the Event field, type
{device_id}_{state}
, then copy the URL at the bottom of the page.Next, go to the CANDY HOUSE Dashboard and click on API Settings. Create a webhook by clicking on the EDIT button, then paste the copied URL in the URL field. It will be
https://maker.ifttt.com/trigger/{device_id}_{state}/with/key/*MAKER_KEY*
with*MAKER_KEY*
replaced with your own actual key. Your webhook will then be Enabled.Next, return to your IFTTT account and click on the New Applet button.
Click on +that and search for the Webhooks widget. Select “Receive a web request”.
In the Event Name field, enter
*DEVICE_ID*_*STATE*
, but replace*DEVICE_ID*
with your actual device ID, and replace*STATE*
with either lock or unlock depending on which state you would like to trigger the applet. The end result will be something like “12345678-ABCD-1234-EFGHIJKLMNOP_lock” or “12345678-ABCD-1234-EFGHIJKLMNOP_unlock”. Click Create Trigger to proceed.Next, click +that and select the action you would like to happen. In our example, we chose “Send an email.” You can also edit the content of the email or your own trigger using
MakerEventName
orOccurredAt
. Values 1, 2, 3 are not used.Click Create Applet, then rename your applet and click Finish. Now your action will trigger when Sesame is locked or unlocked, depending on which state you chose to enter in the Event Name field.
Support
We hope you found our tutorial helpful! If you have any feedback or questions for us, please feel free to email<EMAIL_ADDRESS>and we’ll be happy to answer your questions! You can also check out the CANDY HOUSE forum for API-related discussions - just sign in with your CANDY HOUSE account email and password.


I want my website to be simple and easy to navigate, first and foremeost.
With that said, the plan for my site is pretty simple:
I'm planning on having the logo content within its own #logo div. Similarly, the nav content will be in its own div.
I'm thinking I'll have two main nav links/sections on the homepage: one for "thoughts" (i.e., blog entries) and the other for projects like the responsive website we were supposed to make for week 2, problem 3. I'll of course have to make other pages for these two sections.
I'm actually pretty happy with the color scheme for now, so that'll pretty stay the same.
Here's the wireframe:


SoftUni
Welcome to SoftUni.

USERNAME
EMAIL
PASSWORD
REPEAT PASSWORD
REGISTER
I am already a ninja


@blog.label
What is your mood now ? (1. make a short description and 2. click emoticon relevant to your mood)
Recent emotions
| Mood | When | Description |
|---|---|---|
|
@if(entry.mood == models.Mood.ANGRY) {
|
@entry.timestampLocalStr(blog.getTimeZone()) | @entry.notes |


Bus Mall Market Survey
Instructions
- The Bus Mall appreciates your feedback! Please take a moment to provide us some feedback on our products!
- A set of three random product images will appear below. Please click on one of the three. We will ask you to do this 25 times.
- After 25 product clicks, you will be presented with a 'View Results' button to see the survey's results if you'd like!
Thank You for participating!


Popular Tech Topic Overviews
November 19, 2015
This post is going to move a little fast. We're going to do a very brief overview of some common tech topics, which should give you a big picture understanding of tech speak.
Big O Complexity and Notation
Big O complexity answers the question of how efficient an algorithm is, which indicates how quickly a process will run, and how resource-intensive it will be. Complexity is expressed using big-O notation, written as O(N). As an example, linear-time algorithms will be to the order N, so will write as O(N).
Computer Memory
Computer memory is divided into two main types: Internal or Main memory, stored in RAM and ROM chips, and External or Auxiliary Memory, stored in things like Hard Drives. Internal memory can store and retrieve data quickly, and it's used to help the computer process whatever is currently being worked on. It doesn't store data long-term, so empties its contents as soon as the computer is powered down. The external memory is for long-term storage, and is where your documents, pictures, etc are stored. In order for the CPU to access memory, every instruction or piece of data stored in memory has a location, which acts like an address in which it can be referred to.
Dynamic vs. Static-typed Languages
Static-typed languages are languages where the variable types are known before the program is run. For example, variable
i
would be declared as an integer beforei
is assigned a value. This helps in catching errors before these variables are even involved in any operations. Dynamic-typed languages like Ruby do not need variable type declarations in order for the program to run, which allows for quicker coding but can be more error-prone.How computers work
Computers have four components: Input, memory, processors, and output. Things that provide input include keyboards and mice. Memory devices include the hard-drive and memory cards. Processors are also called the central processing unit, and is a microchip in the computer. This is where the work gets done! Lastly, the output includes your monitor and speakers. The operating system is the software that controls these basic four components, and other programs are built on top of it.
The CPU, where the magic happens, converts the data input into information output. It is a complex, electronic circuit that executes program instructions. It also interacts with memory, referring to internal memory for instructions and data.
What's interesting is that the electronic circuitry in the CPU can perform the four basic arithmetic operations (+,-,*,/) and logical comparisons (==,>,<), so in executing programs, all instructions are broken down into these basic functions.
How the Internet Works
The Internet is really just a computer network, akin to a telephone network. The World Wide Web, file sharing, Whatsapp, etc are all things that run on top of this computer network. The computer network's job is to move data via wire cables, fiber-optics, radio waves, and satellites.
Data moves through the network using packet switching. The data is moved into broken up pieces called packets, are given a destination, and then reassemble once it reaches that destination. These packets are all sent separately through the most efficient routes, so they arrive faster than if everything was sent at once.
Recursion
Recursion is a function that calls itself until a base case is reached, upon which the recursive function will end. Recursion is useful for large problems that can be broken down into smaller version of itself, so that the smaller version can be solved, fed back into the problem, and then have the algorithm apply to the new smallest piece. A very common example of recursion is the factorial problem(n!), where n! = n*(n-1)*(n-2)...*1 or, written recursively, n*(n-1)!. As ruby, this would look like
def factorial(n) if n == 1 return 1 else n*factorial(n-1) end end
Regular Expressions
A regular expression is a text string that describes a search pattern in a programming language. Some examples would be the use of [A-Z] to search for capital letters, *.txt to search for file names that end with .txt, or \d to search for a digit.
Sorting (merge sort, quick sort, bubble sort)
When it comes to big data sets, it's important to think about an efficient sorting algorithm.
- Bubble Sort: The least efficient method, bubble sort goes through the items of the list in pairs, and swaps the order of the pairs so that the smallest value is first. The algorithm keeps looping through the list until it goes through the list once without any swaps.
- Quick Sort: Selects a pivot in the list, and moves smaller elements to before the pivot, greater elements to after the pivot. What is important here is that it isn't necessarily placing the swapped elements in order, it is just moving the elements into a smaller and greater section. It then calls the function recursively on each section until the subsections have no more elements to partition. It is important that the initial pivot is randomly chosen, and not the furthermost element of the list.
- Merge Sort: Merge sort is a recursive algorithm that divides a list into n subsets. It then sorts these subsets (initially just one element each) and merges one level. It then sorts these subsets, and continues to merge and sort until there is only one sublist.
Test-Driven Development
Test-Driven Development is the idea of driving development based on short and fast testing cycles. The process results in very short development cycles based on test cases that are defined to test (and initially fail) for specific improvements or functions. This reduces errors throughout the code, breaks down problems into small steps, and helps the development team design for the user when they think about test cases.
What is Rails?
Rails is a software library that is installed via the command-line and pairs with Ruby. It's a framework for building the back-end of web applications, simplifying development by combining Ruby with HTML, CSS, and JavaScript.
Web Security
Web security relies on a few different components:
- Authentication of clients, end users, other services, processes, computers. These are called principals.
- Authorization of resources and operations that authenticated principals are permitted to access.
- Auditing and logging of operations and transactions.
- Confidentiality or privacy, making sure that data remains private and cannot be viewed by unauthorized users.
- Integrity is the guarantee of protection over data from modifications.
- Availability of the systems for legitimate users, which protects from hackers trying to cause applications to crash by overwhelming the system.
Building a secure web application is important. Much like modeling risks in other fields, part of application design would include modeling threats to identify vulnerabilities in the system.
SQL Injection
SQL injection is a way to extract data maliciously from data-heavy applications. Users can inject SQL commands into a SQL statement using an entry field (such as user name fields) and pull data from the web app's database.
NoSQL databases
NoSQL databases is a method of storage and retrieval of data that does not use relational databases. NoSql databases benefit in their scalability and performance power compared to relational databases. They can handle large volumes of structured and unstructured data, lend themselves to agile development (as the database schema does not need to be defined at initial build), and can be more efficient.
SQL query optimization
SQL query optimization is the process of writing efficient code to pull data from relational databases using SQL. There are various techniques, including specifying field names instead of using wild cards, minimizing subqueries, and performing proper indexing in table columns.
Functional Programming
Functional programming is stateless and immutable. When we say that data in functional programs is immutable, we mean that it should never change. This means that instead of modifying existing data structures in an operation, new data structures are created. To be stateless, this means that functional programs should have no knowledge of what happened earlier in the program execution, so the functions should only operate on data that was passed into the function as arguments, and no other outside data.


Most frameworks provide their own form of component communication. But try and use rxjs for this instead.
In assignment-4-movie-search.component.ts we can see that we have a tag-list component which prints out all of our historical searchqueries in a list. We wil still use Angular input directive as it stands right now. But we want to get back the tag item that the user has clicked so we can put it inside the search input.
Use the Input selectedItem$ BehaviorSubject in assignment-4/shared/components/tag-list/tag-list.component.ts to put in a new value when the user clicks on a item. for the sake of this workshop the eventHandler(public handleItemClick) has already been made. Fill it in with the logic to provide the selectedItemSubject Subject with data
we now have a component which takes a "items" and "selectedItem$" as input and updates the selectedItem$ to whatever subscribers ther are. Head over to the assignment-4-movie-search.component.ts and subscribe to the selectedItemSubject wich is also already given to the tag-list component
NOTE!: always remember to unsubscribe to open subscriptions to prevent memory leaks


| |
- Method resolution order:
- CygwinSshCommand
- nrvr.remote.ssh.SshCommand
- __builtin__.object
Methods defined here:
- __init__(self, sshParameters, argv, exceptionIfNotZero=True, maxConnectionRetries=10, tickerForRetry=True)
- Create new CygwinSshCommand instance.
See nrvr.remote.ssh.SshCommand.
Class methods defined here:
- isGuiAvailable(cls, sshParameters, alsoNeedsScreen=False) from __builtin__.type
- Return whether GUI is available.
Should be user to be meaningful.
Will wait until completed.
sshParameters
an SshParameters instance.
- sleepUntilIsGuiAvailable(cls, sshParameters, alsoNeedsScreen=False, checkIntervalSeconds=3.0, ticker=False, extraSleepSeconds=5.0) from __builtin__.type
- If GUI available return, else loop sleeping for checkIntervalSeconds.
Should be user to be meaningful.
As implemented first calls SshCommand.sleepUntilIsAvailable(sshParameters).
sshParameters
an SshParameters instance.
Class methods inherited from nrvr.remote.ssh.SshCommand:
- acceptKnownHostKey(cls, sshParameters, connectTimeoutSeconds=None) from __builtin__.type
- Accept host's key.
Will wait until completed.
ipaddress
IP address or domain name.
- commandsUsedInImplementation(cls) from __builtin__.type
- Return a list to be passed to SystemRequirements.commandsRequired().
This class can be passed to SystemRequirements.commandsRequiredByImplementations().
- hasAcceptedKnownHostKey(cls, sshParameters) from __builtin__.type
- Return whether an attempt to acceptKnownHostKey() succeeds.
Will wait until completed with success or failure.
sshParameters
an SshParameters instance to use in the attempt.
return
whether success.
- isAvailable(cls, sshParameters, probingCommand='hostname') from __builtin__.type
- Return whether probingCommand succeeds.
Will wait until completed.
- removeKnownHostKey(cls, ipaddress) from __builtin__.type
- Remove line from ~/.ssh/known_hosts file.
- sleepUntilHasAcceptedKnownHostKey(cls, sshParameters, checkIntervalSeconds=3.0, ticker=False, extraSleepSeconds=5.0) from __builtin__.type
- If available return, else loop sleeping for checkIntervalSeconds.
sshParameters
an SshParameters instance to use in the attempts.
- sleepUntilIsAvailable(cls, sshParameters, checkIntervalSeconds=5.0, ticker=False, probingCommand='hostname') from __builtin__.type
- If available return, else loop sleeping for checkIntervalSeconds.
Data descriptors inherited from nrvr.remote.ssh.SshCommand:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- output
- Collected output string of command.
May contain extraneous leading or trailing newlines and whitespace.
- returncode
- Returncode of command or 255 if an ssh error occurred.
Could be None.
|


An example of using the Google sheets connector to retrieve data from a Google Sheets spreadsheet. The data that's retrieved is combined and used as the Scatter chart coordinates.
This goes in the documents header:  Put this where you want the chart to show up:

This is the code that generates the chart - it should be placed AFTER the

tag:


Blacksmith Brunon:
Ah, you are smarter than you look! Was that too easy?
Come to think of it, mathematical skills aren't at all important for the position I was thinking about. You don't seem to understand my way of thinking very well, and I hesitate to trust you with the expensive equipment. If we are to work together we must know each other's minds completely.


Coverage Summary for Class: AvailableInputStream (org.wikipedia.dataclient.okhttp)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| AvailableInputStream | 0% (0/ 1) | 0% (0/ 7) | 0% (0/ 24) |
1 package org.wikipedia.dataclient.okhttp;
2
3 import android.support.annotation.NonNull;
4
5 import java.io.IOException;
6 import java.io.InputStream;
7
8 /**
9 * This is a subclass of InputStream that implements the available() method reliably enough
10 * to satisfy WebResourceResponses or other consumers like BufferedInputStream that depend
11 * on available() to return a meaningful value.
12 *
13 * The problem is that the InputStream provided by OkHttp's body().byteStream() returns zero
14 * when calling available() prior to making any read() calls, which means that it will break
15 * any consumers that wrap a BufferedInputStream onto this stream, or any other wrapper that
16 * relies on a consistent implementation of available().
17 *
18 * This is initialized with the original InputStream plus its total size, which must be known
19 * at the time of instantiation. You may then call the read() and skip() methods in the usual
20 * way, and then be able to call available() and get the number of bytes left to read.
21 */
22 public class AvailableInputStream extends InputStream {
23 private InputStream stream;
24 private long available;
25
26 public AvailableInputStream(InputStream stream, long available) {
27 this.stream = stream;
28 this.available = available;
29 }
30
31 @Override public int read() throws IOException {
32 decreaseAvailable(1);
33 return stream.read();
34 }
35
36 @Override public int read(@NonNull byte[] b) throws IOException {
37 int ret = stream.read(b);
38 if (ret > 0) {
39 decreaseAvailable(ret);
40 }
41 return ret;
42 }
43
44 @Override public int read(@NonNull byte[] b, int off, int len) throws IOException {
45 int ret = stream.read(b, off, len);
46 if (ret > 0) {
47 decreaseAvailable(ret);
48 }
49 return ret;
50 }
51
52 @Override public long skip(long n) throws IOException {
53 long ret = stream.skip(n);
54 if (ret > 0) {
55 decreaseAvailable(ret);
56 }
57 return ret;
58 }
59
60 @Override public int available() throws IOException {
61 int ret = stream.available();
62 if (ret == 0 && available > 0) {
63 return (int) available;
64 }
65 return ret;
66 }
67
68 private void decreaseAvailable(long n) {
69 available -= n;
70 if (available < 0) {
71 available = 0;
72 }
73 }
74 }


All Classes
Packages
PlayerWarpGUI
PlayerWarpGUI.API
PlayerWarpGUI.Chat
PlayerWarpGUI.Commands
PlayerWarpGUI.Commands.SubCommands
PlayerWarpGUI.config
PlayerWarpGUI.Events
PlayerWarpGUI.Handlers
PlayerWarpGUI.Hooks
PlayerWarpGUI.Listeners
PlayerWarpGUI.locale
PlayerWarpGUI.Objects
PlayerWarpGUI.Others
PlayerWarpGUI.Utils
PlayerWarpGUI.Utils.Location
PlayerWarpGUI.Utils.Perms
PlayerWarpGUI.Utils.Player
PlayerWarpGUI.Utils.Warp
PlayerWarpGUI.Utils.World


Welcome
notedown lets you take down notes.
fast and beautiful.
Notedown allows you to send snapshots over email. Simply click on the to copy the notes into clipboard and open compose email dialog. Enter your email id and paste your notes into the body and send.
Privacy
notedown uses HTML5 localStorage.
That means all your data are stored within your browser.
No data is sent to servers. We care for our users privacy :)


[Gecode] RE: PowerB
Denys Duchier
duchier at ps.uni-sb.de
Tue Nov 4 20:36:20 CET 2003
"Christian Schulte" <schulte at imit.kth.se> writes:
> [Gabor: I am sending the answer to the gecode list as it might be of general
> interest]
Actually all gecode-related emails should go to this list. This way,
we all learn from the questions and answers, and we are kept up to
date on what is happening. That's the whole point.
Cheers,
--
Dr. Denys Duchier
Équipe Calligramme
LORIA, Nancy, FRANCE
More information about the gecode-users
mailing list


{% load bootstrap4 %}
This agreement is made by and between the Harvard Law School Library (the "Library") and the person named above ("you"). It governs the terms and conditions of unmetered access to caselaw data made available by the Library’s Caselaw Access Project ("CAP").
To be eligible for unmetered access to CAP cases, you must be:
If you do not meet one of these criteria, then you are not eligible for unmetered access to CAP cases. By accepting this agreement, you represent that the information you provide above concerning your identy and any affiliation is true and that you meet at least one of these criteria.
The CAP cases are being made available by the Library pursuant to its agreement with LexisNexis, a division of RELX Inc., which has certain exclusive rights to make use of the cases for purposes other than education and research. As such, the CAP cases are subject to the following important restrictions on usage and distribution, all of which you must accept in order to receive unmetered access to them:
By accepting this agreement, you accept these restrictions. If you do not accept these restrictions, then you cannot receive comprehensive unmetered access to CAP cases.
LexisNexis, a division of RELX Inc., is a third-party beneficiary of this agreement. Any violation of its restrictions may result in legal action against you by LexisNexis, a division of RELX Inc., to enforce these restrictions.


--- layout: post status: publish published: true title: The Reds are the most un-likeable team in the NL Central author: display_name: Corey Fineran login: Corey email<EMAIL_ADDRESS>url: '' author_login: Corey author_email<EMAIL_ADDRESS>wordpress_id: 3148 wordpress_url: http://ivyenvy.com/?p=3148 date: '2010-08-10 22:27:09 +0000' date_gmt: '2010-08-11 03:27:09 +0000' categories: - General Baseball tags: - All-Star Game - Asshat of the Week - Cardinals - Dusty Baker - Jim Edmonds - Joey Votto - NL Central - Oakland A's - Reds - St. Louis - Marlon Byrd - A's - Cincinnati - Bash Brothers - '1990' - Media - Brandon Phillips - Yadier Molina comments: - id: 1653 author: Rex author_email<EMAIL_ADDRESS>author_url: '' date: '2010-08-11 09:20:41 +0000' date_gmt: '2010-08-11 14:20:41 +0000' content: Spoken like a true Flubs fan. BP should not have ran his mouth but come on. Votto's comments were in jest...or did you fail to read that part of the story? Good luck next year. Maybe the Flubs will win 65 games. Nice series this past weekend, by the way. - id: 1654 author: Brown author_email<EMAIL_ADDRESS>author_url: '' date: '2010-08-11 09:56:53 +0000' date_gmt: '2010-08-11 14:56:53 +0000' content: "\"They apparently can not handle four months of winning baseball and I believe they will melt down in any sort of race to the finish.\"\r\n\r\nYou mean they will melt down the same way the Cubs have for the past 100+ years?" - id: 1655 author: Corey author_email<EMAIL_ADDRESS>author_url: '' date: '2010-08-11 10:06:36 +0000' date_gmt: '2010-08-11 15:06:36 +0000' content: I can understand your excitement about the Reds. I mean, you haven't had a winning season or finished better than 3rd place in 10 years. - id: 1656 author: Rex author_email<EMAIL_ADDRESS>author_url: '' date: '2010-08-11 10:37:32 +0000' date_gmt: '2010-08-11 15:37:32 +0000' content: So the Cubs are satisfied with winning a division title now and then? Sounds about right...1908, bro. 1908. - id: 1657 author: Corey author_email<EMAIL_ADDRESS>author_url: '' date: '2010-08-11 10:49:14 +0000' date_gmt: '2010-08-11 15:49:14 +0000' content: You mean to tell me the Cubs haven't won a World Series since 1908? WHAT?! - id: 1666 author: Ryan author_email<EMAIL_ADDRESS>author_url: '' date: '2010-08-12 13:20:46 +0000' date_gmt: '2010-08-12 18:20:46 +0000' content: "We're well aware that the Cubs haven't won a WS since 1908. All Corey was trying to say is that when September rolls around there's not a whole lot of pennant race experience on that team. \r\n\r\nAnd they're annoying. \r\n\r\nMeehan" - id: 1667 author: Ryan author_email<EMAIL_ADDRESS>author_url: '' date: '2010-08-12 13:29:29 +0000' date_gmt: '2010-08-12 18:29:29 +0000' content: "I agree with the point about being impartial. This is hard for me because I have a lot of friends in the Cincinnati area. But this year they have been much more cocky. Votto was flying under the radar for a while but that comment about Byrd kind of blew his humbleness quotient. \r\n\r\nMeehan" - id: 1668 author: Rex author_email<EMAIL_ADDRESS>author_url: '' date: '2010-08-12 13:40:35 +0000' date_gmt: '2010-08-12 18:40:35 +0000' content: Again, if you go back and look at the reports, it was totally in jest. He meant it about the Cubs fans, not the Cub players. I've been to well over 200 games at Riverfront/Cinergy/GABP.  No other team's fans are even close. Not even Phillies fans. - id: 1671 author: Ryan author_email<EMAIL_ADDRESS>author_url: '' date: '2010-08-13 19:51:24 +0000' date_gmt: '2010-08-14 00:51:24 +0000' content: "No, no, and no. \r\n\r\nA lot of Phillies fans are also Eagles fans and by almost every account in sports history, Eagles fans are the worst and it's not even close.\r\n\r\n\r\nMets fans are assholes because they're from New York so they have somewhat of an excuse.\r\n\r\nBut Phillies fans...no we are not nearly as hateful (and violent) as Phillies fans.\r\n\r\nMeehan" - id: 1680 author: Ryan author_email<EMAIL_ADDRESS>author_url: '' date: '2010-08-16 00:46:51 +0000' date_gmt: '2010-08-16 05:46:51 +0000' content: "I think we should mention that on tonight's show we discussed the Jim Edmonds thing and we all pretty much don't remember the media assaulting him like he claims.\r\n\r\nTo be perfectly honest with you, all I remember was he got the standard grief from the die hard fans from coming over from a team that we all hate more than anything in the world, but even before the time he hit his first home run, all of that disappeared. \r\n\r\nIt's your standard \"blame the media\" card, and it's a crock. According to these guys the media is responsible for when they hit .235, which is ridiculous. \r\n\r\nMeehan" ---
I never really minded the Reds. When I was 13, I put a Reds sticker on my dirt-bike to support them in their 1990 playoff run and World Series battle with the Bash Brothers and the rest of the Oakland A's. They haven't really been terribly relevant, and so I've had pretty impartial feelings towards them for years. When Dusty Baker was picked up by the Reds, I wanted to see them fail, just because I couldn't stand Dusty Baker. However, in the last month or so, the Reds are possibly becoming my most hated team in the division.
The Reds have become a cocky and outspoken team. There is a gray area of cocky and whiny and these Reds fall somewhere in the middle.
After the All-Star game, we awarded Joey Votto with our Asshat of the Week award for his comments about the Cubs and Marlon Byrd after Byrd's efforts to help the National League win home-field advantage, from which the Reds could possibly benefit.
I don't like the Cubs. And I'm not going to pat anybody with a Cubs uniform on the back.
But that's old news. Reds players have been in the news twice this week for their statements. This week, the Reds acquired Jim Edmonds to assist him in his tour of the NL Central - 4 teams down, 2 to go. Edmonds was asked if fans would warm up to him in Cincinnati and responded with this:
As long as it’s not as bad as it was in Chicago, I’ll be all right. The media killed me in Chicago for the first three weeks until I hit my first home run.
And then Brandon Phillips joined the party on Monday with his comments on the Cardinals.
I'd play against these guys with one leg. We have to beat these guys.   I really hate the Cardinals. Compared to the Cardinals, I love the Chicago Cubs.
Since the Cubs are out of post-season contention and although I am definitely no fan of the Cardinals, I am rooting for them to destroy these mouth-breathers from Cincinnati Northern Kentucky. They apparently can not handle four months of winning baseball and I believe they will melt down in any sort of race to the finish. They exhibit the inability to keep their cool and control themselves.


Create empty Git repo in specified directory. Run with no arguments to initialize the current directory as a git repository.
Clone repo located at
Clones a single branch on your local machine from the repo hosted on github
Define author name to be used for all commits in current repo. Devs commonly use --global flag to set config options for current user.
Stage all changes in
Commit the staged snapshot, but instead of launching a text editor, use
List which files are staged, unstaged, and untracked.
Display the entire commit history using the default format. For customization see additional options.
Show unstaged changes between your index and working directory.
Create new commit that undoes all of the changes made in
Remove
Shows which files would be removed from working directory. Use the -f flag in place of the -n flag to execute the clean.
 Use with nothing staged to edit the last commit’s message.
Rebase the current branch onto
Show a log of changes to the local repository’s HEAD. Add --relative-date flag to show date info or --all to show all refs
List all of the branches in your repo. Add a
Create and check out a new branch named
Merge
Create a new connection to a remote repo. After adding a remote, you can use
Fetches a specific
Fetch the specified remote’s copy of current branch and immediately merge it into the local copy
Push the branch to


{% extends 'base-complex.html' %} {% block scripts %} {% endblock %} {% block navbar_top_links %} {{ super() }}
| ID | Name | Host | Image | Command | Volumes | Env Vars | Expose Ports | Publish Ports | RAM Limit | # CPU Cores | Status | Username | Active | Created | Updated | Action |
|---|


Mud Puddles
问题描述 :
Farmer John is leaving his house promptly at 6 AM for his daily milking of Bessie. However, the previous evening saw a heavy rain, and the fields are quite muddy. FJ starts at the point (0, 0) in the coordinate plane and heads toward Bessie who is located at (X, Y) (-500 ≤ X ≤ 500; -500 ≤ Y ≤ 500). He can see all N (1 ≤ N ≤ 10,000) puddles of mud, located at points (Ai, Bi) (-500 ≤ Ai ≤ 500; -500 ≤ Bi ≤ 500) on the field. Each puddle occupies only the point it is on.
Having just bought new boots, Farmer John absolutely does not want to dirty them by stepping in a puddle, but he also wants to get to Bessie as quickly as possible. He’s already late because he had to count all the puddles. If Farmer John can only travel parallel to the axes and turn at points with integer coordinates, what is the shortest distance he must travel to reach Bessie and keep his boots clean? There will always be a path without mud that Farmer John can take to reach Bessie.
输入:
* Line 1: Three space-separate integers: X, Y, and N.
* Lines 2..N+1: Line i+1 contains two space-separated integers: Ai and Bi
输出:
* Line 1: The minimum distance that Farmer John has to travel to reach Bessie without stepping in mud.
样例输入:
1 2 7 0 2 -1 3 3 1 1 1 4 2 -1 1 2 2
样例输出:
11
解题代码:
//* @author: import java.io.BufferedInputStream; import java.util.LinkedList; import java.util.Scanner; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ public class Main { static int[][] field = new int[1001][1001]; static int y; static int n; static int x; public static void main(String[] args) { Scanner scan = new Scanner(new BufferedInputStream(System.in)); x = scan.nextInt(); y = scan.nextInt(); n = scan.nextInt(); field[x + 500][y + 500] = 1; for (int i = 0; i < n; i++) { int a = scan.nextInt(); int b = scan.nextInt(); field[a + 500][b + 500] = -1; } solve(); } public static void solve() { System.out.println(bsf(500, 500)); } public static int bsf(int r, int c) { LinkedList< Point> queue = new LinkedList(); queue.add(new Point(r, c, 0)); field[r][c] = -1; while (!queue.isEmpty()) { Point current = queue.removeFirst(); int ai = current.a; int bi = current.b; if (ai - 1 >= 0 && field[ai - 1][bi] == 0) { queue.addLast(new Point(ai - 1, bi, current.step + 1)); field[ai - 1][bi] = -1; } else if (field[ai - 1][bi] == 1) { return current.step + 1; } if (ai + 1 <= 1000 && field[ai + 1][bi] == 0) { queue.addLast(new Point(ai + 1, bi, current.step + 1)); field[ai + 1][bi] = -1; } else if (field[ai + 1][bi] == 1) { return current.step + 1; } if (bi - 1 >= 0 && field[ai][bi - 1] == 0) { queue.addLast(new Point(ai, bi - 1, current.step + 1)); field[ai][bi - 1] = -1; } else if (field[ai][bi - 1] == 1) { return current.step + 1; } if (bi + 1 <= 1000 && field[ai][bi + 1] == 0) { queue.addLast(new Point(ai, bi + 1, current.step + 1)); field[ai][bi + 1] = -1; } else if (field[ai][bi + 1] == 1) { return current.step + 1; } } return 0; } } class Point { int a = 0; int b = 0; int step = 0; public Point(int a, int b, int step) { this.a = a; this.b = b; this.step = step; } }
第二种解法如果数组有重复元素 就不正确
不错的网站，建议添加些比赛信息
很好。代码比书上的简练！
博主您好，这是一个内容十分优秀的博客，而且界面也非常漂亮。但是为什么博客的响应速度这么慢，虽然博客的主机在国外，但是我开启VPN还是经常响应很久，再者打开某些页面经常会出现数据库连接出错的提示
第二个是python代码啊。。
第二种想法，我想来好久，为啥需要一个newhead，发现是把最后一个节点一直返回到嘴上面这层函数。厉害，这道题之前没样子想过。
#include <stdio.h>
int main()
{
int n,p,t[100]={1};
for(int i=1;i<100;i++)
t =i;
while(scanf("%d",&n)&&n!=0){
if(n==1)
printf("Printing order for 1 pages:nSheet 1, front: Blank, 1n");
else {
if(n%4) p=n/4+1;
else p=n/4;
int q=4*p;
printf("Printing order for %d pages:n",n);
for(int i=0;i<p;i++){
printf("Sheet %d, front: ",i+1);
if(q>n) {printf("Blank, %dn",t[2*i+1]);}
else {printf("%d, %dn",q,t[2*i+1]);}
q–;//打印表前
printf("Sheet %d, back : ",i+1);
if(q>n) {printf("%d, Blankn",t[2*i+2]);}
else {printf("%d, %dn",t[2*i+2],q);}
q–;//打印表后
}
}
}
return 0;
}
代码是给出了，但是解析的也太不清晰了吧！如 13 abejkcfghid jkebfghicda
第一步拆分为 三部分 (bejk, cfghi, d) * C(13,3)，为什么要这样拆分，原则是什么？
前排支持
居然看懂了
和编译器有关吧，我用的g++正常。头文件可能还需要一个<string.h>
nice!!!


ACROSS 1. Company that epitomizes the Big Apple? (4) 3. A first laundry load (10) 9. Finally David Landau got basic French language (5) 11. Treat from crazy redhead? (6, 3) 12. Inferior cousin to the lemon is simply wonderful (7) 13. Reportedly joins White's counterparts (5) 15. Fair lady broke old toilet (9) 17. Fur bales destroyed (5) 19. Schlemiel found in Jell-O serving (5) 21.  Israeli start-up (5) 24. Cook chicken for infidel (7) 26. Riddle’s sister is into fish and booze (9) 27. Message – “Dorothy’s aunt hurt” (5) 28. Stir shreds around and put this on your chest (5, 5) 29. I suppose shaggy animal returned with love (4) DOWN 1. Adds diesel haphazardly to ride this way (10) 2. These hold words of love and a returned wager enclosed in hidden places (9) 4. Awkwardly glean – it’s sometimes right (5) 5. Spooner takes two rabbits and makes a kinkajou (5, 4) 6. The French follow requirement – they have several points (7) 7. Loud character (like Daffy Duck) is here in North Africa (5) 8. Join a tea party to find great guy (4) 10. 'Detest Earl Grey!' said an American neighbor (5) 14. Speaking for oneself, for one's child, and friend (10) 16. Naughty tenor hurt One Direction (4, 5) 18. Benjamin and Markus surround church standard (9) 20. About fellows and governors (7) 22. Fish feature musical range (5) 23. Grabbing everything in sight! (5) 24. Simpson’s an epic writer (5) 25. Tossed dice – really cool! (4)


List and Tree Controls
JBList and Tree
Whenever you would normally use a standard
Swing JList
component, it’s recommended to use the
JBList
class as drop-in replacement.
JBList
supports the following additional features on top of
JList
:
-
Drawing a tooltip with complete text of an item if the item doesn’t fit into the list box width.
-
Drawing a gray text message in the middle of the list box when it contains no items. The text can be customized by calling
getEmptyText().setText()
. -
Drawing a busy icon in the top right corner of the list box to indicate that a background operation is being performed. This can be enabled by calling
setPaintBusy()
.
Similarly, the
Tree
class provides a replacement for the standard
JTree
class.
In addition to the features of
JBList
,
it supports wide selection painting (Mac style) and auto-scroll on drag & drop.
ColoredListCellRenderer and ColoredTreeCellRenderer
When you need to customize the presentation of items in a list box or a tree, it’s recommended to use the
ColoredListCellRenderer
or
ColoredTreeCellRenderer
classes as the cell renderer.
These classes allow you to compose the presentation out of multiple text fragments with different attributes by calling append()
and to set an optional icon for the item by calling setIcon
.
The renderer automatically takes care of setting the correct text color for selected items and of many other platform-specific rendering details.
ListSpeedSearch and TreeSpeedSearch
To facilitate keyboard-based selection of items in a list box or a tree, you can install a speed search handler on it using the
ListSpeedSearch
and
TreeSpeedSearch
.
This can be done simply by calling new ListSpeedSearch(list)
or new TreeSpeedSearch(tree)
.
If you need to customize the text which is used to locate the element, you can override the getElementText()
method.
Alternatively, you can pass a function to convert items to strings.
A function needs to be passed as elementTextDelegate
to the
ListSpeedSearch
constructor or as toString
to the
TreeSpeedSearch
constructor.
ToolbarDecorator
A very common task in plugin development is showing a list or a tree where the user is allowed to add, remove, edit or reorder the items.
The implementation of this task is greatly facilitated by the
ToolbarDecorator
class.
This class provides a toolbar with actions on items and automatically enables drag & drop reordering of items in list boxes if supported by the underlying list model.
The position of the toolbar above or below the list depends on the platform under which the IDE is running.
To use a toolbar decorator:
-
If you need to support removing and reordering of items in a list box, make sure the model of your list implements the
EditableModel
interface.CollectionListModel
is a handy model class that implements this interface. -
Call
ToolbarDecorator.createDecorator()
to create a decorator instance. -
If you need to support adding and/or removing items, call
setAddAction()
and/orsetRemoveAction()
. -
If you need other buttons in additional to the standard ones, call
addExtraAction()
orsetActionGroup()
. -
Call
createPanel()
and add the component it returns to your panel.


This appendix is normative.
This appendix describes how to expose the SVG DOM to an ECMAScript language environment [ECMA-262].
For descriptions of how interfaces and exceptions defined in other specifications are to be exposed to an ECMAScript language environment, consult the relevant specification:
The SVG DOM defines a single exception, SVGException, which is exposed to an ECMAScript language environment as follows.
The ECMAScript global object has a property named "SVGException"
whose value is an object with the following properties:
"SVG_WRONG_TYPE_ERR"
, whose value is the Number value 1."SVG_INVALID_VALUE_ERR"
, whose value is the Number value 2."SVG_MATRIX_NOT_INVERTABLE"
, whose value is the Number value 3.A host object that is an SVGException also has these three
properties on itself, or somewhere in its prototype chain. Every such host
object also has a read only property named "code"
whose value is a
Number, corresponding to the
code exception member on SVGException.
For every interface defined in the SVG DOM that has one or more constants defined on it, there exists a property on the ECMAScript global object whose name is the name of the interface, and whose value is an object with a read only property for each of the constants. The name of each of these read only properties is the name of the corresponding constant, and the value is a Number with the same value as that of the constant.
A host object that implements an interface with constants defined on it has, on itself or somewhere in its prototype chain, these properties that correspond to the constants.
The following table gives the corresponding ECMAScript type for the IDL primitive types used in the SVG DOM.
| IDL type | ECMAScript type |
|---|---|
| boolean | Boolean |
| float | Number |
| long | Number |
| unsigned short | Number |
| unsigned long | Number |
| DOMString | String |
When an ECMAScript Number is assigned to a property that corresponds to an attribute of an IDL integer type (long, unsigned short or unsigned long), or it is passed as an argument passed to an operation for which the argument type is an IDL integer type, then behavior is undefined if the Number value is not an integer within the range of that type.
For an interface type, a host object that implements the given interface is used.
A host object that implements a given interface has properties on itself, or in its prototype chain, that correspond to the operations and attributes defined on that interface and all its superinterfaces.
A property that corresponds to an attribute is read only if the attribute is read only, and has a name that is the same as the name of the attribute. When getting the property, a value of a type according to the Types section above is returned. When setting the property, if it is not read only, then behavior is defined only if a value of a type according to the Types section is assigned to it.
For example, if a is a host object that implements the SVGLength interface, then evaluating the statement:
a.valueAsString = "10";
has defined behavior, but evaluating the statement:
a.valueAsString = 10;
does not.
A property that corresponds to an operation has a name that is the same as the name of the operation, and has a value that is a Function object. The value returned from the Function is of a type according to the table in the Types section above. When calling the Function, behavior is only defined if the correct number of arguments is passed, and the type of each argument is the type according to the Types table. Also, behavior is only defined for invoking the Function with a this value that is equal to the object from which the Function was obtained.
For example, if L1 and L2 are two distinct host objects that implement the SVGPointList interface and p is a host object that implements the SVGPoint interface, then evaluating the following statement has defined behavior:
L1.insertItemBefore(p, 0);
Evaluating any of the following statements, however, does not:
L1.insertItemBefore(p, '0'); L1.insertItemBefore(p, -1); L1.insertItemBefore(p, 0.5); L1.insertItemBefore(p); L1.insertItemBefore(p, 0, 0); L1.insertItemBefore({ x: 10, y: 20 }, 0); L1.insertItemBefore.call([], p, 0); L1.insertItemBefore.call(L2, p, 0);


Lipsum
Lipsum agnoangs and more more final more.
String first. Now a string in a P. And another one in a P. And a string to end.
Now a string in a P.
And another one in a P.
Footer?
2019


Home
About Us
Our Partners
Our Services
Work Experience
Hire Us
Our Training
Contact Us
Quote Us
Name
*
Email
*
Phone
*
Agreement 1
*
Agreement 2
Send
Phone
*
Agreement 1
*
Send
Find us on Google map


org.flexiblepower.ral.ext
RS
- The type of the ResourceState
RCP
- The type of the ResourceControlParameters
public abstract class AbstractResourceManager<RS extends ResourceState,RCP extends ResourceControlParameters> extends java.lang.Object implements ResourceManager
ResourceManager
which does simple translation, possible while keeping
state information.| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger
The logger that should be used by any subclass.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractResourceManager()
Creates a new instance for the specific driver class type and the control space class.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
allocationStatusUpdate(AllocationStatusUpdate allocationStatusUpdate)
Send status update to attached controller.
|
protected abstract ControlSpaceRevoke |
createRevokeMessage()
This method is called when a revoke message is needed (e.g.
|
protected boolean |
isConnectedWithResourceController()
Indicate if this
ResourceManager is currently connected to a ControllerManager . |
protected boolean |
isConnectedWithResourceDriver()
Indicate if this
ResourceManager is currently connected to a ResourceDriver . |
org.flexiblepower.messaging.MessageHandler |
onConnect(org.flexiblepower.messaging.Connection connection) |
protected abstract RCP |
receivedAllocation(ResourceMessage message)
This method is called when a message has been received from the controller.
|
protected void |
sendControlParameters(ResourceControlParameters controlParameters)
Send control parameters to attached driver.
|
protected abstract java.util.List<? extends ResourceMessage> |
startRegistration(RS state)
This method is called when the first state has been received from the driver and a registration is needed.
|
protected void |
unconnectedStateUpdate(RS state)
This method is called when a state update from the driver has been received, but this manager is not connected.
|
protected abstract java.util.List<? extends ResourceMessage> |
updatedState(RS state)
This method is called when the state is updated and the
startRegistration(ResourceState) has already
been called previously. |
protected final org.slf4j.Logger logger
protected AbstractResourceManager()
protected void unconnectedStateUpdate(RS state)
state
- The state of the driverprotected abstract java.util.List<? extends ResourceMessage> startRegistration(RS state)
ResourceMessage
s that should at least contain a registration message.state
- The state of the driverResourceMessage
s that will be sent to the controller.protected abstract java.util.List<? extends ResourceMessage> updatedState(RS state)
startRegistration(ResourceState)
has already
been called previously.state
- The state of the driverResourceMessage
s that will be sent to the controller.protected abstract RCP receivedAllocation(ResourceMessage message)
Allocation
object, but could also be of another type, depending on the used message type.message
- The received messageResourceControlParameters
that should be sent to the driver.protected abstract ControlSpaceRevoke createRevokeMessage()
ControlSpaceRevoke
that will be sent to the controller.public org.flexiblepower.messaging.MessageHandler onConnect(org.flexiblepower.messaging.Connection connection)
onConnect
in interface org.flexiblepower.messaging.Endpoint
protected boolean isConnectedWithResourceController()
ResourceManager
is currently connected to a ControllerManager
.ResourceManager
is currently connected to a ControllerManager
protected boolean isConnectedWithResourceDriver()
ResourceManager
is currently connected to a ResourceDriver
.ResourceManager
is currently connected to a ResourceDriver
protected void allocationStatusUpdate(AllocationStatusUpdate allocationStatusUpdate)
allocationStatusUpdate
- The AllocationStatusUpdate
that is to be sent to the controller.protected void sendControlParameters(ResourceControlParameters controlParameters)
controlParameters
- The parameters that have to be sent to the driver