MQ_RECEIVE
Section: Linux Programmer's Manual (3)
Updated: 2014-06-03
Index
Return to Main Contents
NAME
mq_receive, mq_timedreceive - receive a message from a message queue
SYNOPSIS
#include <mqueue.h>
ssize_t mq_receive(mqd_t mqdes, char *msg_ptr,
size_t msg_len, unsigned int *msg_prio);
#include <time.h>
#include <mqueue.h>
ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr,
size_t msg_len, unsigned int *msg_prio,
const struct timespec *abs_timeout);
Link with -lrt.
Feature Test Macro Requirements for glibc (see
feature_test_macros(7)):
mq_timedreceive():
-
_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L
DESCRIPTION
mq_receive()
removes the oldest message with the highest priority from
the message queue referred to by the descriptor
mqdes,
and places it in the buffer pointed to by
msg_ptr.
The
msg_len
argument specifies the size of the buffer pointed to by
msg_ptr;
this must be greater than or equal to the
mq_msgsize
attribute of the queue (see
mq_getattr(3)).
If
msg_prio
is not NULL, then the buffer to which it points is used
to return the priority associated with the received message.
If the queue is empty, then, by default,
mq_receive()
blocks until a message becomes available,
or the call is interrupted by a signal handler.
If the
O_NONBLOCK
flag is enabled for the message queue description,
then the call instead fails immediately with the error
EAGAIN.
mq_timedreceive()
behaves just like
mq_receive(),
except that if the queue is empty and the
O_NONBLOCK
flag is not enabled for the message queue description, then
abs_timeout
points to a structure which specifies a ceiling on the time for which
the call will block.
This ceiling is an absolute timeout in seconds and nanoseconds
since the Epoch, 1970-01-01 00:00:00 +0000 (UTC), and it is
specified in the following structure:
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
If no message is available,
and the timeout has already expired by the time of the call,
mq_timedreceive()
returns immediately.
RETURN VALUE
On success,
mq_receive()
and
mq_timedreceive()
return the number of bytes in the received message;
on error, -1 is returned, with
errno
set to indicate the error.
ERRORS
- EAGAIN
-
The queue was empty, and the
O_NONBLOCK
flag was set for the message queue description referred to by
mqdes.
- EBADF
-
The descriptor specified in
mqdes
was invalid.
- EINTR
-
The call was interrupted by a signal handler; see
signal(7).
- EINVAL
-
The call would have blocked, and
abs_timeout
was invalid, either because
tv_sec
was less than zero, or because
tv_nsec
was less than zero or greater than 1000 million.
- EMSGSIZE
-
msg_len
was less than the
mq_msgsize
attribute of the message queue.
- ETIMEDOUT
-
The call timed out before a message could be transferred.
ATTRIBUTES
Multithreading (see pthreads(7))
The
mq_receive()
and
mq_timedreceive()
functions are thread-safe.
CONFORMING TO
POSIX.1-2001.
NOTES
On Linux,
mq_timedreceive()
is a system call, and
mq_receive()
is a library function layered on top of that system call.
SEE ALSO
mq_close(3),
mq_getattr(3),
mq_notify(3),
mq_open(3),
mq_send(3),
mq_unlink(3),
mq_overview(7),
time(7)
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- RETURN VALUE
-
- ERRORS
-
- ATTRIBUTES
-
- Multithreading (see pthreads(7))
-
- CONFORMING TO
-
- NOTES
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 02:55:03 GMT, September 18, 2014


We’ve all heard how crucial it is to set intentions, goals and targets. Powerful goals electrify us. Clear intentions energize and pull us forward.


Add translation or commentary to a tweet.
Hey, you're probably wondering what's going to happen to your data should you read or write a post on lmtt.fyi. Here is a list of things we do with your data.
If you are just reading posts on lmtt.fyi, we DO NOT collect any personal data.
When you post something on lmtt.fyi, here are list of information we collect (we use Twitter OAuth).
We will NOT ...
We might ...
Every post on lmtt.fyi is shared as public post. Anyone who has link to your post can see what you wrote. Please see Content Policy for more information.


- To help our people to live their 100% Human potential.
- To create solutions "via magic code" with and for our people : ).
While growing up as an undetected dyslexic human being on planet earth, I've developed the desire to advocate for others; to make unfairness and hardship become things of the past.
My motto: “It’s better to fail while striving for something wonderful, challenging, adventurous, and uncertain, than to say, ’I don’t want to try because I may not succeed completely.'” (Jimmy Carter)
- Strengths: I LOOOOOVE learning; I LOOOOOVE to gain new skills I can use for some more action station.
- Limitation: Time management - Goal: Feeling re-enegized at the end of the Bootcamp. Need to make regular timeslots for fitness, family, friends and healthy food.
- I would like to work on my public speaking : )
- I need to make sure that I have good time management; take active breaks (go to gym, walks) and enjoy some time alone.
- have good time management; take active breaks (go to gym, walks), eat healthy food, enjoy some time alone.
- talk with the team and rest of the team if required.
A bit of a push for some public speaking opportunities and tech-support for my project
Some weekends are for the family: ) and some evenings will be required for friends & fitness.


Pininyahang Manok
INGREDIENTS
1/2 kilo chicken, cut ups
1 (227g) pineapple chunks
2 pcs potatoes, peeled and cubed
2 pcs potatoes, peeled and cubed
1 pc carrots, peeled and cubed
1 cup red and green bell peppers, desseded and cubed
1/2 cup all purpose cream or coconut cream (optional)
1/2 cup malunggay leaves (optional)
INSTRUCTIONS
First, get a pan and make it nice and hot over medium high heat. Pour some oil and throw in the onions and garlic. Saute until tender.
Add the chicken and cook until the color changes.
Drop in the Knorr Chicken Cube with the patis, the pineapple chunks with juice/syrup and water last. Give this a nice simmer of 3 minutes.
Next, add the potatoes, carrots and bell peppers. And cook them until the chicken and vegetables are tender. You may add the sugar if you want the dish to be a bit sweeter.
Get ready to reduce the heat to low before pouring in the all purpose cream or coconut cream. Be careful not to let this boil as the cream may curdle if the heat is too high. Add the malunggay leaves at this point. Cook for 1-2 minutes over low heat and that's it!
Spiced Chicken Wings
INGREDIENTS
5 pcs siling labuyo, chopped
2 tbsp spring onions, chopped
Optional: Serve with singkamas/jicama, carrot and celery sticks on the side
INSTRUCTIONS
This recipe is so simple and such a breeze to make. You’ll be surprised by how easy the process will be. First, you’ve got to flavour the wings in a mixture of Liquid Seasoning, Chicken Cube, sugar, sili, onion, garlic and sesame oil for at least 30 minutes.
Transfer the wings in a baking pan and place these in the oven to cook for 30 minutes or until the chicken is done.
Give your chicken wings a nice finish by adding a sprinkle of sesame seeds and chopped spring onions on top.
Tasty and spicy, Spiced Chicken Wings is guaranteed to be a winner whatever the occasion.
 Drop in the onions, garlic and ginger and sauté slowly for about 2 minutes or until you can smell the lovely aroma.
It’s time to drop in the chicken pieces and stir until it turns white or light brown in color.
Pour in the water and add your Knorr Chicken Broth cubes. Bring this to a simmer until chicken is tender and cooked through.
You can now add your sayote or green papaya and cook until tender.
Dahon ng sili is added at the last stage to ensure leaves (and nutrients) don’t dry up. Give this a minute then it is done. Malunggay is also another healthy alternative because it is packed with vitamins and minerals which are good for nursing moms and kids as well.
Enjoy this with patis and calamansi on the side. See the faces of your whole family light up as you bring this to the table.
Coconut Chicken Kare Kare
INGREDIENTS
3/4 kg whole chicken, chopped
1 pack Knorr Complete Recipe Mix Kare-Kare
1/2 pack Knorr Ginataang Gulay Mix
1/2 bundle pechay Tagalog
INSTRUCTIONS
For the first step, you need to cook the chicken in a stockpot filled with 6 of cups water and Knorr Chicken Cube.
Next, get another pan and heat this to medium high. Pour a little bit of oil and throw in the onion, garlic and meat. Allow these to cook for a few minutes or until you can smell the lovely aroma from the vegetables. Pour in the Knorr Complete Recipe Mix Kare Kare and the Knorr Ginataang Gulay Mix that have been dissolved in 3 cups of water.
You may now add the vegetables and allow these to simmer in low heat until the vegetables are cooked through.
With a large serving of rice, it’s nice and exciting to share something as creative as this with the family.
 Sprinkle them with some salt & pepper and coat them in the flour.
Add the olive oil and 1 tbsp of the butter to a skillet over medium-high heat. Once the pan is hot, sauté the chicken for 4-5 minutes/side or until it's nice and golden. Take the chicken out of the pan and set it aside.
Reduce the heat to medium (or even med-low if using cast iron), and add the rest of the butter to the pan. Let it melt and then add the garlic cloves. Cook them for 3-4 minutes, stirring often, until they're lightly browned on the outside.
Add the chicken broth, lemon juice, and garlic powder to the pan. Let it bubble for around 4 minutes or until the liquid is noticeably reduced.
Stir in the cream and add the chicken back into the pan. Let it cook for another 5 minutes or so, until the sauce is reduced and the chicken is cooked through. Serve with freshly chopped parsley if you wish.


