Lab 3: More Haskell Calculators
Announcements
Office hours 12 - 3:15 on Wednesday (this week only). Normal office hours resume next week.
Building a Simple Haskell Calculator
Later in the course you will consider monadic parsing but in this lab we will focus on the simple parsing problem of constructing a calculator.
The calculator should work as follows:
> 1 + 1
2
> 2 * 6
12
> (1 + 3) * (5 + 1)
24
> (1 + 2 + 3 * 2 + 6)
15
> (1 + (2 + ((4 + 2) * 6)))
39
> 5 +-6 --This should be parsed as 5 + (-6)
-1
where user-input is indicated by a prepended >. The lab consists of:
- Create a data type
ArithExpr
to represent an expression - Implement a function
eval
to evaluate the expression to a number - Implement a fuction
simpleParseExpr
to parse a string into an expression - Use the functions above to read user input and using
fmap
parse the string into an integer and return the result - Plug into a calculator program
Skeleton Program
import System.IO
main :: IO ()
main = do
putStr "> "
hFlush stdout
line <- getLine
putStrLn line
main
This is the basis for the calculator program. It is your responsibility to incorporate your calculator into this base program.
ArithExpr
Defining the ArithExpr
Data Type. Recursion is the name of the game.
This data type should represent
- a constructor
Number
for positive or negative integers - Addition and Multiplication operators represented by the constructors
Plus
andMult
. These operators are most easily defined as a data constructor taking two arguments. - Division
Div
andMod
should follow the conventions from lab1 (possibly usequot
ordiv
here) - precedence should be
Mod > Div > Mult > Plus
The abstract ArithExpr
form for (2+3)*(3+2)
would be
(Mult (Plus (Number 2) (Number 3)) (Plus (Number 3) (Number 2)))
Evaluating an ArithExpr
Again, use recursion. eval
should be a function that takes ArithExpr
and outputs a number. This is the first thing to get working. Check that it works by ensuring that you get the right outputs for:
(Mult (Plus (Number 2) (Number 3)) (Plus (Number 3) (Number 2)))
(Mod (Plus (Number 2) (Number 3)) (Div (Number 13) (Number 6)))
(Plus (Mod (Mult (Number 2) (Number 3)) (Div (Number 13) (Number (-6)))) (Plus
(Number (-10)) (Number 2)) )
and some other expression. Generate your own simple ones and make sure that things work. Put those in your sample runs file TestLab3.hs
.
Parsing a String to ArithExpr
The input will be *, -, +, [0-9], (, ), %, /
and the -
will always precede a number [0-9]
.
- Remove whitespace with
isSpace
in the libraryData.Char
- Tokenize. Break-up the expression into tokens: numbers (positive or negative), operators, or parenthetical expression.
- The functions
dropWhile
,takeWhile
, andspan
inData.List
are helpful here. AlsoisDigit
inData.Char
is useful. - Turn the tokens into an
ArithExpr
. Useread
to get integers out(read x :: Int)
. Thinking about arithmetic it makes sense to split the list at the operator of least precedence and then recurse on the elements. show x
turns andInt
toString
Work incrementally. Start with a tokenizer, begin by tokenezing simple expressions:
1+2
1 + 2
1 * -2
then move to harder and harder expressions
(1+2)
(1 + 2 )
(-10 + 2) * 5
Put the tokenizer
sample run tests in TestLab3.hs
. Once you are convinced the tokenizer can handle all simple expressions (and more complicated ones), ensure that eval
can handle all of the expressions.
Tokens to ArithExpr
Expanding on the third step a little more: think about the expression 4*3+4
which should be broken up into 4*3, +, 4
. The function break will be useful for this. I called my function that does this buildExpr
and in the above example buildExpr
is implemented as a composition of a parser parse
and a tokenizer tokenizer
. So that buildExpr = parse . tokenizer
where tokenizer
splits a string into tokens, e.g. " 4 * -32"
into ["4","*","-32"]
. parse
converts the output of tokenizer
into an ArithExpr
. You may assume all inputs are well-formed.
Submit
Make a lab3
folder with Lab3.hs
and TestLab3.hs
. Lab3.hs
should export functions to test for TestLab3.hs
follow the syntax in Lab1.hs
from the first lab to understand modules (or check the course notes). TestLab3.hs
should have sample runs implemented as tests, e.g.:
test1 = eval (Plus (Number 1) (Number 1)) == 0
and a final tests list:
tests = [test1, test2, ..., testn]
testAll = all id tests
You are primarily evaluated on whether you correctly implement the calculator.
Extra-Credit
For extra-credit implement a file Lab3Rational.hs
and TestLab3Rational.hs
which works with rational numbers. The inputs should be the same expressions but the outputs are now rational numbers so that the output for .75
would be 3 / 4
. TestLab3Rational.hs
should also throw an error properly if there is a division by zero.


Id: 413
Name: Old Women
Status: unknown
Species: Human
Type: Old Amazons
Gender: Female
OriginName: Interdimensional Cable
OriginUrl: https://rickandmortyapi.com/api/location/6
LocationName: Interdimensional Cable
LocationUrl: https://rickandmortyapi.com/api/location/6
Image: https://rickandmortyapi.com/api/character/avatar/413.jpeg
Episode: ['https://rickandmortyapi.com/api/episode/8']
Url: https://rickandmortyapi.com/api/character/413
Created: 2018-04-15T21:21:32.623Z


Author: Matthew Leonawicz
License: MIT
The trekcolors
package provides a collection of color palettes based on Star Trek. It also offers functions for custom palettes and scale_*
functions for use with ggplot2
.
Install the CRAN release of trekcolors
with
install.packages("trekcolors")
Install the development version from GitHub with
# install.packages("remotes")
remotes::install_github("leonawicz/trekcolors")
library(trekcolors)
library(ggplot2)
trek_pal("starfleet")
#> [1] "#5B1414" "#AD722C" "#1A6384"
trek_pal("lcars_2357")
#> [1] "#FFFF99" "#FFCC99" "#FFCC66" "#FF9933" "#664466" "#CC99CC" "#99CCFF" "#3366CC" "#006699"
lcars_pal("2357") # there are some special functions for LCARS colors
#> [1] "#FFFF99" "#FFCC99" "#FFCC66" "#FF9933" "#664466" "#CC99CC" "#99CCFF" "#3366CC" "#006699"
Preview the starfleet
and lcars_2357
palettes.
view_trek_pals(c("starfleet", "lcars_2357"))
p <- ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) +
geom_point(size = 5, alpha = 0.75)
p + scale_color_trek() # starfleet is default palette
p <- ggplot(diamonds, aes(carat, price, color = clarity)) +
geom_point()
p + scale_color_lcars("2357") # equivalent to scale_color_trek("lcars_2357")
p <- ggplot(diamonds, aes(carat, stat(count), fill = cut)) +
geom_density(position = "fill")
p + scale_fill_trek("klingon")
p + scale_fill_trek("romulan")
p + scale_fill_trek("andorian")
p <- ggplot(diamonds, aes(carat, stat(count), fill = cut)) +
geom_density(position = "fill")
p + scale_fill_lcars("2357")
p + scale_fill_lcars1("atomic-tangerine", dark = TRUE)
p + scale_fill_lcars2("pale-canary", "danub")
d <- diamonds[diamonds$cut >= "Very Good", ]
p <- ggplot(d, aes(carat, stat(count), fill = cut)) +
geom_density(position = "fill")
p + scale_fill_trek("starfleet")
The four LCARS palettes that have a year in their series name are special in that these official standard LCARS colors have formal names.
# lcars_pals() # print list of all LCARS palettes
lcars_colors() # full set of unique names across the four palettes
#> pale-canary tanoi golden-tanoi neon-carrot eggplant lilac anakiwa mariner bahama-blue blue-bell
#> "#FFFF99" "#FFCC99" "#FFCC66" "#FF9933" "#664466" "#CC99CC" "#99CCFF" "#3366CC" "#006699" "#9999CC"
#> melrose hopbush chestnut-rose orange-peel atomic-tangerine danub indigo lavender-purple cosmic red-damask
#> "#9999FF" "#CC6699" "#CC6666" "#FF9966" "#FF9900" "#6688CC" "#4455BB" "#9977AA" "#774466" "#DD6644"
#> medium-carmine bourbon sandy-brown periwinkle dodger-pale dodger-soft near-blue navy-blue husk rust
#> "#AA5533" "#BB6622" "#EE9955" "#CCDDFF" "#5599FF" "#3366FF" "#0011EE" "#000088" "#BBAA55" "#BB4411"
#> tamarillo
#> "#882211"
lcars_2357() # specific color series; also 2369, 2375, 2379
#> pale-canary tanoi golden-tanoi neon-carrot eggplant lilac anakiwa mariner bahama-blue
#> "#FFFF99" "#FFCC99" "#FFCC66" "#FF9933" "#664466" "#CC99CC" "#99CCFF" "#3366CC" "#006699"
lcars_2357("lilac", "mariner") # select by name
#> lilac mariner
#> "#CC99CC" "#3366CC"
In addition to these and all the other predefined palettes, custom palettes can be constructed using official LCARS color names. This is like colorRampPalette
but with the ability to recognize official LCARS color names. This functionality was leveraged by scale_color_lcars1
and scale_color_lcars2
seen above when making sequential or divergent palettes based on specific LCARS colors for use with ggplot.
lcars_custom_pal <- lcars_colors_pal(c("pale-canary", "eggplant"))
lcars_custom_pal(8)
#> [1] "#FFFF99" "#E9E491" "#D3C98A" "#BDAE83" "#A7947B" "#917974" "#7B5E6D" "#664466"
p <- ggplot(diamonds, aes(carat, stat(count), fill = cut)) +
geom_density(position = "fill")
p + scale_fill_lcars2("pale-canary", "danub")
# p + scale_fill_manual(values = lcars_custom_pal(8)) # equivalent
p + scale_fill_lcars2("pale-canary", "danub", divergent = TRUE)
p + scale_fill_lcars2("pale-canary", "danub", dark = TRUE, divergent = TRUE)
# See available palette names
trek_pal()
#> [1] "andorian" "bajoran" "borg" "breen" "breen2" "dominion" "enara" "enara2"
#> [9] "ferengi" "gorn" "iconian" "klingon" "lcars_series" "lcars_2357" "lcars_2369" "lcars_2375"
#> [17] "lcars_2379" "lcars_alt" "lcars_first_contact" "lcars_nemesis" "lcars_nx01" "lcars_29c" "lcars_23c" "lcars_red_alert"
#> [25] "lcars_cardassian" "romulan" "romulan2" "starfleet" "starfleet2" "tholian" "terran" "ufp"
#> [33] "red_alert" "yellow_alert" "black_alert"
# view all predefined palettes
view_trek_pals()
rtrek: The core Star Trek package
Datasets related to Star Trek, API wrappers to external data sources, and more.
lcars: LCARS aesthetic for Shiny
Create Shiny apps based on the Library Computer Access/Retrieval System (LCARS).
trekcolors: A color palette package
Predefined and customizable Star Trek themed color palettes and related functions.
Matthew Leonawicz (2021). trekcolors: Star Trek Color Palettes. R package version 0.1.3. https://CRAN.R-project.org/package=trekcolors
Contributions are welcome. Contribute through GitHub via pull request. Please create an issue first if it is regarding any substantive feature add or change.
Please note that the trekcolors
project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.


