Tutorial by Examples

The example below uses the input statement to read a value from a source (in this case the string 123) into a both a character destination and a numeric destination. data test; source = '123'; numeric_destination = input(source, best.); character_destination = input(source, $3.); run; ...
Magics whose name begins with just one % take as argument the rest of the line and are called line magics. Magics that begin with a double percent sign %% take a multi-line argument and are called cell magics. A commonly used magic is %timeit, a wrapper around the Python's timeit.timeit function, f...
Crontab contains cron jobs, each related to a specific task. Cron jobs are composed of two parts, the cron expression, and a shell command to be run: * * * * * command/to/run Each field in the above expression * * * * * is an option for setting the schedule frequency. It is composed of minute,...
We have a Student table with SubjectId. Here the requirement is to concatenate based on subjectId. All SQL Server versions create table #yourstudent (subjectid int, studentname varchar(10)) insert into #yourstudent (subjectid, studentname) values ( 1 ,'Mary' ) ,( 1 ,'John' ...
In case of SQL Server 2017 or vnext we can use in-built STRING_AGG for this aggregation. For same student table, create table #yourstudent (subjectid int, studentname varchar(10)) insert into #yourstudent (subjectid, studentname) values ( 1 ,'Mary' ) ,( 1 ,'John' ) ,( 1 ...
import scalaz._ import Scalaz._ scala> Apply[Option].apply2(some(1), some(2))((a, b) => a + b) res0: Option[Int] = Some(3) scala> val intToString: Int => String = _.toString scala> Apply[Option].ap(1.some)(some(intToString)) res1: Option[String] = Some(1) scala> Appl...
import scalaz._ import Scalaz._ scala> val len: String => Int = _.length len: String => Int = $$Lambda$1164/969820333@7e758f40 scala> Functor[Option].map(Some("foo"))(len) res0: Option[Int] = Some(3) scala> Functor[Option].map(None)(len) res1: Option[Int] = None ...
import scalaz._ import Scalaz._ scala> val plus1 = (_: Int) + 1 plus1: Int => Int = $$Lambda$1167/1113119649@6a6bfd97 scala> val plus2 = (_: Int) + 2 plus2: Int => Int = $$Lambda$1168/924329548@6bbe050f scala> val rev = (_: String).reverse rev: String => String = $$Lambd...
Having different pipes is a very common case, where each pipe does a different thing. Adding each pipe to each component may become a repetitive code. It is possible to bundle all frequently used pipes in one Module and import that new module in any component needs the pipes. breaklines.ts import...
Unary operators act on the object upon which they are called and have high precedence. (See Remarks) When used postfix, the action occurs only after the entire operation is evaluated, leading to some interesting arithmetics: int a = 1; ++a; // result: 2 a--; // result: 1 i...
A common need for random numbers it to generate a number that is X% of some max value. this can be done by treating the result of NextDouble() as a percentage: var rnd = new Random(); var maxValue = 5000; var percentage = rnd.NextDouble(); var result = maxValue * percentage; //suppose NextDoub...
apcu_store can be used to store, apcu_fetch to retrieve values: $key = 'Hello'; $value = 'World'; apcu_store($key, $value); print(apcu_fetch('Hello')); // 'World'
apcu_cache_info provides information about the store and its entries: print_r(apcu_cache_info()); Note that invoking apcu_cache_info() without limit will return the complete data currently stored. To only get the meta data, use apcu_cache_info(true). To get information about certain cache ...
The APCUIterator allows to iterate over entries in the cache: foreach (new APCUIterator() as $entry) { print_r($entry); } The iterator can be initialized with an optional regular expression to select only entries with matching keys: foreach (new APCUIterator($regex) as $entry) { pr...
When creating a std::unique_lock, there are three different locking strategies to choose from: std::try_to_lock, std::defer_lock and std::adopt_lock std::try_to_lock allows for trying a lock without blocking: { std::atomic_int temp {0}; std::mutex _mutex; std::thread t( [&...
/** * Set a custom add to cart URL to redirect to * @return string */ function custom_add_to_cart_redirect() { return 'http://www.yourdomain.com/your-page/'; } add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' );
std::mutex is a simple, non-recursive synchronization structure that is used to protect data which is accessed by multiple threads. std::atomic_int temp{0}; std::mutex _mutex; std::thread t( [&](){ while( temp!= -1){ ...
Recursive mutex allows the same thread to recursively lock a resource - up to an unspecified limit. There are very few real-word justifications for this. Certain complex implementations might need to call an overloaded copy of a function without releasing the lock. std::atomic_int temp{0}; ...
std::scoped_lock provides RAII style semantics for owning one more mutexes, combined with the lock avoidance algorithms used by std::lock. When std::scoped_lock is destroyed, mutexes are released in the reverse order from which they where acquired. { std::scoped_lock lock{_mutex1,_mutex2}; ...
Compress-Archive -Path C:\Documents\* -CompressionLevel Optimal -DestinationPath C:\Archives\Documents.zip This command: Compresses all files in C:\Documents Uses Optimal compression Save the resulting archive in C:\Archives\Documents.zip -DestinationPath will add .zipif not present. -Li...

Page 1241 of 1336