WHERE THE MONEY IS A film review by Steve Rhodes Copyright 2000 Steve Rhodes RATING (0 TO ****): **
If Paul Newman would bottle his really secret sauce, he could make more than an Internet IPO. Whatever it is that he takes, it makes him look two years younger and better every year. And even with his white hair, he's no blonde bimbo, he seems to get brighter with advancing age.
All of the above notwithstanding, the mere casting of Newman in WHERE THE MONEY IS isn't enough to guarantee that the picture will be compelling. Any actor needs some material to work with, and the screenplay by the writing committee of E. Max Frye, Topper Lilien and Carroll Cartwright is sorely lacking in plot and character development. The most impressive credentials for the latter two writers, as noted in the film's press kit, is that Movieline in 1992 named their script for HELLO, STRANGER as one of the top 10 unproduced screenplays. This reminds me of the biggest bass that I never caught. You wouldn't believe its size.
The setup for this three-person story is that an old bank robber, Henry (Newman), gets released briefly from prison by faking a stroke. With the prison hospital full, Henry is taken to a nursing home composed almost exclusively of elderly women.
One savvy nurse, Carol (Linda Fiorentino), figures out his con and decides to force him out of his fake coma. Fiorentino (THE LAST SEDUCTION) has a take-no-prisoners sexuality that most directors shy away from. In one scene, director Marek Kanievska, takes advantage of this as he has her use lap dancing to coax a little life out of Henry. He proves a tough bird, however, who requires something more drastic for him to break his spell than a beautiful woman rubbing against him.
As her husband, Wayne (who was the king to her queen at their high school prom), Dermot Mulroney is given the least of all to do in an underdeveloped script.
Since Henry's a bank robber by trade and since Carol and Wayne aren't exactly in the chips, you might figure that the movie would involve a big robbery. If you did, you'd be right. The robbery, however, is made both needlessly complicated and ridiculously easy to execute. Similarly, the film's ending is entirely too neat, unbelievable and completely predictable.
A few parts of the movie are worth recommending. Beside the nicely done lap dancing scene, Fiorentino has a great short scene in which she uses her sexual charms to overpower a young bank clerk. This wide-eyed lad ends up giving her a toaster oven without her having to open the required bank account. Personally, I would have given her two.
WHERE THE MONEY IS runs 1:28, but the film's slow pacing belies its short length. It is rated PG-13 for sex and language and would be acceptable for teenagers.
Email<EMAIL_ADDRESS>Web: http://www.InternetReviews.com
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


jQuery effects are the first fun thing to learn. Try the buttons below to see these three effects: hide, slide, fade.
View this page on Codepen.
See more jQuery examples.
View GitHub repo.


The Wayback Machine - https://web.archive.org/web/20040930235921/http://www.angelfire.com:80/games2/NMjxl/
Search the web with Hotbot
Host your site on Angelfire
Kairi's kRO stuff
my NM page is gone forever, sorry. I am now using this space to host random stuff.
stuff
AC: Nexus video


Mainz announce Cologne reject Beierlorzer as new coach
BERLIN, Nov 18 — Bundesliga relegation candidates Mainz have announced Achim Beierlorzer as their new head coach, just nine days after the 51-year-old was fired by fellow strugglers Cologne.
Beierlorzer, who led Cologne to promotion as caretaker coach last season, was sacked earlier this month after a three-game losing run which started with defeat to Sandro Schwarz’s Mainz side on October 25.
Yet he now replaces Schwarz, who was dismissed by Mainz after a 3-2 home defeat to promoted side Union Berlin a week ago.
“Achim Beierlorzer is a typical coach for Mainz,” sporting director Rouven Schroeder told the club’s website.
“He is a meticulous and informed football expert and has a talent for developing a special team spirit.”
Mainz, a former club of both Liverpool manager Juergen Klopp and Paris Saint-Germain coach Thomas Tuchel, now sit third from bottom in the German top flight.
Cologne, who sit a place below them, are expected to announce former Hoffenheim and Hamburg boss Markus Gisdol as their new coach later today. — AFP