Chile to vote on new constitution
Protesters sought replacement of charter, in force since 1980.
by AFPChile announced on Friday it will stage a referendum to replace the country’s dictatorship-era constitution — a key demand of protesters after nearly a month of sometimes violent civil unrest.
The current charter, in force since 1980 and enacted by the former military junta of Augusto Pinochet, has been changed numerous times in the years since.
But it does not establish the state’s responsibility to provide education and healthcare — two demands made by millions of Chileans who have taken to the streets.
Lawmakers in Chile’s National Congress agreed on Friday to hold the plebiscite in April 2020 after hours of intense negotiations between the governing coalition and opposition parties. The unrest began on October 18. “This agreement is a first step, but it is a historic and fundamental first step to start building our new social pact, and in this the citizenry will have a leading role,” said Interior Minister Gonzalo Blumel.
The referendum will ask voters whether the constitution should be replaced and if so, how a new charter should be drafted, Senate president Jaime Quintana said.


I have used nutmeg around 5-6 times. The most important things I learned to remember:
1. Never have anything important to do.
2. Never be around people that I don't like.
3. Have 3-5 days of rest.
4. Drink lots of water (NOT pop), before during and after. (This tends to get rid of the side effects. Many people dislike nutmeg, it is too weak or too strong for some, and sometimes has nasty side effects.)
This is an account of my most memorable and recent trip.
Noon - I ingest 3 tbsp of nutmeg.
1:00 - No effects yet, like expected.
2:00 - Mild pot-like buzz.
3:00 - Things get interesting. At times nutmeg feels like acid, pot and MDMA. Acid-like patterns form, short term memory is non-existent. My body feels lightweight, and heavy at the same time.
It was difficult to concentrate on the movie. I had decided that I shouldn't have gone to a public place. I needed to go pee but was afraid that I would get lost and go into the wrong theater. Eventually I got the courage to go to the bathroom. Upon returning I watched the rest of the movie, and the fight scenes looked and sounded cool. All of the characters in the movie were moving in slow motion at times that it would not have made sense for the effect to be there.
10:00 - I was frozen in a euphoric state, unable to move. I have never done heroin, but this is what I guessed it would feel like.
Sounds were very loud. Visually there were few effects unless I meditated. I had a feeling of grandeur throughout the rest of the trip. I felt like I was the king of the room I was in and my pets were my servants. My lizard, which is a bearded dragon, was my bodyguard.
2 days later - My mind was gone until a few days afterward. I enjoyed the trip. This is a definite boredom drug. If you are bored and have the time, go ahead and do it. I DO NOT recommend doing this drug if you are not experienced in chemicals.
PEACE.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


Total Filtered Client: {{filtered.length}}
Filter by Company
Check All
Uncheck All
{{company.name}}
Clients Table:
#
Name
Designation
Company
{{$index + 1}}
{{client.name}}
{{client.designation}}
{{client.company.name}}


Discrete Fourier Transform:
\begin{equation} X[n] = \sum_{k=0}^{N-1} x[k] e^{-j \frac{2 \pi}{N} n k} \end{equation}
topic: "Asset/A1000/rotaryVelocity_S"
payload: {
"dateTime": "2019-03-08T15:43:44.808Z",
"assetId" : "A1000",
"dataItemId" : "rotaryVelocity_S",
"value" : 1002
}
topic: "Asset/A1000/Vibration"
payload: {
"dateTime": "2019-03-08T15:43:44.808Z",
"assetId" : "A1000",
"dataItemId" : "Vibration",
"iteminstanceId" : "Part_1001",
"sensorId": "accelerometer1",
"samplingInterval":0.00048828125,
"Kurtosis": 0.033,
"mean": -0.040,
"rootMeanSquare": 0.025,
"skewness": -0.204,
"variance": 0.001,
"PSDFreqInterval":10,
"PSDAmps":[0.895,0.889,...,0.877]
}
Record mean time required to perform inference on models
Why use external sensors?


Why Is An F-35 Sitting On The Deck Of HMS Queen Elizabeth?
The F-35 aircraft will remain on HMS Queen Elizabeth until repair and maintenance work is complete.
One of the UK's F-35 aircraft has travelled back home on HMS Queen Elizabeth after developing a fault in the US.
A Royal Navy spokesperson said that after flight trials in the United States, one of the Lightning jets will need to undergo repair and maintenance work.
"Following completion of successful flying trials in the US, one F-35 Lightning remained embarked on HMS Queen Elizabeth in order for repair and maintenance work to be completed," the spokesperson said.
"The aircraft will return to RAF Marham in the near future."
The F-35 was unable to fly home from the US because of the technical problem.
The aircraft is expected to take off from the aircraft carrier in Portsmouth and fly back to RAF Marham once the fault has been addressed.
In a tweet, HM Naval Base Portsmouth dismissed rumours suggesting the F-35 could take off on Monday.
Cover image: Royal Navy.


AWC
Simple Hero Image - test
Lorem Ipsum
"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
"There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain..."


January 2
Look Up!
Consider [Jesus] that endured such contradiction of sinners against himself, lest ye be wearied and faint in your minds.
Hebrews 12:3
Look up...because in times like these, your very life may depend on it.
Some time ago, the Lord showed me that a spirit of weariness is trying to work its way into our lives these days through all the pressure and bad news that surrounds us. It's working to get our eyes off the Word of God by bombarding us with negative forces. It's trying to get us to look down at defeat instead of up at Jesus.
If you let that happen, your spirit man will begin to lose his dominion. And the Word tells us what the results of that is. It says you will "be wearied and faint in your minds."
Jesus put it this way in Mark 4. He said that when the cares of this world enter into your heart and mind, they'll choke the Word and cause it to become unfruitful. And since your faith is the product of the Word, that means your faith will wither. Once that happens, you're headed for disaster.
What can you do to stop this chain reaction of weariness?
  I remember on the field of athletic competition that when an opponent allowed himself to drop his head, he was no longer dangerous. He could be very easily defeated.  Keep considering Jesus, the Author and Finisher of your faith. Consider Him instead of the cares of this world. Consider what God says in His Word. Be moved by the thoughts of God. Let His thoughts become your thoughts.
  Don't be afraid you're going to lose everything. God is your Source, not the world. He can take care of you regardless of what happens around you.
If you've gotten weary lately, begin to lift your eyes. Raise your head up instead of looking down. God is up. Jesus is up. The devil is down--under your feet.  Scripture Reading: Isaiah 40:21-31


SampleHost Blogging Platform
The application encountered one or more errors:
{% for error in e %}
{{ error }}
{% endfor %}