Haskell provides indexable arrays, which may be thought of as functions whose domains are isomorphic to contiguous subsets of the integers. Functions restricted in this way can be implemented efficiently; in particular, a programmer may reasonably expect rapid access to the components. To ensure the possibility of such an implementation, arrays are treated as data, not as general functions.
Since most array functions involve the class Ix, the contents of the module Data.Ix are re-exported from Data.Array for convenience:
| module Data.Ix |
| data Ix i => Array i e |
| instance Ix i => Functor (Array i) |
| instance (Ix i, Eq e) => Eq (Array i e) |
| instance (Ix i, Ord e) => Ord (Array i e) |
| instance (Ix a, Read a, Read b) => Read (Array a b) |
| instance (Ix a, Show a, Show b) => Show (Array a b) |
| array |
| :: | Ix i | |
| => | (i, i) | a pair of bounds, each of the index type of the array. These bounds are the lowest and highest indices in the array, in that order. For example, a one-origin vector of length ’10’ has bounds ’(1,10)’, and a one-origin ’10’ by ’10’ matrix has bounds ’((1,1),(10,10))’. |
| -> | [(i, e)] | a list of associations of the form (index, value). Typically, this list will be expressed as a comprehension. An association ’(i, x)’ defines the value of the array at index i to be x. |
| -> | Array i e | |
Construct an array with the specified bounds and containing values for given indices within these bounds.
The array is undefined (i.e. bottom) if any index in the list is out of bounds. If any two associations in the list have the same index, the value at that index is undefined (i.e. bottom).
Because the indices must be checked for these errors, array is strict in the bounds argument and in the indices of the association list, but non-strict in the values. Thus, recurrences such as the following are possible:
Not every index within the bounds of the array need appear in the association list, but the values associated with indices that do not appear will be undefined (i.e. bottom).
If, in any dimension, the lower bound is greater than the upper bound, then the array is legal, but empty. Indexing an empty array always gives an array-bounds error, but bounds still yields the bounds with which the array was constructed.
| listArray :: Ix i => (i, i) -> [e] -> Array i e |
| accumArray |
| :: | Ix i | |
| => | (e -> a -> e) | accumulating function |
| -> | e | initial value |
| -> | (i, i) | bounds of the array |
| -> | [(i, a)] | association list |
| -> | Array i e | |
The accumArray function deals with repeated indices in the association list using an accumulating function which combines the values of associations with the same index. For example, given a list of values of some index type, hist produces a histogram of the number of occurrences of each index within a specified range:
If the accumulating function is strict, then accumArray is strict in the values, as well as the indices, in the association list. Thus, unlike ordinary arrays built with array, accumulated arrays should not in general be recursive.
| (!) :: Ix i => Array i e -> i -> e |
| bounds :: Ix i => Array i e -> (i, i) |
| indices :: Ix i => Array i e -> [i] |
| elems :: Ix i => Array i e -> [e] |
| assocs :: Ix i => Array i e -> [(i, e)] |
| (//) :: Ix i => Array i e -> [(i, e)] -> Array i e |
is the same matrix, except with the diagonal zeroed.
Repeated indices in the association list are handled as for array: the resulting array is undefined (i.e. bottom),
| accum :: Ix i => (e -> a -> e) |
| -> Array i e -> [(i, a)] -> Array i e |
| ixmap :: (Ix i, Ix j) => (i, i) |
| -> (i -> j) -> Array j e -> Array i e |
A similar transformation of array values may be achieved using fmap from the Array instance of the Functor class.


--- layout: post title: Yahoo blogging... Marketing marketing... ---
Just read from Scoble that Yahoo search team starts blogging... There's always a start, but this one looks like a PR announcement. Let's hope they get better in the next few days.
Have you noticed how much a lot of corporate blogs actually are PR announcement mailing lists using RSS feeds? The corporate world has a world collision shock to do if it wants to adopt blogging as a real communication tool. And this is a great challenge!


Styling Text
Apply styles to text appearance
Applying bold to text
Bold text in here
Applying italic to text
Italic text in here
Apply styles to text font
Different font in here
Different font size in here
Applying styles to text alignment, spacing, and indentation
Text alignment
Text aligned center in here
Text indentation
Text indented in here
Text spacing
Letters spaced in here
Words spaced in here
Applying styles to text hyphenation
Long sentence and a weirdlongword in a small div
Second long sentence and a weirdlongword in a small div
Third long sentence and a weirdlongword in a small div


[gecode-users] Gecode memory question
Guido Tack
tack at ps.uni-sb.de
Sat Dec 5 16:07:15 CET 2009
Hi Gustavo,
you can allocate from the general heap, which is available in Gecode through the Heap class and the global object called heap. Furthermore, to get sharing right, you should derive from the SharedHandle/SharedObject infrastructure we provide. Just have a look at how SharedArrays are implemented, for example. They have exactly the behavior you describe.
Cheers,
Guido
Gustavo Gutierrez wrote:
> Dear all,
>
> I am trying to implement something which at a first sight could look weird and have a memory problem, I will try to be as concise as possible while giving enough details to have some help from you; if you need to know more, I don't have any problem to explain my situation in a deeper way.
>
> I have some data structures which are external to propagators but that I need to share among computation spaces. Still, I would like to have this data structures allocated in some way by gecode itself and not from using new (malloc). Let's have a look at the following example of a main program creating some instances of Space:
>
>
> opt.parse(argc,argv);
> Space *sp = new Simple(opt);
> sp->status();
> Space *csp = sp->clone(true);
> csp->status();
> //delete sp;
> Space *csp2 = csp->clone(true);
>
>
> Just assume that there are no propagators posted during the construction of Simple, just a branching. Now, If I am right, by sending true to clone will cause the data structures (variables, etc) to be shared. Then csp will share data structures with sp. Now, I am considering to clone (and share again the data structures) csp into csp2. If at some point, I decided to delete sp I will get a memory problem, this is, there are data structures inside csp2 that are supposed to *point* to something that where in sp but now is deallocated.
>
> I am using the space allocator to allocate the data structures, so I think that a space is deallocated by removing its complete heap from memory. If I understand correctly, there is a one to one relation between a space and a space heap. In my case, I would like to allocate the data structures somewhere else in such a way that those are no removed when spaces are deallocated. Is it possible to do that in gecode?, is there some "general heap" from which I can allocate memory from?, if yes, is there an allocator to allocate memory from this part?.
>
> I would like the memory to be allocated by gecode because in that way (I think) it will be reported as part of the statistics when running a search engine. Also, the data structures I am using use reference counting for the memory management but are not thread safe so I would like to know how this would interact with parallel search engines. I don't want to cause any heap segmentation (I am not sure how much sensible is gecode to memory alignment in its heap and things like that) that severely affects gecode performance.
>
>
> Any comment is more than welcome and thanks in advance.
>
> Gustavo
>
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users
More information about the users
mailing list


"Charettes"
"Hold me"
"Squeeze me"
"Rise"
+
"Spin me"
"Reset row"
1
2
3
4
"Change the channel"
"Create"
"ROY G. BIV"
"Brrr, the temperature is..."
"Dissappear"
"Reset row"
"My glasses.
"Fire!"
"Get big"
"Ball pit"
"Square dance"
"Click once"
"Double click"
"Reset row"
"Hate to see you go"
"Ok seriously, please leave"
"Let's get aggressive"
"Reset page"


---
layout: layouts/post.njk
title: "Material Theming: Making Material Your Own!"
permalink: /material-theming-intro/
date: '2019-06-03'
comments: true
tags:
- Material
- Material Design
- Theme
description: "Creative web design and systematic web design don’t need to be at arms. This post examines how to use a design system (Material) and extend it to make it your own."
link-out: https://css-tricks.com/material-theming-making-material-your-own/
---
If you are not redirected, please visit this think!


Laravel provides a unified API for various caching systems. The cache configuration is located at app/config/cache.php
. In this file you may specify which cache driver you would like used by default throughout your application. Laravel supports popular caching backends like Memcached and Redis out of the box.
The cache configuration file also contains various other options, which are documented within the file, so make sure to read over these options. By default, Laravel is configured to use the file
cache driver, which stores the serialized, cached objects in the filesystem. For larger applications, it is recommended that you use an in-memory cache such as Memcached or APC.

Cache::put('key', 'value', $minutes);
$expiresAt = Carbon::now()->addMinutes(10);
Cache::put('key', 'value', $expiresAt);
Cache::add('key', 'value', $minutes);
The add
method will return true
if the item is actually added to the cache. Otherwise, the method will return false
.
if (Cache::has('key'))
{
//
}
$value = Cache::get('key');
$value = Cache::get('key', 'default');
$value = Cache::get('key', function() { return 'default'; });
Cache::forever('key', 'value');
Sometimes you may wish to retrieve an item from the cache, but also store a default value if the requested item doesn't exist. You may do this using the Cache::remember
method:
$value = Cache::remember('users', $minutes, function()
{
return DB::table('users')->get();
});
You may also combine the remember
and forever
methods:
$value = Cache::rememberForever('users', function()
{
return DB::table('users')->get();
});
Note that all items stored in the cache are serialized, so you are free to store any type of data.
Cache::forget('key');

All drivers except file
and database
support the increment
and decrement
operations:
Cache::increment('key');
Cache::increment('key', $amount);
Cache::decrement('key');
Cache::decrement('key', $amount);

Note: Cache tags are not supported when using the
file
ordatabase
cache drivers. Furthermore, when using multiple tags with caches that are stored "forever", performance will be best with a driver such asmemcached
, which automatically purges stale records.
Cache tags allow you to tag related items in the cache, and then flush all caches tagged with a given name. To access a tagged cache, use the tags
method.
You may store a tagged cache by passing in an ordered list of tag names as arguments, or as an ordered array of tag names:
Cache::tags('people', 'authors')->put('John', $john, $minutes);
Cache::tags(array('people', 'artists'))->put('Anne', $anne, $minutes);
You may use any cache storage method in combination with tags, including remember
, forever
, and rememberForever
. You may also access cached items from the tagged cache, as well as use the other cache methods such as increment
and decrement
.
To access a tagged cache, pass the same ordered list of tags used to save it.
$anne = Cache::tags('people', 'artists')->get('Anne');
$john = Cache::tags(array('people', 'authors'))->get('John');
You may flush all items tagged with a name or list of names. For example, this statement would remove all caches tagged with either people
, authors
, or both. So, both "Anne" and "John" would be removed from the cache:
Cache::tags('people', 'authors')->flush();
In contrast, this statement would remove only caches tagged with authors
, so "John" would be removed, but not "Anne".
Cache::tags('authors')->flush();

When using the database
cache driver, you will need to setup a table to contain the cache items. You'll find an example Schema
declaration for the table below:
Schema::create('cache', function($table)
{
$table->string('key')->unique();
$table->text('value');
$table->integer('expiration');
});


TestMe
Menu
Home
About
Gallery
Create
Contact
Submission Form
TEST
SURVEY
Your Name
Form Name
Question List
Add Short Answer Question
Add Long Answer Question
Add Multiple Choice Question
Add True False Question
Add Ranking Question
Delete


What's your take on the DBC/EDA experience?
For me the EDC experience is one that I have actively chosen to undertake. It's not something that is expected or required or part of the job etc. We have all chosen to be here. It's a fork in the road and so far 4 days in it's been great. It is a totally different approach to education then what I am used but I am enjoying it and really excited to see where the journey goes.
What are your impressions?
So far so good! The course is going to be a lot of hard work but I am certain it will be worth it. Everyone - both students and teachers have been really friendly and extemely helpful so it has been a great positive start!
How do you see yourself engaging with this type of culture?
It's going to take a little bit of practise! It's certainly very different to any other educational culture I have experienced before - but in a great way! I am looking forward to seeing how it all unfolds and the experience this new culture brings.
Have your expectations of EDA changed, if so how?
I knew the staff and the students were going to be supportive throughout the course to some degree but that level of support is much higher then my initial expectations. Everyone is so eager to help each other out in any way they can. It's really great to see such a level of support and encouragement from everyone involved.
Are you excited to participate in this kind of learning environment? Does it make you nervous?
Yes, I am really excited to take part. The environment is new, fast-moving, informative and energetic and yes it makes me nervous - but in a really great - I don't know what's around the next corner kind of way!


I’m a Lead Data Scientist in the Chief Analytics Office at IBM. I currently am the Technical Lead for the Finance and Planning team where we build revenue forecasts to gauge progress towards financial targets.
Previously, I applied NLP to build recommendations for upskilling in the People Analytics domain.
I hold a PhD in Sociology from the University of Arizona. My research focused on social networks, health behavior, diffusion, and communication technologies. In my PhD dissertation, I specifically studied how people search for information and rely on this information to inform their health behaviors and develop social norms, particularly during times of uncertainty. You can find some of my publications from journals like Ethnic and Racial Studies, Sociological Perspectives, Journal on Migration and Human Security, and the Journal of Religion and Health below.
I am a Posit Academy Mentor, a Certified RStudio Trainer and a Carpentries instructor. You can view some of my open source teaching materials at my Youtube Channel, a sample semester-long course website or 3-day seminar materials.
Feel free to get in touch via the contact form at the bottom of this page.
PhD in Sociology, 2022
University of Arizona
Grad Certificate in Computational Social Science, 2020
University of Arizona
MA in Sociology, 2019
University of Arizona
MPhil in Race, Ethnicity, and Conflict, 2015
Trinity College, Dublin
Using data from the Migrant Border Crossing Project (Slack, Martínez, and Whiteford), I map out how Mexican origins cross the US border at different points en route to new destinations.
How have rankings of Sociology Graduate programs over time?
Which states have been most impacted by unemployment due to the 2020 Coronavirus pandemic?
Tidy Tuesday: How similar are European Energy Producers?
Which states decreased their movement due to COVID-19 and by how much?


This example shows how to use the client-side API of Telerik ComboBox for ASP.NET MVC and Telerik DropDownList for ASP.NET MVC.
To use the client-side API you should first retrieve the combobox/dropdownlist client-side object. The following code snippet shows how to do this for the combobox:
<script type="text/javascript"> function getComboBox(){ //"ComboBox" is the value specified by the Name() method. var combobox = $("#ComboBox").data("tComboBox"); return combobox; } </script>
Available client-side methods:


Papers We Love Romania
Community built around reading, discussing and learning more about academic computer science papers.
Meetups around Romania
PapersWeLove @București
PapersWeLove @Iasi
PapersWeLove @Timișoara
GitHub


class: center, middle # The GoLang Playground ## Nick Brown ## UCSB CS 263 - Spring 2017 .displayed[![sticker](gophers/sticker.png)] --- # Agenda 1. [Introduction](#intro) 2. [Objective](#objective) 3. [System Architecture](#architecture) 4. [Implementation](#implementation) 5. [My Contribution](#contribution) .tl-corner[![fancy_gopher_renee](gophers/fancy_gopher_renee.jpg)] --- name: intro # Introduction - GoLang .br-corner[![baby](gophers/baby.jpg)] > Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. * Statically typed * Built-in concurrency support * Standardized formatting via `go fmt` * As a result, most GoLang code looks the same! * Good for collaboration * Like C or C++, but without "extraneous garbage" and unsafe pointer operations * Go "Runtime" included in binaries with GC, concurrency, stack management, etc. * Not a VM like Java --- # GoLang Playground .bl-corner[![gopherswrench](gophers/gopherswrench.jpg)] A Web service that compiles + executes arbitrary Go code, returning program output * Original GoLang PlayGround * [https://play.golang.org/](https://play.golang.org/) * Simple Operations * Edit - Write code in [GoLang](https://golang.org/) * Run - Send code to server, get back program output or compiler errors * Format - Take your ugly code and send it back to you with good format * Share - Share your bad program with your friends --- name: objective # Problem? .br-corner[![bupher](gophers/bupher.png)] * The GoLang Playground already exists! Why do we need to remake it??? -- * Current version has restrictions * Limited CPU, RAM * No Network Access * No File System Access * Concurrency, Networking → key strengths of GoLang * Restrictions are half-addressed in Playground * Fake Time * Fake File System * Fake Network --- # What do we want? .tr-corner[![sticker](gophers/sticker.png)] * To address current version's restrictions * Limited CPU, RAM → Unlimited? * No Network Access → Network Access * No File System Access → FS Access * But restrict the increased capability to logged-in users --- name: architecture # Architecture .tl-corner[![gopherhelmet](gophers/gopherhelmet.jpg)] .left-column[![Go Playground Architecture](go-playground.jpg)] .right-column[ 1. JavaScript Client communicates HTTP/WebSocket with Front-End to display output 2. Front-End receives user input via HTTP/WebSocket and delivers output from Back-End RPCs to Client a. Caches redundant inputs to prevent overload 3. Back-End receives RPCs to compile + execute user programs; returns program output or compiler errors ] --- # Architecture - Client .br-corner[![gopherhelmet](gophers/gopherhelmet.jpg)] .left-column[![Go Playground Architecture](go-playground.jpg)] .right-column[ The JavaScript client chooses HTTP or WebSocket interface for running GoLang code and receiving outputs * **HTTP** - Output is gathered and sent back in one response * **WebSocket** - Output is sent to the client as it is generated Timing is preserved via output delays from JSON response. * Recall: time is fake on server side * All programs start at `2009-11-10 23:00:00 +0000 UTC` * Output is separated into timed chunks * To the user, it looks like program is run in real time ] --- # Architecture - Front-End .bl-corner[![gopherhelmet](gophers/gopherhelmet.jpg)] .left-column[![Go Playground Architecture](go-playground.jpg)] .right-column[ Receives client code, dispatches RPCs, sends translated output and compiler errors back to client * _Caches_ program outputs so that redundant inputs don't overwhelm the system * _Decodes_ output from the Back-End and sends output back to the client with playback info Mostly trivial — just a routing/translation component ] --- # Architecture - Back-End .tl-corner[![gopherhelmet](gophers/gopherhelmet.jpg)] .left-column[![Go Playground Architecture](go-playground.jpg)] .right-column[ Receives small goroutines to _compile_ and _execute_. * _Compiles_ user code into `NaCl`.red[*] executables * _Executes_ compiled code * Returns encoded.red[**] output or compilation errors in response Ensures safe execution of arbitrary code in sandboxed environment (NaCl) * Compiles differently to fake Time, Network, and FS .footnote[ .red[*] Google's Native Client, discussed in next slide .red[**] Encoded for timed playback ] ] --- name: implementation # NaCl - Google Native Client .br-corner[![pirate](gophers/pirate.png)] Originally designed to permit the safe execution of x86 programs inside web browsers * Implements sandbox environment for 32-bit x86, 64-bit x86, and 32-bit ARM * Arranges assembly instructions in a verifiable way to disable certain functions * Typically the job of the linker — most higher-level packages can stay the same * `syscall` package re-implemented for `NaCl` It is essentially a new operating system providing its own execution environment * Includes custom OS features — syscall, malloc, threads, signals, etc. * No access to pipes, networking, file system * A simulated clock starting at Unix time<PHONE_NUMBER> Unsupported, but available: `PNaCl` — Portable Native Client * Portable bytecode format for `NaCl` based on LLVM ??? Note: it was built for web browsers (\*cough\* Google Chrome \*cough\*) but is not necessarily restricted to being run in web browsers. Note about 64-bit x86, where NaCl adjustment is also required of compiler and runtime * pointers are only 32 bits wide * disallows the use of register R15 * and disallows the use of multi-register addressing modes --- # Handling Processes .tr-corner[![cowboy](gophers/cowboy.png)] ```go type Message struct { Id string // client-provided unique id for the process Kind string // "stdout", "stderr", "end" Body string } // Process represents a running process. type Process struct { id string // user-defined process ID out chan<- *Message done chan struct{} // closed when wait completes run *exec.Cmd // the command running; Kill method is available } ``` * Keeping track of these objects lets us manage runtime * Program output is wrapped in `Message` struct * Convert `Message` to/from JSON using Go `encoding/json` package ??? Users and system can kill process Messages from out are sent over WebSocket Connections --- # Timing: Front-End ↔ Client .bl-corner[![biplane](gophers/biplane.jpg)] ```go func main() { stop := time.After(3 * time.Second) tick := time.NewTicker(1 * time.Second) defer tick.Stop() for { select { case <-tick.C: fmt.Println(time.Now()) case <-stop: return } } } ``` ```sh 2009-11-10 23:00:01 +0000 UTC 2009-11-10 23:00:02 +0000 UTC 2009-11-10 23:00:03 +0000 UTC Program exited. ``` ??? This is what the client sends and receives * the lines are each separated by a second --- # Timing: Front-End ↔ Client .tr-corner[![biplane](gophers/biplane.jpg)] ```sh 0 0 P B <8-byte time> <4-byte data length>
\x00\x00PB\x11\x74\xef\xed\xe6\xb3\x2a\x00\x00\x00\x00\x1e2009-11-10 23:00:01 +0000 UTC \x00\x00PB\x11\x74\xef\xee\x22\x4d\xf4\x00\x00\x00\x00\x1e2009-11-10 23:00:02 +0000 UTC \x00\x00PB\x11\x74\xef\xee\x5d\xe8\xbe\x00\x00\x00\x00\x1e2009-11-10 23:00:03 +0000 UTC ``` ```json { "Errors": "", "Events": [ { "Delay":<PHONE_NUMBER>, "Message": "2009-11-10 23:00:01 +0000 UTC\n" }, { "Delay":<PHONE_NUMBER>, "Message": "2009-11-10 23:00:02 +0000 UTC\n" }, { "Delay":<PHONE_NUMBER>, "Message": "2009-11-10 23:00:03 +0000 UTC\n" } ] } ``` ??? Top is what is generated on the back-end Bottom is what the front-end parses it into --- # Networking .bl-corner[![run](gophers/run.png)] Restrictions on network input and output * Can use loopback interface (<IP_ADDRESS>) * Listening for connections * Making requests * Requests to any other hosts will fail horribly --- name: contribution # My Contribution .tl-corner[![viking](gophers/viking.jpg)] * Replicated all existing functionality of the GoLang Playground * Removed dependency on Google Cloud * Enable both WebSocket + HTTP communication * Added User Login + Sign-up * For logged-in users, add enhanced functionality * Instead of `NaCl`, use regular `go build` * Run compiled binary under `chroot`-ed environment and clean up afterwards * https://golang.org/pkg/syscall/#Chroot * https://golang.org/pkg/syscall/#StartProcess - wraps [clone(2)](http://man7.org/linux/man-pages/man2/clone.2.html) * Still have timeout, albeit a bit longer * people shouldn't host websites or mine bitcoin on my playground * Don't cache outputs * Require WebSocket communication for enhanced functionality --- # Inspiration - Dan Nurmi ```c #define _GNU_SOURCE #include
#include
#include
#include
#include
#include
char cstack[1024*1000]; static int child_init() { chroot("/tmp/rootfs"); system("mount -t proc proc /proc"); // work... return(0); } int main(int argc, char **argv) { pid_t cpid; cpid = clone(child_init, cstack + (1024*1000), CLONE_NEWPID | CLONE_NEWNET | CLONE_NEWNS | SIGCHLD, NULL); waitpid(cpid, NULL, 0); exit(0); } ``` --- class: center, middle # Thank You! Questions? .bl-corner[ ![gophergrad](gophers/gophergrad.jpg) ![aviator](gophers/aviator.png) ![bupher](gophers/bupher.png) ![cowboy](gophers/cowboy.png) ![fancy_gopher_renee](gophers/fancy_gopher_renee.jpg) ![biplane](gophers/biplane.jpg) ![pirate](gophers/pirate.png) ![viking](gophers/viking.jpg) ![run](gophers/run.png) ]


Prototype
TEA Prototype
AW8P - Beta Prototype
- Version 10 - 18th December 2019 - Integrate with "My NHS Pension"
- Version 9 - 13th November 2019 - Intenational Banking Mandate and Ill Health
- Version 8 - 2nd April 2019
- Version 7 - 28th March 2019
- Version 6 - 20th August 2018
- Version 5 - 22nd January 2018
- Version 4 - 5th January 2018
- Version 3 - 18th December 2017
- Version 2 - 10th December 2017
- Version 1 - 13th November 2017


India's Coolest Marketplace
Home
Login
Back
Enter your first name:
Please enter the first name
Enter your last name:
Please enter the last name
Enter your mobile no:
Please enter the mobile number
Enter your email id:
Please enter the email id
Username:
Please enter the username
Password:
Please enter the password
Confirm Password:
Please enter confirm password
Reset
Register


Form
: Form
Form has been introduced as a language specific feature for Irish. It covers both the morphology of direct/indirect relative markers, and initial mutation.
Direct
: direct
Direct relatives represent the relative marker a in the following contexts:
Examples
(Relativisers where mark:prt applies)
- Nuair a chonaic mé “when I saw”
- Fad a bhí sé ann “while he was there”
Relative pronouns that represent a missing subject or object in the relative clause
- cé mhéad fuinnimh a bheidh le fáil “how much energy would be available” (nsubj)
- rudaí a sheoltar ar ais “things that were sent back” (obj)
Cases of a that are regarded as Pronouns instead of particles (according to FGB https://www.teanglann.ie/ga/fgb/a)
- An bhfuair tú a bhfuil uait? Did you get what you wanted? (nsubj in this case)
Indirect
: indirect
Indirect relatives represent the relative marker a in the following contexts:
Examples
Relative pronouns that represent a missing oblique (PP head)
- an teach inar thug sé an chuid ba mhó dá óige “the house in which he spent most his youth” (obl)
Resumptive pronouns, whereby the element which is represented is actually still present in the relativised clause
- an scríbhneoir a molann na mic léinn é “the writer who the students praise” (mark:prt)
Possessive relativisers - where the a represents the missing possessor in the relativised clause
- An fear a raibh a mhac san ospidéal “the man whose son was in hospital” (mark:prt)
One of the characteristics of Irish is its tendency for initial mutation (eclipsis and lenition) to occur in certain circumstances. This is triggered by the preceding word and affects the spelling of nouns, adjectives and verbs. Nouns in Irish are divided into classes according to the way they are inflected to form the genitive singular. There are five such noun-classes or declensions. (The Christian Brothers, 1994)
Ecl
: eclipsis
This feature occurs when the initial consonant or vowel of a word is eclipsed by a prefixing consonant. This is either a voiced consonant for voiceless consonants, (e.g. /tʲ/ → /dʲ/, /k/ → /g/) or a nasalised consonant for voiced consonants (e.g. /dʲ/ → /nʲ/, /g/ → /ŋ/). Vowels are eclipsed by adding n- or t-.
Not every consonant can experience eclipsis. The consonants that can be eclipsed in Irish are: p, b, t, d, c, g and f.
Eclipsis will happen in a number of environments:
- after the plural possessive nouns ár, bhur and a (“our”, “your (pl.)”, “their”)
- on singular count nouns following the numbers 7-10
- after the preposition i “in”
- on plural nouns in the genitive case after the definite article
- on singular nouns in the dative case after the definite article
- following certain clitics such as interrogative particles (an, nach), complementisers (go, nach) and relativisers (a, nach)
Examples
- a gcuid iarrachtaí “their efforts”
- seacht mbliana “seven years”
- i nGaeilge “in Irish”
- costas na n-oibreacha “cost of the works”
- ar an bhfocal “on the word”
- nach bhfaca sé “he didn’t see”
Emp
: emphatic
The emphatic form is a special form a word takes to mark emphasis in Irish.
Examples
- dom “to me”
- domsa “to me (emph)”
- a deirim “I said”
- a deirimse “I (emph) said”
Len
: lenition
Lenition is by far the most common means of initial mutation in the treebank. When lenited, h is added immediately after the initial consonant.
These are some of the environments that trigger lenition:
- following the definite article (see Definite for specifics)
- following the vocative particle a (see PartType, Case)
- after certain adjectives (singular possessive pronouns, uile, aon, dhá, etc.)
- after certain simple prepositions (a, de, do, faoi, etc.)
- following the past tense of the copula is
- following preverbal particles in the past tense (níor, ar, etc.)
- verb forms in the past tense
Examples
- an fharraige “the sea”
- A Dhochtúir Van Helsing “Doctor Van Helsing”
- mo chuid oibre “my work”
- faoi cheist “under question”
- Ba mhaith liom “I would like”
- Níor chuir sin “that doesn’t put”
- tháinig “came”
HPref
: h-prefix
When two vowels come together in Irish, a h-prefix is inserted before the second vowel in order to simplify pronunciation.
Examples
- go hálainn “lovely”
- na heisimirce “emigration”
- de h-Íde “from Íde”
- ní hamháin “not only”
VF
: Vowel form
Vowel form is an indicator of spelling changes that occur in copular verbs when followed by a word that begins with a vowel or a lenited consonant.
Examples
- is copula, “is”
- ab ea iad “they are”
- gurbh é “it was”
- B’fhearr leis lit. “it was better for him”
Form in other languages: [ga] [gd] [gv] [ko] [la]


Cryptography with Prolog
Introduction
Prolog has several features that make it extremely well-suited
for cryptographic applications. For example,
built-in integer arithmetic that works
for arbitrarily large numbers makes it easy to reason about large
prime numbers and various operations on them that frequently
arise in the context of cryptography. As another example, Prolog's
built-in search mechanism
lets you easily experiment with brute-force attacks such as
exhaustive search for keys, which has great didactic
value. The Prolog toplevel
lets us interactively try various predicates and their
parameters. And so on.
Support for cryptographic algorithms varies between
Prolog systems. In the following, we are using Scryer Prolog due
to its
library(crypto).
| Video: |
|
In this text, we consider three aspects of cryptography that are
extremely relevant in practice:
We shall focus on the practical application of these
methods, with sample code that you can try out and use. The
methods I use in this document are all deemed at
least reasonably secure
in December 2022. Beware though: Make sure to follow best
current practices when you use these methods in your own
applications. This includes studying additional reference material
and at least an introductory textbook on this subject. For
example, consider
reading Introduction
to Modern Cryptography by Jonathan Katz and
Yehuda Lindell, and the references included therein.
The convention I use in this document is that information that
ought to be kept secret is
written in red.
Data representation: characters, codes, bytes etc.
In Prolog, lists of characters are the preferred
representation of text and also of binary data. The reason is that
lists of characters can be represented very efficiently, and are
amenable to reasoning with DCGs and built-in predicates for lists.
Also, processing lists of characters leaves little trace in a
system's atom table. These properties make lists of
characters an ideal representation in cryptographic applications.
A character is an atom of length 1. A list of characters is
also called a string. Each character has a
corresponding code, which is an integer. The standard
predicate char_code/2 relates a character to its code.
In the following, we assume that the Prolog
flag double_quotes is set to chars, which is the
default and recommended setting in Scryer Prolog. It lets us write
a string very compactly if we enclose it in double quotes.
For example, the string [a,b,c] can be written more
compactly as "abc".
Hexadecimal escape sequences can be used in strings to embed any
character by its code. For example, the
string "\x0\\x12\\x2124\" is the same term as the
list ['\x0\','\x12\','\x2124\'], namely a list with three
characters with respective codes 0, 18 and 8484.
Cryptographic methods typically work on bytes, and
code points that are greater than 255 do not fit into a
single byte. Therefore, many predicates
in library(crypto) provide two different ways to reason
about strings, specified via the encoding/1 option:
- encoding(utf8) uses the UTF-8 encoding of
the string as the sequence of bytes. This is the default.
- encoding(octet) works on the sequence of
bytes that is specified by the code of each character in
the list. Of course, this only works if all occurring characters
have codes in the range 0..255.
If the encoding(octet) option is used, then you may (as
an alternative to a list of characters) also specify a list
of bytes as the input, i.e., integers in the
range 0..255.
There are conversion predicates that let us transform every Prolog
term into a list of characters or bytes that can be processed
with library(crypto). For example, the standard
predicate atom_chars/2 relates an atom to a list of
characters, and the predicate chars_utf8bytes/2
from library(charsio) relates a list of characters to its
UTF-8 encoding, specified as a list of bytes:
?- atom_chars('κρυπτός', Cs).
Cs = "κρυπτός".
?- chars_utf8bytes("κρυπτός", UTF8).
UTF8 = [206,186,207,129,207,133,207,128,207,132|...].
In cryptographic applications, short lists of bytes also
often need to be communicated to other programs and participants,
and in these use cases it is common to represent such lists
in hexadecimal notation. This means that each byte is
represented by exactly two hexadecimal digits
(between 0 and F) that are then stringed
together. We can use hex_bytes/2 to easily
convert between these encodings:
?- hex_bytes("501ACE", Bs).
Bs = [80,26,206].
?- hex_bytes(Hex, [80,26,206]).
Hex = "501ace".
To create a list of cryptographically strong pseudo-random
bytes, we can
use crypto_n_random_bytes/2. For
example, here is a 256-bit (i.e., 32 bytes) sequence that in all
likelihood nobody else has ever generated before me:
?- crypto_n_random_bytes(32, Bs),
hex_bytes(Key, Bs).
Bs = [135,227,97,217,131,152,108,154,145,104|...],
Key = "87e361d983986c9a91686ef90ccdedc22b852370612543ab99563ba92bd902b5"
Thus, we can easily generate strong keys and unique tokens when needed.
To more compactly store and embed binary data in your
applications, also consider Base64 encoding.
Cryptographic hash functions
A cryptographic
hash function lets us efficiently map data
of arbitrary size to a bit string of fixed
size in such a way that the mapping is infeasible to invert and
collisions are very unlikely.
Hash functions are needed in almost all applications of modern
cryptography. In library(crypto),
among the most important predicates for computing cryptographic
hashes
is crypto_data_hash/3.
Here is an example (click on the hash to expand it):
?- crypto_data_hash("Hello world!", Hash, [algorithm(blake2s256)]).
Hash = "c63813a8f804abece06213a46acd04a2d738c8e7a58fbf94bfe066a9c7f89197".
We can use hex_bytes/2 to convert such hex-encoded values
to lists of bytes, by which we mean lists of integers
between 0 and 255. For example:
?- hex_bytes("c63813a8f804abece06213a46acd04a2d738c8e7a58fbf94bfe066a9c7f89197", Bytes).
Bytes = [198,56,19,168,248,4,171,236,224,98|...].
Security of default algorithms is an important design
principle of library(crypto). For this reason, the only
guarantee that the hash predicates give is that the default
algorithm is cryptographically secure. The default may change
in the future. To find out which algorithm was actually used, we
can specify the algorithm/1 option, and use
a variable as argument. For example:
?- crypto_data_hash("Hello world!", Hash, [algorithm(A)]).
Hash = "c0535e4be2b79ffd93291305436bf889314e4a3faec05ecffcbb7df31ad9e51a",
A = sha256.
This shows that sha256 is currently the default
algorithm. We can use this approach to ensure interoperability
and at the same time benefit from more secure defaults that may be
used in the future.
A hash can be used to assess the integrity of data: By
computing the hash and comparing it against a
reference value, you can detect corruption and manipulation
of your data.
This raises the question: How can we be certain that such
a reference value is actually authentic, i.e.,
truly stemming from the purported originator? One way to ensure
the authenticity of data is to
use digital signatures.
Storing passwords safely
Hashes can also be used to securely store
user passwords for the purpose of authentication. In
fact, to store a password securely, the main idea is
to avoid storing the password altogether. Instead, we store
only the hash of the password. Later, when the user enters
a password, we compute its hash, and compare that hash against the
stored value.
Two additional features make this process vastly more secure:
- First, we make computing the hash as slow as
we can. This counteracts brute-force attacks where an
attacker tries many different passwords to find one whose hash
matches the stored hash. One way to do this is to compute
the N-fold application of the hash function. For
example, N = 217 makes brute-force
attacks more than 100 000 times slower than applying
the hash only once.
- Second, we generate a so-called salt, which is a list
of random bytes that we combine with the password before it is
hashed. We thus ensure (with extremely high probability) that
even identical passwords yield different
hashes. We store the salt together with the computed hash, so
that we can use it for later reference.
All of this happens completely automatically
with crypto_password_hash/2.
For example:
?- crypto_password_hash("test", Hash).
Hash = "$pbkdf2-sha512$t=131072$Xj6ZIfB4U+QOeZr3ymE/AA$2KYXsPFI2zJVMb9PHVtN+pVwQ6f7LleXF8ehbyqgOmkINcIYjO8IFhz8LelwMjzidEtojRHmC0B5RQJDEB2/tw".
?- crypto_password_hash("test", Hash).
Hash = "$pbkdf2-sha512$t=131072$+aXCnE1r3gAFjpQ3qHcsVw$JAiD2sLbBZPQD1/FtBJUE+iWXRF0VvC/p8etsP6JGSo2dz5U+lV3a6tFDo84mluW1BufFoGZkAuaMW+K74DIaQ".
In this case, even though the password was the same in
both queries, the hashes are different.
The resulting hash encapsulates everything that is necessary to
later verify a password and thus authenticate
the user:
?- crypto_password_hash("test", "$pbkdf2-sha512$t=131072$+aXCnE1r3gAFjpQ3qHcsVw$JAiD2sLbBZPQD1/FtBJUE+iWXRF0VvC/p8etsP6JGSo2dz5U+lV3a6tFDo84mluW1BufFoGZkAuaMW+K74DIaQ").
true.
?- crypto_password_hash("password", "$pbkdf2-sha512$t=131072$+aXCnE1r3gAFjpQ3qHcsVw$JAiD2sLbBZPQD1/FtBJUE+iWXRF0VvC/p8etsP6JGSo2dz5U+lV3a6tFDo84mluW1BufFoGZkAuaMW+K74DIaQ").
false.
Experience shows that most users choose very predictable
passwords, and also reuse the same passwords for different
applications. Using crypto_password_hash/2 in your
applications makes it hard for attackers to find out which
passwords were used, even if they manage to obtain all hashes
you store.
If necessary, we can use crypto_password_hash/3 to
specify the applied algorithm, a custom salt, and the number
of iterations.
Digital signatures
To establish the authenticity of data, there are different
signature algorithms with different strengths and weaknesses.
Common to all schemes are:
- a key pair is generated
by the originator. The pair consists of
a private key and an
associated public key.
- data is signed with
the private key. This means
that a signature is generated by performing a
computation that involves the data and the private key.
- The signature can be verified by performing a
computation that involves the data and the public key.
An essential property of a signature algorithm is that,
realistically, only someone who is in possession of
the private key can generate a
signature that matches the data in such a way that it is
verifiable with the corresponding public key.
As the names suggest, the public key can be freely shared with
everyone, while the private key
must be kept absolutely secret.
library(crypto) provides Ed25519, which is a specific
instance of a digital signature scheme based on twisted Edwards
curves. Ed25519 is an algorithm with very desirable cryptographic
properties, and easy to use securely.
For example, we can easily create a new, cryptographically strong
random key pair
using ed25519_new_keypair/1:
?- ed25519_new_keypair(Pair).
Pair = "[redacted]".
The pair is represented as a string
that also includes
the private key and must
therefore be kept absolutely secret. We can relate
the pair to its
public key component
with ed25519_keypair_public_key/2. In my case, I obtained
as public key a Prolog string whose Base64 encoding
is "D/dkIG7mp6a0kbUeqjzxAitTIMthnKo+W6BCCMyGWyg=".
I now sign the message "Hello!" using ed25519_sign/4:
ed25519_sign(Pair, "Hello!", Signature, [])
where Pair is
the key pair from above which
only I know. You will never get to see
the pair's private component, and
there is no realistic way for you to compute it even if I tell you
the associated public key (see above) and
the signature that was computed,
namely "480895ab0202dd9de5e967b4ea9f12757efdfb81043dbbb8d7edf065f24ff01def8095f93bda78db91f8a34a4eff814f7dbe55ee974c92f232b74563536c3f09".
However, if you trust that I kept
the private key absolutely
secret, and you are certain that you have the
correct public key that is associated with
my private key, then you can
use ed25519_verify/4 to authenticate the
string "Hello!", which is to say, to establish beyond all
reasonable doubt that it is I who signed it:
?- PublicKeyB64 = "D/dkIG7mp6a0kbUeqjzxAitTIMthnKo+W6BCCMyGWyg=",
Message = "Hello!",
Signature = "480895ab0202dd9de5e967b4ea9f12757efdfb81043dbbb8d7edf065f24ff01def8095f93bda78db91f8a34a4eff814f7dbe55ee974c92f232b74563536c3f09",
chars_base64(PublicKey, PublicKeyB64, []),
ed25519_verify(PublicKey, Message, Signature, []).
Since this succeeds, the signature is valid.
Symmetric encryption
We now come to the topic you are probably most interested
in: symmetric encryption. This means
that the same key is used for encrypting and
decrypting the data. For example, an important use case
is encrypting files with a password, so
that the same password can be used to decrypt them.
Scryer Prolog makes it extremely easy to encrypt arbitrary data
in a secure way, using the predicate
crypto_data_encrypt/6.
In addition to the data you want to encrypt, you must provide:
- the algorithm you want to use
- the key that is used for encryption
- the initialization vector (IV).
We now consider each of these parameters.
An example of a symmetric encryption algorithm is
AES,
which is a subset of the Rijndael cipher developed by
Vincent Rijmen and Joan Daemen. AES is the only publicly
accessible cipher that the NSA has approved
for top secret information. AES is
a block cipher and can be used in several modes
that guarantee different properties.
Ideally, key and IV are randomly chosen, with
each key and IV being equally likely. Reusing the same
combination of key and IV typically leaks at least
some information about the plaintext. For example,
identical plaintexts will then correspond to identical
ciphertexts. For some algorithms, reusing an IV with the same key
has disastrous results and can cause the loss of all
properties that are otherwise guaranteed. Especially in such
cases, an IV is also called a nonce. This is short for
"number used once" and emphasizes that for a fixed key,
an IV must be used at most once.
We can specify keys and IVs as lists of bytes. We can use
crypto_n_random_bytes/2 to
generate cryptographically strong pseudo-random bytes.
With extremely high likelihood, each invocation will generate a
completely different key and nonce.
The key must be kept
absolutely secret to retain the
confidentiality of the encrypted text. In contrast, the IV
can be safely stored and transmitted in plain text.
Authenticated encryption
As long as the key and IV are chosen (sufficiently) randomly, AES
in CBC mode ensures confidentiality of the
plain text. However, the cipher falls critically short in
other respects: It does not guarantee integrity and
therefore also not authenticity of the ciphertext. This
means that an attacker can change the ciphertext during
transmission or on a storage device, and we will not
notice the change if we only rely on this cipher. This can
cause highly dramatic consequences. For example, suppose the
plaintext is "Send you a kiss!", and malicious
modifications of the ciphertext yield a deviating decrypted text
that reads "Send him a kiss!".
There are several ways to solve this. We start—and
end—with the
best way to do it: Use a cipher that, in addition to
confidentiality of the plaintext, also ensures integrity
and authenticity of the ciphertext.
To illustrate the idea, we now use a powerful and efficient
algorithm denoted by the atom 'chacha20-poly1305': It is
the ChaCha20
stream cipher that was introduced by
Daniel J. Bernstein, coupled with
the Poly1305 authenticator
that was also introduced by Daniel J. Bernstein.
This cipher uses a 256-bit key and a 96-bit nonce,
i.e., 32 and 12 bytes,
respectively. Authenticated ciphers work by computing a tag
that is obtained upon encryption, and must be supplied
for decryption. The tag is obtained and supplied via
the tag/1 option in both cases.
For example, here is a concrete encryption with ChaCha20-Poly1305,
using a random key and nonce:
?- crypto_n_random_bytes(32, Ks),
crypto_n_random_bytes(12, IV),
crypto_data_encrypt("test", 'chacha20-poly1305', Ks, IV, CipherText, [tag(Ts)]).
In response, we get the encrypted text, and a 128-bit tag which
is specified as a list of 16 bytes:
Ks = [84,148,85,236,235,183,51,68,144|...],
IV = [182,70,102,111,6,170,45,76,148|...],
CipherText = "Pç,õ",
Ts = [119,23,173,207,167,255,29,135,101|...].
Again, the key must be kept completely secret. In contrast,
the tag and nonce (IV) can be safely stored and shared in
plain text.
Decryption only works if the correct tag is supplied. For
example:
?- crypto_data_decrypt($CipherText, 'chacha20-poly1305', $Ks, $IV, PlainText, [tag($Ts)]).
PlainText = "test",
CipherText = "Pç,õ",
Ks = [84,148,85,236,235,183,51,68,144|...],
IV = [182,70,102,111,6,170,45,76,148|...],
Ts = [119,23,173,207,167,255,29,135,101|...].
In contrast, even if we only slightly shorten, extend or
modify the ciphertext, nonce, or the required tag in any way, the
decryption fails.
Thus, an attacker who changes the ciphertext must also make
a fitting change in the tag for the change to go
unnoticed. However, without knowing the secret key, such a change is
extremely improbable.
Prolog is well-suited for studying how such algorithms work by
prototyping their implementations. For example, here is a Prolog
implementation of the Poly1305
authenticator: poly1305aes.pl.
And here is the ChaCha20
core: chacha20.pl.
Before we continue, a few test runs are highly appropriate. For
example, let us see whether we can decrypt the ciphertext
if we supply the same algorithm, key and IV to
crypto_data_decrypt/6. In addition, let us try
this not only once, but over and over, with a
freshly generated key and IV in each run:
?- repeat,
PlainText = "test",
Algorithm = 'chacha20-poly1305',
crypto_n_random_bytes(32, Ks),
crypto_n_random_bytes(12, IV),
portray_clause(verifying),
crypto_data_encrypt(PlainText, Algorithm, Ks, IV, CipherText, [tag(Ts)]),
crypto_data_decrypt(CipherText, Algorithm, Ks, IV, PlainText, [tag(Ts)]),
portray_clause(ok),
false.
As result, we get:
verifying.
ok.
verifying.
ok.
verifying.
ok.
etc.
After a few hundred thousand iterations of this, we can be
reasonably confident that what is encrypted can also be decrypted.
When experimenting with different algorithms, it is a common error
to specify keys or IVs that are shorter than what the chosen
algorithm requires, and such test cases help us to detect these
mistakes.
Deriving keys and initialization vectors
In most actual applications, it is not enough to generate a
random key. Instead, we typically must find a way
to derive a key and IV from other information,
which is called input keying material (IKM).
For example, in
the Diffie-Hellman-Merkle
key exchange, we first negotiate
a shared secret with another participant, and then
must derive a suitable key from that secret. Examples of such
secrets are integers, and points on an elliptic curve.
There is a standard algorithm that lets us derive keys and IVs
from arbitrary input data. It is called HKDF (HMAC-based
key derivation function), and it is described
in RFC 5869. In
Scryer Prolog, it is available
as crypto_data_hkdf/4.
For example, let us now derive a key and an IV from
a password in such a way that entering the same password
always yields the same key and IV.
Using HKDF, we could of course derive a key directly
from a given password. However, consider what we said
about storing passwords: First,
attackers that try to guess the password should be slowed
down. Second, using a password should not leak any information
even if the same password is also used elsewhere.
Therefore, instead of password
→ key, we will do:
password and salt
→ intentionally slow hash
→ key.
Thus, we will now combine password-based hash derivation
with HMAC-based key derivation,
using crypto_password_hash/3
and then crypto_data_hkdf/4.
To ensure that the same key is generated also when the same
password is entered later, we must fix all parameters
of crypto_password_hash/3. For example, recall that by
default, a random salt is used. Now, we will supply our
own salt, and store it for later reference. We can easily
generate a salt with crypto_n_random_bytes/2. For
example, let us use a 128-bit salt (16 bytes). In
addition, let us explicitly supply the algorithm we want to use
('pbkdf2-sha512', which is currently the only supported
option in any case) and also the number of iterations. For
example, let us use 219 iterations.
From the generated hash, we can easily derive a
key and an IV: The info/1 option
of crypto_data_hkdf/4 can be used to derive several
different keys and IVs from the same IKM. We also fix
the algorithm that is used by crypto_data_hkdf/4.
Taking all these considerations into account, we obtain for
example the following predicate to derive a 128-bit (i.e.,
16 bytes) key and IV from a given password and salt:
password_salt_key_iv(Password, Salt, Ks, IV) :-
crypto_password_hash(Password, Hash, [algorithm('pbkdf2-sha512'),
cost(19),
salt(Salt)]),
crypto_data_hkdf(Hash, 16, Ks, [info("key"),algorithm(sha256)]),
crypto_data_hkdf(Hash, 16, IV, [info("iv"),algorithm(sha256)]).
Sample usage, with a fresh 128-bit salt:
?- crypto_n_random_bytes(16, Salt),
password_salt_key_iv("test", Salt, Ks, IV).
This yields:
Salt = [203,81,172,46,86,244,37,2,215|...],
Ks = [38,141,86,95,83,22,243,31,38|...],
IV = [36,149,175,179,48,192,213,175,71|...].
When we later use the same password and salt, exactly the same
results are derived.
Thus, we only need to store the salt that was used, and can
later (again) use HKDF to derive all required values when the
password is entered. It is safe to store the salt in plain text,
since it has no discernible or realistically computable relation
with the derived values, as long as the password is kept
completely secret.
A shared secret can be established over an insecure channel via
elliptic-curve Diffie–Hellman (ECDH), using the elliptic
curve functionality of library(crypto). Curve25519 is
particularly well suited for this: In library(crypto),
points on Curve25519 are represented as lists of characters
that denote the u-coordinate of the Montgomery curve. There
are two predicates that let us implement X25519, a secure key
exchange algorithm using Curve25519:
- curve25519_generator(-Gs)
Gs is the generator point of Curve25519.
- curve25519_scalar_mult(+Scalar, +Ps, -Rs)
Scalar must be an integer between 0 and
2256-1, or a list of 32 bytes,
and Ps must be a point on the curve. Computes the
point Rs = Scalar·Ps as mandated by X25519.
Alice and Bob can establish a shared secret over an insecure
channel as follows, where Gs is the generator point of
Curve25519:
-
Alice creates a random integer a, computes As =
a·Gs, and sends As to Bob. Instead of an
integer a, Alice can
use crypto_n_random_bytes/2 to generate 32
random bytes.
-
Bob creates a random integer b, computes Bs =
b·Gs, and sends Bs to Alice. Bob can also
use crypto_n_random_bytes/2 to
generate b.
-
Alice computes Rs = a·Bs.
-
Bob computes Rs = b·As.
-
Alice and Bob use crypto_data_hkdf/4 on Rs
with suitable (same) parameters to obtain lists of bytes that
can be used as keys and initialization vectors for symmetric
encryption.
If a and b are kept secret, this method is
considered very secure.
Sometimes, keys are themselves derived from keys. For example, you
may have a master key, and derive further keys from
it, such as one key per file you want to encrypt. In such cases,
you can for example specify a file name in
the info/1 option
of crypto_data_hkdf/4. Even if an attacker finds out one
of these keys, the master key remains safe. As another example,
you could prove the authenticity of the cipher text by
deriving a further key that you use to compute
an HMAC
over the encrypted data and the IV. However, although this
construction does not leak the primary key even if the derived key
is broken, it is less error-prone and therefore safer to use a
cipher with built-in support for
authenticated encryption
for such use cases.
Further reading
We have barely scratched the surface of what you can and should do
with Prolog in the context of cryptography. For example,
An
Efficient Cryptographic Protocol Verifier Based on Prolog
Rules by Bruno Blanchet outlines how you can use Prolog to
verify properties of a cryptographic protocol.
In many cases, you can benefit from cryptographic features even
without knowing how they work internally. For example, if you
simply want to enable encrypted traffic for your web applications,
see LetSWICrypt to set up an
HTTPS server with SWI-Prolog.
In other cases, you can use the available functionality to
implement specific applications on your own. For example, you can
use Prolog to reason about Bitcoin addresses.
See Bitcoinolog for more
information. You can use the above methods to encrypt your
Bitcoin wallets and other sensitive data:
Use Enscryerypt to encrypt and
decrypt files.
The cryptographic functionality of Scryer Prolog is subject to
continuous improvements. If you are interested in specific
features, file an issue with the project, or contribute a patch!
More about Prolog
Main page


UK PM Johnson says UK will leave EU by Jan 31 at the latest
by ReutersLONDON (Nov 29): British Prime Minister Boris Johnson said on Friday that Britain would leave the European Union by Jan 31 at the latest if his Conservative Party win a majority in the election in two weeks time.
"If we can get a working majority then we will come on Jan 31 at the absolute latest," Johnson told LBC radio.
He also repeated his message that he saw no reason why Britain would need to extend the transition period after Brexit beyond the end of 2020.
Asked if he would rather be prime minister or have Britain leave the EU, he replied: "I would rather get us out of the EU. I can tell you that."


| Home | Trees | Indices | Help |
|---|
|
|
Provides an interface between cocosCairo and PyGTK.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
Initialization method.
|
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Fri Apr 9 14:54:58 2010 | http://epydoc.sourceforge.net |


In a local editor, open the project's skyuxconfig.json file in the root directory.
Insert the appSettings property and specify the data to reuse throughout the application. For example:
"appSettings": {
"exampleSetting2": "barfoo"
}
Open the component or service files where you want to reference the appSettings value.
In the component.ts file for the component or the service.ts file for the service, import SkyAppConfig from @blackbaud/skyux-builder/runtime:
import { SkyAppConfig } from '@blackbaud/skyux-builder/runtime';
Add SkyAppConfig as a private property in the constructor for the component or service: constructor(private skyAppConfig: SkyAppConfig) {}.
import { Component } from '@angular/core';
import { SkyAppConfig } from '@blackbaud/skyux-builder/runtime';
@Component({
selector: 'my-home',
templateUrl: './home.component.html'
})
export class HomeComponent {
constructor(private skyAppConfig: SkyAppConfig) {}
}
In the template file for the component or service, pull in the config service and reference the appSettings value to access it in the .html file. For example:

Sample text: {{ skyAppConfig.skyux.appSettings.exampleSetting2 }}

Save your changes. The appSettings value is now available to the component or service.


In the previous section we looked at several ways to create and access named templates. This makes it easy to import one template from within another template. But sometimes it is desirable to import a file that is not a template and inject its contents without sending the contents through the template renderer.
Helm provides access to files through the .Files
object. Before we get going with the template examples, though, there are a few things to note about how this works:
.Files
object, usually for security reasons.
templates/
cannot be accessed..helmignore
cannot be accessed..Files
object.With those caveats behind, let’s write a template that reads three files into our ConfigMap. To get started, we will add three files to the chart, putting all three directly inside of the mychart/
directory.
config1.toml
:
message = Hello from config 1
config2.toml
:
message = This is config 2
config3.toml
:
message = Goodbye from config 3
Each of these is a simple TOML file (think old-school Windows INI files). We know the names of these files, so we can use a range
function to loop through them and inject their contents into our ConfigMap.
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-configmap
data:
{{- $files := .Files }}
{{- range tuple "config1.toml" "config2.toml" "config3.toml" }}
{{ . }}: |-
{{ $files.Get . }}
{{- end }}
This config map uses several of the techniques discussed in previous sections. For example, we create a $files
variable to hold a reference to the .Files
object. We also use the tuple
function to create a list of files that we loop through. Then we print each file name ({{.}}: |-
) followed by the contents of the file {{ $files.Get . }}
.
Running this template will produce a single ConfigMap with the contents of all three files:
# Source: mychart/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: quieting-giraf-configmap
data:
config1.toml: |-
message = Hello from config 1
config2.toml: |-
message = This is config 2
config3.toml: |-
message = Goodbye from config 3
When working with files, it can be very useful to perform some standard operations on the file paths themselves. To help with this, Helm imports many of the functions from Go’s path package for your use. They are all accessible with the same names as in the Go package, but with a lowercase first letter. For example, Base
becomes base
, etc.
The imported functions are: - Base - Dir - Ext - IsAbs - Clean
As your chart grows, you may find you have a greater need to organize your files more, and so we provide a Files.Glob(pattern string)
method to assist in extracting certain files with all the flexibility of glob patterns.
.Glob
returns a Files
type, so you may call any of the Files
methods on the returned object.
For example, imagine the directory structure:
foo/:
foo.txt foo.yaml
bar/:
bar.go bar.conf baz.yaml
You have multiple options with Globs:
{{ $root := . }}
{{ range $path, $bytes := .Files.Glob "**.yaml" }}
{{ $path }}: |-
{{ $root.Files.Get $path }}
{{ end }}
Or
{{ range $path, $bytes := .Files.Glob "foo/*" }}
{{ base $path }}: '{{ $root.Files.Get $path | b64enc }}'
{{ end }}
(Not present in version 2.0.2 or prior)
It is very common to want to place file content into both configmaps and secrets, for mounting into your pods at run time. To help with this, we provide a couple utility methods on the Files
type.
For further organization, it is especially useful to use these methods in conjunction with the Glob
method.
Given the directory structure from the Glob example above:
apiVersion: v1
kind: ConfigMap
metadata:
name: conf
data:
{{ (.Files.Glob "foo/*").AsConfig | indent 2 }}
---
apiVersion: v1
kind: Secret
metadata:
name: very-secret
type: Opaque
data:
{{ (.Files.Glob "bar/*").AsSecrets | indent 2 }}
You can import a file and have the template base-64 encode it to ensure successful transmission:
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-secret
type: Opaque
data:
token: |-
{{ .Files.Get "config1.toml" | b64enc }}
The above will take the same config1.toml
file we used before and encode it:
# Source: mychart/templates/secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: lucky-turkey-secret
type: Opaque
data:
token: |-
bWVzc2FnZSA9IEhlbGxvIGZyb20gY29uZmlnIDEK
Sometimes it is desirable to access each line of a file in your template. We provide a convenient Lines
method for this.
Currently, there is no way to pass files external to the chart during helm install
. So if you are asking users to supply data, it must be loaded using helm install -f
or helm install --set
.
This discussion wraps up our dive into the tools and techniques for writing Helm templates. In the next section we will see how you can use one special file, templates/NOTES.txt
, to send post-installation instructions to the users of your chart.