Training Day (2001) Denzel Washington, Ethan Hawke, Scott Glenn, Tom Berenger, Harris Yulin, Raymond J. Barry, Cliff Curtis, Dr. Dre, Snoop Dogg, Macy Gray. Screenplay by David Ayer. Directed by Anthony Fuqua. 120 minutes. Rated R, 3.5 stars (out of five stars)
Review by Ed Johnson-Ott, NUVO Newsweekly www.nuvo.net Archive reviews at http://reviews.imdb.com/ReviewsBy?Edward+Johnson-Ott To receive reviews by e-mail at no charge, send subscription requests to<EMAIL_ADDRESS>or e-mail<EMAIL_ADDRESS>with the word "subscribe" in the subject line.
A few years ago, while reviewing a Denzel Washington film where his character falls on hard times, I expressed doubt whether he could ever credibly play a bad guy. The charismatic actor is such a natural Boy Scout, I speculated, that portraying true evil might simply be beyond him. Was I ever wrong.  And when you see the film, you'll understand why "hell" is such a fitting word.  While the ending suffers from an overload of coincidences and contrivances, the movie still packs a wallop as it asks the question: Can honorable men deal with the worst of humanity on a daily basis without being corrupted?
Ethan Hawke (or as I've always thought of him, the wince-meister) plays Jake Hoyt, a Los Angeles cop out to become detective. To that end, he tries to join an elite squad led by Alonzo Harris (Washington), an undercover officer legendary for his effectiveness. The hitch is that Jake has only one day to prove his worthiness to Alonzo.
The 13-year veteran narc tears into the kid immediately, challenging his straight-arrow training. "This is street justice," he declares. "It takes a wolf to catch a wolf... It's ugly, but it's like that." Within minutes, Alonzo bullies Jake into smoking a joint laced with a variety of chemicals. Stoned out of his mind, Jake tries to keep his bearings as Alonzo tours the grimmest parts of the city, introducing him to one incredibly dangerous character after another.
Even within his drug haze, the boy soon realizes that Alonzo is not merely an officer that plays fast and loose with the rules - he's a full-fledged rogue cop willing to do anything to get what he wants.
Some of the most harrowing moments take place in a neighborhood completely under the control of thugs. Alonzo lives there, convinced he is respected by his brutal neighbors due to his ability to work the system. In fact, they loathe the man and put up with him solely because of his badge and gun.
 The film creates and maintains a sense of genuine danger. As the proceedings grow ever more dark, you begin to wonder if the key players can possibly survive the day. Until the last 15 minutes, that is, when the story wraps up too quickly and in far too pat a fashion.
Regardless, "Training Day" is one of the stronger action/character studies to be released by a major studio in quite a while. Those able to withstand the intensity and violence will be rewarded with solid acting by Ethan Hawke and a towering performance from Denzel Washington, an artist who still has the capability to surprise.
© 2001 Ed Johnson-Ott
========== X-RAMR-ID: 29694 X-Language: en X-RT-ReviewID: 252614 X-RT-TitleID: 1110027 X-RT-SourceID: 591 X-RT-AuthorID: 1099
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


Prototype Scope
A new instance on every injection request. Use it for stateful beans.
Destruction lifecycle methods callback are not called for prototypes. Use bean post-processing.


If you have a design already in mind or even just an idea, we can make it a reality.
Need a new bedroom or two? Additions are one of the best ways to increase the value of your home.
Remodeling your property will give it a fresh new look without having to spend a fortune on a new home. Minor details can make a huge difference.
We have an in house architect that can help you design the home of your dreams. We offer services that will take you from ideas in your head to keys in your hands!
We're fully licensed to do home inspections as well. If you already found a home, we can help you know what to look for.
General Contractor
Architect
Residential Contractor


The Board Game Guru is a brand new tool to help solve all of your board game needs. Our intuitive and interactive process takes in reviews from thousands of games and applies machine learning and natural language processing to find exactly the board that you are looking.
This is the final project for the UC Berkeley W210 class.
To learn more about our project, visit our
PLACEHOLDER HERE.


100 Burpee squat (1 Burpee + 1 Air squat) With a continuous running clock, every 5 min stop and run 400m. Continue with Burpee squat, stopping and running 400m at every 5 min interval until all 100 Burpee squats are completed. Record time and number of 400m runs.


Welcome to my first post. I'm teaching myself web dev so I figured what better way to get started. I imagine that it will be amusing to come back to this and see just how far I've come.
I am currently working on building a couple games in Unity as well. It is rewarding to build something and see it come to life on the screen. I hope to one day become professional, but until then it is a great way to learn and keep the old puzzle sponge sharp.


Github: @liawesomesaucer
Linkedin: vincentliaw
Email<EMAIL_ADDRESS>Team Solomid's News Site
Redesigning SD Hacks.
Code
Small workshop-focused hackathons.
Design at UCSD 2017


My journey at Dev Bootcamp has come to an end. As I look back on my experience, I can't help but feel an overwelming sense of accomplishment. From having thoughts of never being able to learn how to code, to completing full funcitoning web applications has made me a stronger person. The confidence that I gained from this experience is not anything like I have ever felt.
From my blog post about how at my age, I felt that it would be next to impossible to learn somethine new. Let alone something that isn't easy for most. (Check out that Post!) I'm not going to lie, the first 3 weeks of the onsite portion of the course was very demanding and had me questioning my decision to take on the challenge. However, my cohort mates and instructors cheered me on. With thier support and the support of my family, I was able to break through a barrier which I thought was pivotal in my learning. I had to learn to deal with the confusion of learning at such a fast pace. The ability to hold on to concepts was very difficult. As my brain started to adapt at the pace of learning, and teaching myself how to learn, I was able to make it through the first phase of the curriculum.
With the foundations of programming utilizing the Ruby language, I entered the second phase and the world of Ruby on Rails. I was then faced with a new challenge. This phase for me, required much more memorization and the development of muscle memory. This was very different from the first phase as it was more focused on critical thinking and problem solving using programming. This was direct application of that skillset to build web applications. Although it wasn't easy, I found it much more enjoyable as I could see the fruits of my labor come to life on a web page. Learning to use AJAX as a way to make my applications faster and have less calls to eh database and learning JavaScript to interact with the users of my applications was fun and eye opening.
The third phase at Dev Bootcamp is more designed to start having the students working as if they were in a work enviornment. There is far less instruction from the teachers, and more discovery by yourself. We had to build web applications for our final projects from ideas that we pitched as a group. The ideas were voted on and teams were formed. From there, we talked about the different technologies we were interested in using to build our applications. From technologies we learned during our time at Dev Bootcamp as well as new technologies we would have to teach ourselves in a very short time span. We were given a total of 7 days to build our applications from scratch. I must say that it was one of the hardest times I have worked on anything in my life. Working 14 hour days for almost all 7 days was very grueling but also very rewarding.
Even with some days being extremely difficult and feeling defeated, I feel that the times of feeling the accomplishment of completing the course and walking out with the skills I need to enter the web development industry has been amazing. I would not trade this time for anything. I would never have been able to learn the amount I did in such a short period of time on my own. Dev Bootcamp and it's curriculum is set up for success and I ma glad to have been a part of it.


Rate
person_outline
Choose your option
Teacher Name
rate_review
Syllabus completion
rate_review
Depth of course content
rate_review
Approachability outside class
rate_review
Presentation of Knowledge
rate_review
Regular Assignment
rate_review
Pace
rate_review
Response to Question
rate_review
Marking


In the following module, you will learn to create two-dimensional objects using WebGL, intended as a foundation to design more complex graphics implementations using the framework.
First, you will learn about the WebGL context, including the implementation of shaders and buffers. A vertex shader and fragment shader are required anytime an image is drawn. A buffer is a fixed-sized chunk of memory used for efficient storage and access when processing streams of binary data in order to create a visual representation of an object.
After being provided code with context and shaders, you have the opportunity to practice using WebGL with a suggested task and a code base to get you started. To review relevent terms or the parameters and functions used at any time, see the Glossary tab.


|
Helix
|
#include <Statics.h>
Static Public Member Functions | |
| static void | ReplaceSessionVars (IOConn &ioc, twine &target) |
| static void | ConvertToOneZero (twine &str) |
| static void | ConvertToYesNo (twine &flag) |
| If the input is "1", then reset the twine to "YES", otherwize to "NO". More... | |
| static void | ConvertToYN (twine &flag) |
| If the input is "1", then reset the twine to "Y", otherwize to "N". More... | |
| static void | ConvertToNULL (twine &flag) |
| If the input is zero length, then reset the twine to "NULL", otherwize leave as is. More... | |
| static void | ConvertToZero (twine &flag) |
| If the input is zero length, then reset the twine to "0", otherwize leave as is. More... | |
| static void | ConvertOnOffToOneZero (twine &str) |
| If the input is "On" or "ON", then convert to "1", otherwise to "0". More... | |
| static void | ConvertToOnOff (twine &flag) |
| If the input is "1" then convert to "ON", otherwise to "OFF". More... | |
| static twine | convertIP (unsigned int ipAddr) |
| Converts an IP address as an int into a string in dotted quad notation. More... | |
| static void | ensureSubDir (const twine &dirName) |
| Ensures that a given subdirectory exists under the current working directory. More... | |
| static bool | areWeHomeBase () |
| Answers the question of whether we are home-base or not. More... | |
Private Member Functions | |
| Statics () | |
| Standard Constructor is private to prevent use. More... | |
| Statics (const Statics &c) | |
| Standard Copy Constructor is private to prevent use. More... | |
| Statics & | operator= (const Statics &c) |
| Standard Copy operator is private to prevent use. More... | |
| virtual | ~Statics () |
| Standard Destructor is private to prevent use. More... | |
This class holds a number of static methods that we use throughout the hub logic classes.
|
inlineprivate |
Standard Constructor is private to prevent use.
|
inlineprivate |
Standard Copy Constructor is private to prevent use.
|
inlineprivatevirtual |
Standard Destructor is private to prevent use.
|
static |
Answers the question of whether we are home-base or not.
|
static |
Converts an IP address as an int into a string in dotted quad notation.
|
static |
If the input is "On" or "ON", then convert to "1", otherwise to "0".
|
static |
If the input is zero length, then reset the twine to "NULL", otherwize leave as is.
|
static |
This method will convert the given string to either 1 or 0. If the given string starts with either a Y or a y, then it will be converted into a 1. Otherwise it will be converted into a 0.
|
static |
If the input is "1" then convert to "ON", otherwise to "OFF".
|
static |
If the input is "1", then reset the twine to "YES", otherwize to "NO".
|
static |
If the input is "1", then reset the twine to "Y", otherwize to "N".
|
static |
If the input is zero length, then reset the twine to "0", otherwize leave as is.
|
static |
Ensures that a given subdirectory exists under the current working directory.
Standard Copy operator is private to prevent use.
|
static |
This method handles replacing session variables in the given string. The string should have tokens in the form of ${VarName} embedded within it, and we'll parse them out, look up "VarName" in our current session settings and, if found, replace the token in the string with the value from the session settings.


Toggle dark theme
Add Comic
What comic would you like to add?
Please enter a comic url:
Add the comic.
No, I'll reconsider


{% extends 'base.html' %} {% block content -%} {{ super() }}
| AI/Machine Dashboards | Production | Integration |
| Nagios | Production | Integration |
| HAProxy Status | Production | Integration |
| HAProxy Dashboard | Production | Integration |
| Graphite Dashboard | Production | Integration |


|
Lucky
(Britney Spears) |
|
This
is a story about a girl named Lucky…
Early morning, she wakes up Knock, knock, knock on the door It's time for makeup, perfect smile It's you they're all waiting for They go… "Isn't she lovely, this Hollywood girl?" And they say… She's so lucky, she's a star But she cry, cry, cries in her lonely heart, thinking If there's nothing missing in my life Then why do these tears come at night Lost in an image, in a dream But there's no one there to wake her up And the world is spinning, and she keeps on winning But tell me what happens when it stops? They go… "Isn't she lovely, this Hollywood girl?" And they say… She's so lucky, she's a star But she cry, cry, cries in her lonely heart, thinking If there's nothing missing in my life Then why do these tears come at night "Best actress, and the winner is…Lucky!" "I'm Roger Johnson for Pop News standing outside the arena waiting for Lucky" "Oh my god…here she comes!" Isn't she lucky, this Hollywood girl? She is so lucky, but why does she cry? If there's nothing missing in her life Why do tears come at night? She's so lucky, she's a star But she cry, cry, cries in her lonely heart, thinking If there's nothing missing in my life Then why do these tears come at night |


justify-self
values
(inline-axis alignment)
start
end
center
left
right
self-start (RTL)
self-end (RTL)
stretch
align-self
values
(block-axis alignment)
start
end
center
left
right
self-start (RTL)
self-end (RTL)
stretch


HOME
Home
About
Explore
Contact
Feedback
Hike Pageheader
All about Hike. We share our knowledge on blog
Our approach is very simple: we define your problem and give the best solution.


Menu
Dashboard
START DRIVING
CUSTOM CONTROLS
EDIT MY CONTROLLER
HELP & MANUAL
SETTINGS
ROUTER SETUP
WRITE CODE
Log Out
BATTERY 100%
WIFI 100%
EDIT MY CONTROLLER


YOU ODER WE DELIVER...
KSH 1200
KSH 800
KSH 600
PEPERONI, BEEF,CHEESE
THICK CHEESE LAYER,VEGES
BARBEQUED CHICKEN,BBQ SAURCE
PINEAPPLE, BACON
how would you like your pizza!!!
ksh 200
ksh 250
ksh 300
ksh 350
100
150
200
note that extra charges apply for these choices!!
| Order No. | Pizza Size | Toppings | Crust | Total |
|---|---|---|---|---|
| 1 |


After my first approach to easying up the many pains of Rails deployment I happened to bump into Docker for a broader PAAS project.
So my thought was: why automate only code deployment if I can automate the whole machine deployment especially with a tool like Docker that makes this task trivial and quick.
In this way it will be extremely easy to replicate a development/production environment and instead of updating code I could simply redeploy a machine.
Not only this but it will be easier to experiment with a broader PAAS deployment.
So these will be the takeaways from this series of posts:
- Configure a Rails app to be deployed on a cloud architecture (Part 1)
- Create a vagrant test machine with docker installed (Part 1)
- Interactive image building vs. Dockerfiles (Part 2)
- Data Persistence (Part 2)
- Development vs. Production (Part 2)
- Create 7 docker containers that will host the reconfigured rails app (Part 3):
- Container 1: Redis Server (for session storing)
- Container 2: Fluentd (log collection)
- Container 3: ElasticSearch (log storage)
- Container 4: Kibana (log analysis)
- Container 5: PostgreSQL + PostGIS
- Container 6: Ruby 2.1.1 Rails Puma
- Container 7: Nginx
- Link the 7 containers through Docker Links (Part 3) —> intra host communication
- Create another vagrant test machine with docker (Part 4)
- Deploy PostgreSQL on this second host (Part 4)
- Make the app work with the second host postgres container (Part 4) —> inter host communication
- SCALE (Part 5)
The overview seems quite interesting so let’s start.
Configure a Rails app to be deployed on a cloud architecture
To configure the Rails app (or every other app) to be cloud deployable you need to follow the The twelve-factor app methodology.
You can use this methodology to build software-as-a-service apps that:
– Use declarative formats for setup automation, to minimize time and cost for new developers joining the project;
– Have a clean contract with the underlying operating system, offering maximum portability between execution environments;
– Are suitable for deployment on modern cloud platforms, obviating the need for servers and systems administration;
– Minimize divergence between development and production, enabling continuous deployment for maximum agility;
– And can scale up without significant changes to tooling, architecture, or development practices.
Going through the twelve factors I found that most of the steps are already achieved through git versioning + rails YAY!!!
Nonetheless there are some points to tackle.
Config
Rails stores configuration in config files which are not checked into revision control. This violates the principle of strict separation of config from code.
Configuration must not be grouped (development, test, production) and must be independently managed for each deploy.
It must be stored in environment variables.
So what we need is a place to store env variables which won’t be committed into our git repository and a way to load it into Rails.
The dotenv gem is a wellcomed help in this task expecially in its master branch which now initializes before database (see here)
The dotenv gem let you use a .env
file to store ENV variables (you can also use a different .env.environment
file for each environment though this will break the twelve factor app principles)
Something like:
S3_BUCKET=YOURS3BUCKET
SECRET_KEY=YOURSECRETKEYGOESHERE
That you can use in your code this way:
config.fog_directory = ENV['S3_BUCKET']
Every time the rails app loads it will have all the variables declared in .env
available in ENV
!
Processes
Twelve-factor processes are stateless and share-nothing
Amongst other things this means we need to store our session data either in the DB or in another kind of datastore.
Using the db will introduce significant lag in page rendering so I want to use a faster key/value datastore.
Memcached is a very interesting and clusterable datastore but I will use Redis for two fundamental reasons:
1. first and foremost because its creator is italian!
2. faster than memcached
3. more powerful commands
4. no cache warmup needed
5. useful for solving other problems (eg. queues with Resque)
redis-session-store to the rescue!
Once installed and run a Redis server switching Rails session management to Redis is as simple as
adding a dependency on the redis-session-store gem to your Gemfile then run bundle.
Open the session initializer config/initializers/session_store.rb
and add the following lines:
AppName::Application.config.session_store :redis_session_store, {
key: 'redis_session',
redis: {
db: 2,
expire_after: 120.minutes,
key_prefix: 'appname:session:',
host: ENV["REDIS_PORT_6379_TCP_ADDR"], # Redis host name, default is localhost
port: ENV["REDIS_PORT_6379_TCP_PORT"] # Redis port, default is 6379
}
}
Restart the server and you’re ready to go!
Keep development, staging, and production as similar as possible
Using Docker on Vagrant on my development machine means that my development and production environments will be identical!
Treat logs as event streams
While rails is already configured to log stdout
to terminal when in development mode it is not thought to route events to a standard destination for long term archiving.
Fluentd is an open source log router (written in ruby) which can used to route log streams to a permanent storing location (MongoDB or a PostgreSQL hstore to avoid inserting another piece of software in the overall architecture, or ElasticSearch to analyze log data) and which includes a robust buffering solution.
Using fluentd in a Rails 4 can be achieved through the following steps:
1. Prepare the OS
2. Install fluentd (Debian flavor)
3. Add fluent logger gem to rails app
gem ‘act-fluent-logger-rails’
bundle
4. Configure rails to log through fluentd
– in config/environments/production.rb
config.log_level = :info
config.logger = ActFluentLoggerRails::Logger.
new()
– create a config/fluent-logger.yml file
production:
fluent_host: ‘192.168.x.x’
fluent_port: 24224
tag: 'foo'
messages_type: 'string'
Create a vagrant test machine with docker installed
The Docker guide works flawlessy and deploys a vagrant image through a Dockerfile deploying docker through docker … awesome!
The Docker version actually deployed is 0.6.1 I need to upgrade to use the links functionality available from 0.6.5.
sudo apt-get install curl
# Add the Docker repository key to your local keychain
sudo sh -c "curl https://get.docker.io/gpg | apt-key add -"
# Add the Docker repository to your apt sources list.
sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
# update your sources list
sudo apt-get update
# install the latest
sudo apt-get install lxc-docker
DONE!
That was easy!
This ends Part 1.


Jun 30 2016 Includes a preface written by Professor Leonard Kleinrock, Distinguished Professor of Computer Science, UCLA, USA This book discusses and explores the concept of mobile cloud , creating an inspiring research space for exploiting opportunistic resource sharing, and covering from theoretical research approaches to the development of commercially profitable ideas. A mobile cloud is a cooperative arrangement of dynamically connected communication nodes sharing opportunistic resources. In this book, authors provide a comprehensive and motivating overview of this rapidly emerging technology. The boo...


Efficiency of tokamak magnetic field in confining plasma: Plasma
beta
To characterize the efficiency of the magnetic field of tokamaks in confining
plasmas, introduce the plasma , which is defined as the ratio of the
thermal pressure to the magnetic pressure, i.e.,
|
(87) |
Since the pressure in tokamak plasmas is inhomogeneous, the volume averaged
pressure is usually used to define the beta. In tokamak plasmas, the toroidal
beta and the poloidal beta are defined, respectively, by
|
(88) |
|
(89) |
where
is the volume averaging, is the
vacuum toroidal magnetic field at the magnetic axis (or geometrical center of
the plasma), is the averaged poloidal magnetic field on the plasma
surface. In tokamaks, the toroidal magnetic field is dominant and thus the the
toroidal beta (not ) is the usual way to characterize the
the efficiency of the magnetic field in confining plasmas. Why do we need
? The short answer is that characterizes the efficiency of
the plasma current in confining the plasma. This can be seen by using Ampere's
law to approximately write the poloidal magnetic field as
. Then is written
|
(90) |
which is the ratio of the pressure to the plasma current, and thus
characterizes the efficiency of the plasma current in confining the plasma.
Furthermore is closely related to the normalized beta
introduced in the next subsection (refer to Eq. (92)). In
addition, is proportional to an important current, the so-called
bootstrap current, in tokamak plasmas. I will discuss this later.
yj
2018-03-09


{% import "macros.html" as m %}
User is able to take a photo of the garbage and submit the photo with a label. Other users can judge on whether the label is correct. We introduced a new virtual currency “Green Coin”. User who labels the image uploaded by other users will earn green coins. User who labels their garbage correctly will earn credentials. The “Green Coin” can be used to pay the utility bills.


Hello World, this is the root GitHub Page of
Joel Gethin Lewis
Projects:
A piece of Art as big as India
Reactickles3


Formation and Breakdown of Citric Acid in Garcinia Fruit ...
the tissues of Citrus acida of the enzyme system concerned with synthesis of citric acid (5) and suggested that organic acids may generally be formed in the fruit .
http://www.jbc.org/content/236/9/2377.full.pdf
35 Miles from Center
dutyfree shops at heathrow airport


This example demonstrates the creation of multiple pages based on one template and many i18n files
i18n - English


This image inspires me because I love where I am from. I feel deeply connected to the streets, corners, and buildings.
Though we may land far from where we grew up, we always take the places we have been with us.
This image inspires me because I love where I am from. I feel deeply connected to the streets, corners, and buildings.
Though we may land far from where we grew up, we always take the places we have been with us.


CEnumerateSerial
v1.37
Welcome to CEnumerateSerial, A simple C++ class to enumerate the serial ports
installed on your machine.
Features
- Simple C++ class interface.
- The code is fully Unicode compliant and include Unicode built options in
the workspace file.
- Internally the code provides 10 different ways (yes you read that right:
Ten) of enumerating serial ports: Using CreateFile, QueryDosDevice, GetDefaultCommConfig,
two ways using the Setup API, EnumPorts, WMI, Com Database, enumerating
the values under the registry key HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM
& GetCommPorts.
- All of the configuration of the code is controlled by the following preprocessor
values: NO_CENUMERATESERIAL_USING_CREATEFILE,
NO_CENUMERATESERIAL_USING_QUERYDOSDEVICE, NO_CENUMERATESERIAL_USING_GETDEFAULTCOMMCONFIG,
NO_CENUMERATESERIAL_USING_SETUPAPI1, NO_CENUMERATESERIAL_USING_SETUPAPI2, NO_CENUMERATESERIAL_USING_ENUMPORTS,
NO_CENUMERATESERIAL_USING_WMI, NO_CENUMERATESERIAL_USING_COMDB & NO_CENUMERATESERIAL_USING_REGISTRY.
Usage
- The class is designed for VC 2017 or later. It will not compile on earlier
releases of VC.
- To use the functions in your code simply include enumser.cpp in your project
and #include enumser.h in which ever of your modules needs to make calls to
the function.
- To see the class in action, have a look at the main function in the module "main.cpp".
Copyright
- You are allowed to include the source code in any product (commercial, shareware,
freeware or otherwise) when your product is released in binary form.
- You are allowed to modify the source code in any way you want except you
cannot modify the copyright details at the top of each module.
- If you want to distribute source code with your application, then you are
only allowed to distribute versions released by the author. This is to maintain
a single distribution point for the source code.
History
v1.37 (15 January 2019)
- Updated copyright details.
- Updated the sample app to log the time each method call takes
- Fixed a compilation error "unknown identifier 'HDEVINFO'" in enumser.h.
Thanks to Drew Freer for reporting this issue.
v1.36 (16 September 2018)
- Fixed a number of compiler warnings when using VS 2017 15.8.4
v1.35 (8 July 2018)
- Updated copyright details.
- Fixed a number of C++ core guidelines compiler warnings. These changes
mean that the code will now only compile on VC 2017 or later.
- Remove the code path which supported CENUMERATESERIAL_MFC_EXTENSIONS
v1.34 (19 May 2018)
- Updated copyright details.
- Addition of a tenth and hopefully final method to enumerate serial
ports. The function is called "UsingGetCommPorts" and enumerates the ports
by calling the Win32 GetCommPorts API which is available on Windows 10 1803
or later.
v1.33 (15 November 2017)
- Updated the code to compile cleanly when _ATL_NO_AUTOMATIC_NAMESPACE is
defined.
v1.32 (25 September 2017)
- Updated copyright details.
- Replaced NULL throughout the codebase with nullptr. This means that the
minimum requirement for the framework is now VC 2010.
- Replaced CString::operator LPC*STR() calls throughout the codebase with
CString::GetString calls
- Removed the CENUMERATESERIAL_USE_STL define and instead introduced a new
CENUMERATESERIAL_MFC_EXTENSIONS define which by default is not defined.
v1.31 (2 July 2016)
- Updated the SAL annotations in the code
v1.30 (28 May 2016)
- The sample app previously excluded support for CEnumerateSerial::UsingComDB
for versions of Visual C 2010 or earlier. Now this check has been changed to
be based on the version of the Windows SDK which the code is being compiled
against. This check is now performed by checking the value of the VER_PRODUCTBUILD
preprocessor value from the ntverp.h SDK header file. The sample app now excludes
support for CEnumerateSerial::UsingComDB on the Windows SDK 7.1 or earlier.
This is because the msports.h header file is only available with the Windows
SDK 8 or later. Thanks to "scott" for reporting this issue.
v1.29 (28 March 2016)
- Updated copyright details.
- Updated CEnumerateSerial::RegQueryValueString to ensure that non null terminated
data returned from the registry API is null terminated before it is treated
as such in the code.
- Reworked CEnumerateSerial::UsingRegistry to internally use CEnumerateSerial::RegQueryValueString.
This ensures that non null terminated data returned from the registry API is
null terminated before it is treated as such in the code.
v1.28 (20 December 2015)
- Updated copyright details.
- Updated the code to compile cleanly on VC 2015.
- Reworked CEnumerateSerial::UsingComDB method to statically link to msports.dll.
- Reworked CEnumerateSerial::UsingSetupAPI1 method to statically link to setupapi.dll.
- Reworked CEnumerateSerial::UsingSetupAPI2 method to statically linke to
setupapi.dll.
- Removed now unnecessary CEnumerateSerial::LoadLibraryFromSystem32 method.
- Added SAL annotations to all the code.
- Removed call to VerifyVersionInfo from CEnumerateSerial::UsingQueryDosDevice.
- CEnumerateSerial::UsingCreateFile now use ATL::CHandle instead of CAutoHandle.
- CEnumerateSerial::UsingQueryDosDevice now uses ATL::CHeapPtr instead of
CAutoHeapAlloc.
- CEnumerateSerial::UsingSetupAPI2 now uses ATL::CHeapPtr instead of CAutoHeapAlloc.
- CEnumerateSerial::UsingEnumPorts now uses ATL::CHeapPtr instead of CAutoHeapAlloc.
- CEnumerateSerial::UsingWMI now uses ATL::CW2A instead of CAutoHeapAlloc.
- CEnumerateSerial::UsingComDB now uses ATL::CHeapPtr instead of CAutoHeapAlloc.
- CEnumerateSerial::UsingWMI now uses ATL::CComPtr & ATL::CComVariant.
- Removed AutoHandle.h, AutoHeapAlloc.h & AutoHModule.h from distribution
as these modules are no longer required by enumser.
- CEnumerateSerial::UsingSetupAPI1 now uses ATL::CRegKey.
- CEnumerateSerial::UsingSetupAPI2 now uses ATL::CRegKey.
- CEnumerateSerial::UsingRegistry now uses ATL::CRegKey.
- CEnumerateSerial::RegQueryValueString now uses ATL::CRegKey.
- The return value from CEnumerateSerial::UsingWMI is now a HRESULT instead
of a BOOL.
- CEnumerateSerial::UsingEnumPorts now returns the friendly name of the port.
- Fixed an issue calling EnumPorts the first time in CEnumerateSerial::UsingEnumPorts.
- Simplified the declaration of parameters to the various methods of the class.
- CEnumerateSerial::UsingSetupAPI1 and CEnumerateSerial::UsingSetupAPI2 have
been refactored to use a new internal method called "QueryUsingSetupAPI".
- CEnumerateSerial::UsingSetupAPI2 now uses GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR
define.
- Renamed all the NO_ENUMSERIAL_* defines to NO_CENUMERATESERIAL_*.
v1.27 (1 December 2013)
- Updated the code to compile cleanly on VC 2013
v1.26 (3 August 2013)
- Fixed a bug where the return value from "SetupDiOpenDevRegKey"
in UsingSetupAPI1 and UsingSetupAPI2 were not being checked correctly. Thanks
to Ilya Tsybulsky for reporting this bug.
- Tested code to make sure everything compiles cleanly when CENUMERATESERIAL_USE_STL
is not defined and MFC is not included. Please note that if you do not use STL
or MFC then you MUST use ATL.
- Updated code to make sure everything compiles cleanly when CENUMERATESERIAL_USE_STL
is defined and MFC and ATL are not included. This means that this particular
scenario should now work on Express SKU's of Visual Studio.
- Reworked the CEnumerateSerial::UsingWMI method to not require ATL. This
means that this method should now work on Express SKU's of Visual Studio.
v1.25 (28 July 2013)
- Did some very light cleanup of the code to reduce dependencies when #defining
out parts of the code. Thanks to Jay Beavers for providing this update.
v1.24 (10 January 2013)
- Updated copyright details
- Spun off CAutoHModule class into its own header file
- Spun off CAutoHandle class into its own header file
- Addition of a new CAutoHeapAlloc class which encapsulates HeapAlloc / HeapFree
calls in a C++ class.
- Removed ATL usage completely from UsingQueryDevice, UsingSetupAPI2 and UsingEnumPorts.
This should allow these methods to support compilers which do not have support
for ATL such as VC Express SKUs.
v1.23 (15 October 2012)
- Updated copyright details.
- Code no longer uses LoadLibrary without an absolute path when loading SETUPAPI
and MSPORTS dlls. This avoids DLL planting security issues.
- Added a new internal CAutoHandle and CAutoHModule classes which makes the
implementation for CEnumerateSerial simpler
- Code now uses an internal RegQueryValueString method to ensure that data
returned from raw Win32 API call RegQueryValueEx is null terminated before it
is treated as such in the code. Thanks to Jeffrey Walton for reporting this
security issue.
- Updated the code to clean compile on VC 2012
v1.22 (28 March 2011)
- Updated copyright details.
- Updated the UsingComDB method to fix an off by one issue. This resulting
in the list of ports this function reported being incorrect. Thanks to "Jar,
Min, Jeong" for reporting this issue.
- Updated sample app to compile cleanly on VC 2010
v1.21 (27 March 2010)
- Updated copyright details.
- Code can now optionally use STL instead of MFC or ATL in the API. To use
STL containers instead of MFC or ATL versions, please define CENUMERATESERIAL_USE_STL
before you include enumser in your project. Please note that the code still
internally uses ATL in the UsingWMI method, but the other functions do not.
This means that the class should now be partly compilable on VC Express (2005,
2008 or 2010) as none of these have support for ATL or MFC. I do not personally
have VC Express installed so people's feedback on this would be appreciated.
Thanks to Bill Adair for providing this update.
v1.20 (30 April 2009)
- Updated copyright details.
- Updated the sample app's project settings to more modern default values.
- Updated the sample app to log the time taken for the various methods.
v1.19 (29 November 2008)
- Addition of a ninth and hopefully final method to enumerate serial ports.
The function is called "UsingRegistry" and enumerates the ports by
examining the registry location at HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM.
Thanks to Martin Oberhuber for prompting this update.
- Fixed a bug where the last error value was not being preserved in CEnumerateSerial::UsingComDB.
v1.18 (23 November 2008)
- Updated code to compile correctly using _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
define
- The code now only supports VC 2005 or later.
- Code now compiles cleanly using Code Analysis (/analyze)
- Yes, Addition of a another method called "UsingComDB" to enumerate
serial ports!. This function uses the so called "COM Database" functions
which are part of the Windows DDK which device drivers can use to support claiming
an unused port number when the device driver is being installed. Please note
that the list returning from this function will only report used port numbers.
The device may or may not be actually present, just that the associated port
number is currently "claimed". Thanks to Dmitry Nikitin for prompting
this very nice addition. The code now supports a total of 8 different ways to
enumerate serial ports!
v1.17 (20 March 2008)
- Updated copyright details
- Updates to preprocessor logic to correctly include UsingSetupAPI1 and UsingSetupAPI2
functionality
- Updated sample app to clean compile on VC 2008
v1.16 (5 July 2007)
- Updated the code to work if the code does not include MFC. In this case,
CPortsArray parameters becomes the ATL class CSimpleArray<UINT> and CNamesArray
parameters become the ATL class CSimpleArray<CString>. Please note that
this support requires a recentish copy of Visual Studio and will not support
Visual C++ 6.0 as the code makes use of the ATL CString class. Thanks to Michael
Venus for prompting this update.
- CEnumerateSerial::UsingWMI method now uses ATL smart pointers to improve
robustness of the code.
v1.15 (9 June 2007)
- Following feedback from John Miles, it looks like my previous change of
the 29 January 2007 to use GUID_DEVINTERFACE_COMPORT in the UsingSetupAPI method
had the unintended consequence of causing this method not to work on any versions
of Windows prior to Windows 2000. What I have now done is reinstate the old
mechanism using the name UsingSetupAPI2 so that you can continue to use this
approach if you need to support NT 4 and Windows 9x. The new approach of using
GUID_DEVINTERFACE_COMPORT has been renamed to UsingSetupAPI1.
v1.14 (29 January 2007)
- Updated copyright details.
- UsingSetupAPI code now uses the GUID_DEVINTERFACE_COMPORT guid to enumerate
COM ports. Thanks to David McMinn for reporting this nice addition.
- Detection code which uses CreateFile call, now treats the error code of
ERROR_SEM_TIMEOUT as indication that a port is present.
v1.13 (8 November 2006)
- Extended CEnumerateSerial::UsingWMI to now also return the friendly name
of the port. Thanks to Giovanni Bajo for providing this update.
- Fixed a bug where CEnumerateSerial::UsingSetupAPI forget to empty out the
Friendly name array on start.
- VariantInit is now called for the 2 VARIANT structs used in the UsingWMI
method code.
v1.12 (9 July 2006)
- Updated copyright details.
- Addition of a CENUMERATESERIAL_EXT_CLASS macro to allow the code to be easily
added to an extension dll
- Code now uses newer C++ style casts instead of C style casts.
- Updated the code to clean compile on VC 2005.
- Updated the documentation to use the same style as the web site.
v1.11 (13 May 2004)
- Extended CEnumerateSerial::UsingSetupAPI to now also return the friendly
name of the port. Thanks to Jay C. Howard for prompting this update.
v1.10 (12 December 2003)
- Updated the sample app to VC 6.
- Addition of a "EnumerateSerialPorts6" (See Note 4 below) which
uses WMI.
- You can now optionally exclude each function using preprocessor defines
of the form "NO_ENUMSERIAL_USING_XYX".
- Made the functions members of a C++ class and renamed them to using more
meaningful names
v1.09 (20 September 2003)
- Addition of a "EnumerateSerialPorts5" method. This method (hopefully
the last method!) uses EnumPorts and was provided by Andi Martin.
v1.08 (22 May 2003)
- Updated copyright details.
- Addition of a EnumerateSerialPorts4 which uses Device Manager API
v1.07 (13 August 2001)
- Made the code in IsNumeric more robust when sent an empty string
- Optimized the code in EnumerateSerialPorts2 somewhat. Thanks to Dennis Lim
for these suggestions.
v1.06 (11 August 2001)
- Made code path which uses QueryDosDevice more robust by checking to make
sure the device name is of the form "COMxyz.." where xyz are numeric.
v1.05 (25 June 2001)
- Guess what, You now have the choice of using the GetDefaultCommConfig thro
the use of three versions of the function. You take your pick.
- Fixed problem where port fails to be reported thro the CreateFile mechanism
when the error code is ERROR_SHARING_VIOLATION i.e. someone has the port already
open.
v1.04 (29 March 2001)
- Reverted code to use CreateFile or QueryDosDevice as it is much faster than
using the GetDefaultCommConfig method.
- Updated copyright message.
v1.03 (17 May 2000)
- Code now uses GetDefaultCommConfig in all cases to detect the ports.
v1.02 (12 December 1999)
- Fixed a problem in the Win9x code path when trying to detect deactivated
IRDA-ports. When trying to open those, you will get the error-code ERROR_GEN_FAILURE.
v1.01 (23 February 1999)
- Code now uses QueryDosDevice if running on NT to determine which serial
ports are available. This avoids having to open the ports at all. It should
operate a lot faster in addition.
v1.0 (3 November 1998)
API Reference
CEnumerateSerial::UsingCreateFile
BOOL CEnumerateSerial::UsingCreateFile(CPortsArray& ports);
Parameters
ports Upon return this array will contain the port numbers of all the
serial ports installed on the computer
Remarks
This function uses the CreateFile method of detecting serial ports. This will
work on all Win32 OS'es, but requires actually opening the port.
CEnumerateSerial::UsingQueryDosDevice
BOOL CEnumerateSerial::UsingQueryDosDevice(CPortsArray& ports);
Parameters
ports Upon return this array will contain the port numbers of all the
serial ports installed on the computer
Remarks
This function uses the QueryDosDevice method of detect serial ports. Please note
that this only works correctly on NT 3.x or later and not Windows 9x.
CEnumerateSerial::UsingGetDefaultCommConfig
BOOL CEnumerateSerial::UsingGetDefaultCommConfig(CPortsArray& ports);
Parameters
ports Upon return this array will contain the port numbers of all the
serial ports installed on the computer
Remarks
This function uses the GetDefaultCommConfig method of detect serial ports. Please
note that this is the most compatible way of detecting serial ports and will work
on all Win32 OS'es from Windows 95 onwards but also happens to be the slowest.
CEnumerateSerial::UsingSetupAPI1
BOOL CEnumerateSerial::UsingSetupAPI1(CPortAndNamesArray& ports);
Parameters
ports Upon return this array will contain the port numbers and
friendly names of all the
serial ports installed on the computer
Remarks
This function uses the Device Manager "SetupDi.." APIs and the value
GUID_DEVINTERFACE_COMPORT device interface class to detect serial ports. Please
note that this will only work on Windows 2000 or later.
CEnumerateSerial::UsingSetupAPI2
BOOL CEnumerateSerial::UsingSetupAPI2(CPortAndNamesArray& ports);
Parameters
ports Upon return this array will contain the port numbers and
friendly names of all the
serial ports installed on the computer
Remarks
This function uses the Device Manager "SetupDi.." APIs and the "Ports"
device information set to detect serial ports. The code of course implements logic
to exclude parallel ports from the returned array as they are included in the "Ports"
device information set in addition to serial ports. This approach will work on all
Win32 OS'es from Windows 95 onwards.
CEnumerateSerial::UsingEnumPorts
BOOL CEnumerateSerial::UsingEnumPorts(CPortAndNamesArray& ports);
Parameters
ports Upon return this array will contain the port numbers and
friendly names of all the
serial ports installed on the computer
Remarks
This function uses the Win32 SDK call "EnumPorts" APIs to detect
serial ports. This will work on all Win32 OS'es from Windows 95 onwards.
CEnumerateSerial::UsingWMI
BOOL CEnumerateSerial::UsingWMI(CPortAndNamesArray& ports);
Parameters
ports Upon return this array will contain the port numbers and
friendly names of all the
serial ports installed on the computer
Remarks
This function uses the WMI COM interfaces to detect serial ports. This will only
work on Windows NT 4 SP4 or later (i.e versions of Windows on which WMI is available).
CEnumerateSerial::UsingComDB
BOOL CEnumerateSerial::UsingComDB(CPortsArray& ports);
Parameters
ports Upon return this array will contain the port numbers of all the
serial ports installed on the computer
Remarks
This function uses the uses the so called "COM Database" functions
which are part of the Windows DDK which device drivers can use to support claiming
an unused port number when the device driver is being installed. Please note that
the list returning from this function will only report used port numbers. The device
may or may not be actually present, just that the associated port number is currently "claimed".
This will only work on Windows 2000 or later. A final note is that the ComDB functions
require UAC elevation if UAC is enabled.
CEnumerateSerial::UsingRegistry
BOOL CEnumerateSerial::UsingRegistry(CNamesArray& ports);
Parameters
ports Upon return this array will contain the names of all the serial
ports installed on the computer
Remarks
This function detects the install ports by enumerating the values contained at
the registry key HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM. This is the same
registry location as used by the .NET method SerialPort::GetPortNames.
It also seems to be the way which HyperTerminal uses to enumerate the ports which
it offers in its connect dialog. This method has the advantage that it returns serial
ports which do not adhere to the "COMX" naming convention. For example
if you use the com0com driver from http://com0com.sourceforge.net/,
you will see the "CNC0A" and "CNC0B" ports which it creates
by default being returned from "UsingRegistry". This method will work
on all versions of Windows from Windows 98 onwards.
Contacting the Author
PJ Naughter
Email<EMAIL_ADDRESS>Web: http://www.naughter.com
15 January
2019


Pushover adapter settings
Pushover settings
Group Key:
Group Key of Delivery Group
Token:
API Token/Key of Application
Notification settings
Title:
Sound:
default
pushover
bike
bugle
cashregister
classical
cosmic
falling
gamelan
incoming
intermission
magic
mechanical
pianobar
siren
spacealarm
tugboat
alien
climb
persistent
echo
updown
none
Priority:
quiet
default
high-priority
Test


When you are using Berkeley DB for XA transactions, there are a few restrictions you should be aware of:
Configure environment using the DB_CONFIG file
For most options, you must configure your environment via the DB_CONFIG file because an XA application or server cannot control the environment creation.
Snapshot isolation must be configured for the entire environment.
Transactions managed by the Berkeley DB X/open compliant XA resource manager can be configured for transaction snapshots using either database open flags or the DB_CONFIG file file. To configure using database open flags, open the XA managed database with the flag DB_MULTIVERSION. When using DB_CONFIG, include both of the following lines:
set_flags DB_MULTIVERSION set_flags DB_TXN_SNAPSHOT
Note that both methods will results in all transactions using transaction snapshots, there is no way to enable transaction snapshots in just a subset of XA managed transactions.
No in-memory logging
Upon return from xa_open, Berkeley DB checks to ensure there is no in-memory logging. If in-memory logging is detected, a FAILURE message is returned to the application.
No application-level child transactions
Berkeley DB verifies in the xa_start and xa_end calls that no XA transaction has a parent. If application-level child transactions are detected, a FAILURE message is returned to the application.
All database-level operations, such as create, rename, and remove, must be performed in local BDB transactions, not distributed XA transactions
Berkeley DB checks that there is no XA transaction currently active during these operations, and if detected, a FAILURE message is returned to the application.
Close cursors before a service invocation returns
Berkeley DB checks in the xa_end
call that the DB_TXN
has no active
cursors open and and if detected, a FAILURE message is
returned to the application.


The ONE Piano Hi-Lite is the first of its kind piano learning device, providing an intuitive way to learn and play a piano.
It transforms any standard 88 keys piano or keyboard into a smart one, and interacts with your smart device, helping you start playing in just a few minutes.


DBKL: Burst pipe causes sinkhole on Jalan Maharajalela
KUALA LUMPUR, Nov 25 — The sinkhole along Jalan Maharajalela here is caused by a burst underground pipe.
Kuala Lumpur City Hall Corporate Planning Department director Khairul Azmir Ahmad in a statement today said the repairs works of the burst pipe and the affected road had been completed by Syarikat Bekalan Air Selangor Sdn Bhd contractors.
“The situation has recovered at mid-day today and the affected car had been removed with the help of the police,” he said.
In the last night incident, a car driven by a woman fell into a three-metre square sinkhole at Jalan Maharajalela heading towards Jalan Loke Yew at about 11.35 pm.
The 42-year-old victim was however unhurt.
Meanwhile, Universiti Kebangsaan Malaysia geologist Prof Madya Dr Tajul Anuar Jamaluddin said sedimentation could also occur when there were limestones under a surface.
“The natural characteristic of limestone which is soluble makes it easy to form underground or subsurface cavities.
“When there are heavy loads on the surface, the cavities (empty spaces) will collapse and form a sinkhole. The size of the sinkhole depends on the size of the cavity itself,” he said when contacted by Bernama.
Tajul Anuar said other factors that could cause a sinkhole were changes in underground water levels and shocks or vibrations.
“Therefore, it would be best for the relevant agencies to conduct detailed geophysics studies prior to building physical infrastructure to identify the underground cavities,” he said. — Bernama


The widget to the right is a widget created to practice using an AJAX request to a JSON object and manipulating the information to display the employees name, and whether based on the JSON information the employee is in the office or out of the office, display a box that shows that. The idea is that if this was an updated JSON object, the widget would be updated dynamically. Here is the JavaScript Code:
var xhr = new XMLHttpRequest();//create xmlhttprequest object
//create onsteadystatechange callback function
xhr.onreadystatechange = function() {
if(xhr.readyState === 4 && xhr.status === 200){
var employees = JSON.parse(xhr.responseText);
var employeeListDiv = document.getElementById('employeeList');
var statusHTML = document.createElement('ul');
statusHTML.classList.add('bulleted');
employeeListDiv.appendChild(statusHTML);
console.log(employeeListDiv);
for (var i = 0; i < employees.length; i++){
//create
 element for the first employee
var employee = document.createElement('li');
var employeeName = document.createTextNode(employees[i]["name"]);
employee.appendChild(employeeName);
if(employees[i]["inoffice"]){
//add

employee.classList.add('in');
}else{
//add

employee.classList.add('out');
}
//append
 element to

statusHTML.appendChild(employee);
}
}
};
//open and send request
xhr.open('GET', 'data/employees.json');
xhr.send();
//Solution: Post a List of Employees in the sidebar with their work status
//send a request to the JSON data of employees
//create a
 of those employees
I have also completed this project using AJAX request through jQuery. Here is the code for that:
$.getJSON('../data/employees.json', function(json){
$('#employeeList').html('

');
var employees = "";
for(var i = 0; i < json.length; i++){
var name = json[i]["name"];
var inoffice = json[i]["inoffice"];
var status = '';
if(inoffice){
status = 'in';
} else{
status = 'out';
}
var employee = '
' + name + '
';
employees += employee;
}
$('.bulleted').html(employees);
});


|
| ulong | Id () |
| | The public getter for volumeId More...
|
| |
| RelayDescription | RelayDescription (DataChannelTypes channel) |
| |
| List< UMI3DUser > | RelayDataRequest (UMI3DAbstractNode sender, object data, UMI3DUser target, Receivers receiverSetting, bool isReliable=false) |
| | Handle relay for channel Data More...
|
| |
| List< UMI3DUser > | RelayTrackingRequest (UMI3DAbstractNode sender, object data, UMI3DUser target, Receivers receiverSetting, bool isReliable=false) |
| | Handle relay for channel Tracking More...
|
| |
| List< UMI3DUser > | RelayVoIPRequest (UMI3DAbstractNode sender, object data, UMI3DUser target, Receivers receiverSetting, bool isReliable=false) |
| | Handle relay for channel VoIP More...
|
| |
| List< UMI3DUser > | RelayVideoRequest (UMI3DAbstractNode sender, object data, UMI3DUser target, Receivers receiverSetting, bool isReliable=false) |
| | Handle relay for channel Video More...
|
| |
| bool | HasStrategyFor (DataChannelTypes channelType) |
| | Checks if this relay defines a strategy for channelType . More...
|
| |
| List< UMI3DUser > | RelayDataRequest (UMI3DAbstractNode sender, object data, UMI3DUser target, Receivers receiverSetting, bool isReliable=false) |
| | Control the relay for the data channel. More...
|
| |
| List< UMI3DUser > | RelayTrackingRequest (UMI3DAbstractNode sender, object data, UMI3DUser target, Receivers receiverSetting, bool isReliable=false) |
| | Control the relay for the user tracking channel. More...
|
| |
| List< UMI3DUser > | RelayVoIPRequest (UMI3DAbstractNode sender, object data, UMI3DUser target, Receivers receiverSetting, bool isReliable=false) |
| | Control the relay for the voice over IP channel. More...
|
| |
| List< UMI3DUser > | RelayVideoRequest (UMI3DAbstractNode sender, object data, UMI3DUser target, Receivers receiverSetting, bool isReliable=false) |
| | Control the relay for the video channel. More...
|
| |
| ulong | Id () |
| | UMI3D Id of an entity. More...
|
| |
|
| List< UMI3DCollaborationUser > | GetTargetHashSet (UMI3DUser target, Receivers receiverSetting) |
| | Create a new HashSet with receivers More...
|
| |
| List< UMI3DUser > | RelayRequest (UMI3DAbstractNode sender, object data, UMI3DUser target, Receivers receiverSetting, bool isReliable, DataChannelTypes dataChannel) |
| |
| bool | ShouldRelay (UMI3DAbstractNode sender, UMI3DCollaborationUser to, DataChannelTypes channel, ulong now) |
| | Determine if data have to be relayed. More...
|
| |
| void | RememberRelay (UMI3DAbstractNode sender, UMI3DCollaborationUser to, DataChannelTypes channel, ulong now) |
| | Handle Relay Memory More...
|
| |
| Dictionary< ulong, Dictionary< ulong, ulong > > | GetRelayMemory (DataChannelTypes channel) |
| |
|
| Dictionary< DataChannelTypes, RelayDescription > | DicoRelays = new Dictionary<DataChannelTypes, RelayDescription>() |
| |
| ulong | volumeId = 0 |
| | The objects's unique id. More...
|
| |
| Dictionary< ulong, Dictionary< ulong, ulong > > | relayDataMemory = new Dictionary<ulong, Dictionary<ulong, ulong>>() |
| |
| Dictionary< ulong, Dictionary< ulong, ulong > > | relayTrackingMemory = new Dictionary<ulong, Dictionary<ulong, ulong>>() |
| |
| Dictionary< ulong, Dictionary< ulong, ulong > > | relayVoIPMemory = new Dictionary<ulong, Dictionary<ulong, ulong>>() |
| |
| Dictionary< ulong, Dictionary< ulong, ulong > > | relayVideoMemory = new Dictionary<ulong, Dictionary<ulong, ulong>>() |
| |
Relay for a collaboration room defined by a volume.


Sign up
First Name
Last Name
Email
Password
Confirm your Password
Phone
Message
Submit
Have an account? Sign In
Back Home


--- layout: bootstrap title: Home landing: true ---
We make awesome stuff.
Here are the 5 most recent posts to our job board.


Welcome to the Embedded Rust Demo
enter your name and connect more
Your messages should appear on the LED panel in the meeting room
This site was primarily created for this one demo and won't remain up and running thereafter.
The code can be found here


Aloha! You've found my GitHub HTML test site! Please note that this is
just for testing
and nothing here actually does anything. You can see my repository
here
, or you can return to the site's home
here
.
This page uses Bootstrap.
Please Sign In
Enter Your Username and Password Below.
Sign In


{% extends "base.html" %} {% block content %}
Mostly because it steals good ideas from git. When you enter a URL it is SHA-1 hashed to create the "shortened" URL. If you use the SHA-1 Us service, you can cryptographically verify (with a reasonable degree of assurance) that you were redirected to the correct URL by just hashing the URL and comparing it with the hash on the end of the shortened url. Users don't have to worry about malicious URL manipulation.
The second good idea I steal from git is that you can use whatever portion of the URL is convenient for you. If the full "shortened" URL you receive is http://sha1.us/9c17e047f58f9220a7008d4f18152fee4d111d14 (way too long), then feel free to use http://sha1.us/9c17e047f58f9220 or even just http://sha1.us/9c17e. Be aware that the probability of collisions increases if you use a shorter portion of the hash.
This site was created by Andy Kish and its source is available on github.


{include file="../app/index/view/common/menu.html" /}
{$title}
{$create_time}
{$view}
{$author}
{$menu_name}


Package redempt.redlib.misc
Class LocationUtils
java.lang.Object
redempt.redlib.misc.LocationUtils
public class LocationUtils
extends java.lang.Object
-
Field Summary
Fields Modifier and Type Field Description static org.bukkit.block.BlockFace[]
PRIMARY_BLOCK_FACES
An array of all the block faces which face in a single direction (positive X, negative X, etc.) -
Constructor Summary
Constructors Constructor Description LocationUtils()
-
Method Summary
Modifier and Type Method Description static org.bukkit.Location
center(org.bukkit.block.Block block)
Returns the Location at the center of a Block - shorthandstatic org.bukkit.Location
center(org.bukkit.Location loc)
Sets the location's coordinates to the center point of its block coordinates, then returns itstatic void
delayedTeleport(org.bukkit.entity.Player player, org.bukkit.Location loc, int ticks)
Initiates a delayed teleport for a player which will be cancelled if the player moves.static void
delayedTeleport(org.bukkit.entity.Player player, org.bukkit.Location loc, int ticks, java.util.function.Consumer<java.lang.Boolean> result)
Initiates a delayed teleport for a player which will be cancelled if the player moves.static java.util.List<org.bukkit.Location>
directPathfind(org.bukkit.block.Block start, org.bukkit.block.Block end, int max)
Finds the fastest path between a starting and ending location using A*, then removes unneeded steps for straightstatic java.util.List<org.bukkit.Location>
directPathfind(org.bukkit.block.Block start, org.bukkit.block.Block end, int max, java.util.function.Predicate<org.bukkit.block.Block> filter)
Finds the fastest path between a starting and ending location using A*, then removes unneeded steps for straightstatic org.bukkit.Location
fromString(java.lang.String string)
Converts a String back to a Location.static org.bukkit.Location
fromString(java.lang.String string, java.lang.String separator)
Converts a String back to a Locationstatic void
fromStringLater(java.lang.String string, java.lang.String separator, java.util.function.Consumer<org.bukkit.Location> callback)
Loads a Location from a String.static void
fromStringLater(java.lang.String string, java.util.function.Consumer<org.bukkit.Location> callback)
Loads a Location from a String.static int[]
getChunkCoordinates(org.bukkit.Location loc)
Gets the chunk X and Z of a locationstatic org.bukkit.util.Vector
getDirection(org.bukkit.block.BlockFace face)
Gets the Vector direction of a BlockFace.static org.bukkit.Location
getNearestSafeLocation(org.bukkit.Location loc, int maxDistance)
Gets the nearest safe location to the given location within the given distancestatic org.bukkit.Location
getNearestSafeLocation(org.bukkit.Location loc, int maxDistance, java.util.function.Predicate<org.bukkit.Location> filter)
Gets the nearest safe location to the given location within the given distance passing the given predicate checkstatic boolean
isHazard(org.bukkit.Material type)
Checks if a given block type is a hazard - whether it would damage the player if they were on top of itstatic boolean
isSafe(org.bukkit.Location loc)
Checks whether the given location is safe to teleport a player to - that a player would not be damaged as a result of being moved to this locationstatic java.util.Deque<org.bukkit.Location>
pathfind(org.bukkit.block.Block start, org.bukkit.block.Block end, int max)
Finds the fastest path between a starting and ending location using A*static java.util.Deque<org.bukkit.Location>
pathfind(org.bukkit.block.Block start, org.bukkit.block.Block end, int max, java.util.function.Predicate<org.bukkit.block.Block> filter)
Finds the fastest path between a starting and ending location using A*static org.bukkit.Location
toBlockLocation(org.bukkit.Location loc)
Sets the location's coordinates to its block coordinates, then returns itstatic java.lang.String
toString(org.bukkit.block.Block block)
Converts a Location to a String representing its locationstatic java.lang.String
toString(org.bukkit.block.Block block, java.lang.String separator)
Converts a Location to a String representing its locationstatic java.lang.String
toString(org.bukkit.Location loc)
Converts a Location to a String.static java.lang.String
toString(org.bukkit.Location loc, java.lang.String separator)
Converts a Location to a Stringstatic void
waitForWorld(java.lang.String worldname, java.util.function.Consumer<org.bukkit.World> callback)
Waits for a world with the given name to load before calling the callbackMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
PRIMARY_BLOCK_FACES
public static final org.bukkit.block.BlockFace[] PRIMARY_BLOCK_FACESAn array of all the block faces which face in a single direction (positive X, negative X, etc.)
-
-
Constructor Details
-
LocationUtils
public LocationUtils()
-
-
Method Details
-
isHazard
public static boolean isHazard(org.bukkit.Material type)Checks if a given block type is a hazard - whether it would damage the player if they were on top of it- Parameters:
type
- The type to check- Returns:
- Whether the block type is a hazard
-
isSafe
public static boolean isSafe(org.bukkit.Location loc)Checks whether the given location is safe to teleport a player to - that a player would not be damaged as a result of being moved to this location- Parameters:
loc
- The location to check- Returns:
- Whether the given location is safe
-
getNearestSafeLocation
public static org.bukkit.Location getNearestSafeLocation(org.bukkit.Location loc, int maxDistance, java.util.function.Predicate<org.bukkit.Location> filter)Gets the nearest safe location to the given location within the given distance passing the given predicate check- Parameters:
loc
- The location to find the nearest safe location tomaxDistance
- The maximum distance to check from this locationfilter
- Used to filter safe locations that you still don't want to send the player to. Any locations this returns false for will be ignored.- Returns:
- The nearest safe location, or null if one was not found
-
getNearestSafeLocation
public static org.bukkit.Location getNearestSafeLocation(org.bukkit.Location loc, int maxDistance)Gets the nearest safe location to the given location within the given distance- Parameters:
loc
- The location to find the nearest safe location tomaxDistance
- The maximum distance to check from this location- Returns:
- The nearest safe location, or null if one was not found
-
getDirection
public static org.bukkit.util.Vector getDirection(org.bukkit.block.BlockFace face)Gets the Vector direction of a BlockFace. For use in versions below 1.13.- Parameters:
face
- The block face- Returns:
- The vector representing the direction
-
delayedTeleport
public static void delayedTeleport(org.bukkit.entity.Player player, org.bukkit.Location loc, int ticks, java.util.function.Consumer<java.lang.Boolean> result)Initiates a delayed teleport for a player which will be cancelled if the player moves. The messages relevant to this will be sent automatically.- Parameters:
player
- The player to teleportloc
- The location to teleport the player to after the delayticks
- The delay for the teleport, in ticksresult
- A lambda to handle the result, given true if the teleport succeeded, false otherwise
-
delayedTeleport
public static void delayedTeleport(org.bukkit.entity.Player player, org.bukkit.Location loc, int ticks)Initiates a delayed teleport for a player which will be cancelled if the player moves. The messages relevant to this will be sent automatically.- Parameters:
player
- The player to teleportloc
- The location to teleport the player to after the delayticks
- The delay for the teleport, in ticks
-
toString
public static java.lang.String toString(org.bukkit.Location loc, java.lang.String separator)Converts a Location to a String- Parameters:
loc
- The Location to be stringifiedseparator
- The separator to use between pieces of information- Returns:
- The stringified Location
-
fromString
public static org.bukkit.Location fromString(java.lang.String string, java.lang.String separator)Converts a String back to a Location- Parameters:
string
- The stringified Locationseparator
- The separator that was used in toString- Returns:
- The Location
-
toString
public static java.lang.String toString(org.bukkit.block.Block block, java.lang.String separator)Converts a Location to a String representing its location- Parameters:
block
- The Block location to be stringifiedseparator
- The separator to use between pieces of information- Returns:
- The stringified location
-
toString
public static java.lang.String toString(org.bukkit.block.Block block)Converts a Location to a String representing its location- Parameters:
block
- The Block location to be stringified- Returns:
- The stringified location
-
fromStringLater
public static void fromStringLater(java.lang.String string, java.lang.String separator, java.util.function.Consumer<org.bukkit.Location> callback)Loads a Location from a String. If the world this Location is in is not yet loaded, waits for it to load, then passes the Location to the callback.- Parameters:
string
- The String to be parsed into a Locationseparator
- The separator used when converting this Location to a Stringcallback
- The callback to use the Location once it has been loaded
-
center
public static org.bukkit.Location center(org.bukkit.block.Block block)Returns the Location at the center of a Block - shorthand- Parameters:
block
- The Block to get the center of- Returns:
- The center of the Block
-
toBlockLocation
public static org.bukkit.Location toBlockLocation(org.bukkit.Location loc)Sets the location's coordinates to its block coordinates, then returns it- Parameters:
loc
- The location- Returns:
- The block location
-
center
public static org.bukkit.Location center(org.bukkit.Location loc)Sets the location's coordinates to the center point of its block coordinates, then returns it- Parameters:
loc
- The location- Returns:
- The block location
-
fromStringLater
public static void fromStringLater(java.lang.String string, java.util.function.Consumer<org.bukkit.Location> callback)Loads a Location from a String. If the world this Location is in is not yet loaded, waits for it to load, then passes the Location to the callback.- Parameters:
string
- The String to be parsed into a Locationcallback
- The callback to use the Location once it has been loaded
-
toString
public static java.lang.String toString(org.bukkit.Location loc)Converts a Location to a String. The same as calling toString(Location, " ")- Parameters:
loc
- The Location to be stringified- Returns:
- The stringified Location
-
fromString
public static org.bukkit.Location fromString(java.lang.String string)Converts a String back to a Location. The same as calling fromString(String, " ")- Parameters:
string
- The stringified Location- Returns:
- The Location
-
waitForWorld
public static void waitForWorld(java.lang.String worldname, java.util.function.Consumer<org.bukkit.World> callback)Waits for a world with the given name to load before calling the callback- Parameters:
worldname
- The name of the worldcallback
- A callback to be passed the world when it loads
-
getChunkCoordinates
public static int[] getChunkCoordinates(org.bukkit.Location loc)Gets the chunk X and Z of a location- Parameters:
loc
- The location to get the chunk coordinates of- Returns:
- An array containing the chunk coordinates [x, z]
-
directPathfind
public static java.util.List<org.bukkit.Location> directPathfind(org.bukkit.block.Block start, org.bukkit.block.Block end, int max, java.util.function.Predicate<org.bukkit.block.Block> filter)Finds the fastest path between a starting and ending location using A*, then removes unneeded steps for straight- Parameters:
start
- The starting blockend
- The ending blockmax
- The max number of locations to be checked - use to limit runtimefilter
- A filter to determine which blocks are passable- Returns:
- A List of locations leading from the start to the end, or the closest block if the path could not be completed
-
directPathfind
public static java.util.List<org.bukkit.Location> directPathfind(org.bukkit.block.Block start, org.bukkit.block.Block end, int max)Finds the fastest path between a starting and ending location using A*, then removes unneeded steps for straight- Parameters:
start
- The starting blockend
- The ending blockmax
- The max number of locations to be checked - use to limit runtime- Returns:
- A List of locations leading from the start to the end, or the closest block if the path could not be completed
-
pathfind
public static java.util.Deque<org.bukkit.Location> pathfind(org.bukkit.block.Block start, org.bukkit.block.Block end, int max)Finds the fastest path between a starting and ending location using A*- Parameters:
start
- The starting blockend
- The ending blockmax
- The max number of locations to be checked - use to limit runtime- Returns:
- A Deque of locations leading from the start to the end, or the closest block if the path could not be completed
-
pathfind
public static java.util.Deque<org.bukkit.Location> pathfind(org.bukkit.block.Block start, org.bukkit.block.Block end, int max, java.util.function.Predicate<org.bukkit.block.Block> filter)Finds the fastest path between a starting and ending location using A*- Parameters:
start
- The starting blockend
- The ending blockmax
- The max number of locations to be checked - use to limit runtimefilter
- A filter to determine which blocks are passable- Returns:
- A Deque of locations leading from the start to the end, or the closest block if the path could not be completed
-