Windows uses only double quotes to wrap command line parameters. In order to use double quotes in perl one-liner (i.e. to print a string with an interpolated variable), you have to escape them with backslashes:
perl -e "my $greeting = 'Hello'; print \"$greeting, world!\n\""
T...
genRandom creates a stream of random numbers that has a one in four chance of terminating each time it's called.
def genRandom: Stream[String] = {
val random = scala.util.Random.nextFloat()
println(s"Random value is: $random")
if (random < 0.25) {
Stream.empty[String]
...
Let's say there's a collection called Todos and the autopublish package is added. Here is the basic component.
import { createContainer } from 'meteor/react-meteor-data';
import React, { Component, PropTypes } from 'react';
import Todos from '/imports/collections/Todos';
export class List exte...
They're not easily accessible. If you run the 'meteor bundle' command, you can generate a tar.gz file, and then run your app manually. Doing that, you should be able to access the mongo logs... probably in the .meteor/db directory.
If you really need to access mongodb log files, set up a regular mo...
db.posts.find().forEach(function(doc){
if(doc.arrayOfObjects){
// the false, true at the end refers to $upsert, and $multi, respectively
db.accounts.update({_id: doc._id}, {$unset: {'arrayOfObjects': "" }}, false, true);
}
});
Backbone.js is made up of four separate components: Collections, Models, Routers, and Views. Each of these serve different purposes:
Model - represents a single data object, but adds additional functionalities not provided by native JavaScript objects, such as an event system and a more conveni...
Using Dynamic Arrays in VBA can be quite clunky and time intensive over very large data sets. When storing simple data types in a dynamic array (Strings, Numbers, Booleans etc.), one can avoid the ReDim Preserve statements required of dynamic arrays in VBA by using the Split() function with some cl...
If you want to add all the JARs in directory to the classpath, you can do this concisely using classpath wildcard syntax; for example:
someFolder/*
This tells the JVM to add all JAR and ZIP files in the someFolder directory to the classpath. This syntax can be used in a -cp argument, a CLASSPA...
The following might have undefined behavior due to incorrect pointer alignment:
char *memory_block = calloc(sizeof(uint32_t) + 1, 1);
uint32_t *intptr = (uint32_t*)(memory_block + 1); /* possible undefined behavior */
uint32_t mvalue = *intptr;
The undefined behavior happens as the pointer...
While there are many different control sequences for io:format and io_lib:format, most of the time you'll use only three different ones: ~s, ~p and ~w.
~s
The ~s is for strings.
It prints strings, binaries and atoms. (Anything else will cause a badarg error.) It doesn't quote or escape anything...
for /r command can be used to recursively visit all the directories in a directory tree and perform a command.
@echo off
rem start at the top of the tree to visit and loop though each directory
for /r %%a in (.) do (
rem enter the directory
pushd %%a
echo In directory:
cd
rem leave...
If you are inside a folder of a git repository it might be nice to show the current branch you are on. In ~/.bashrc or /etc/bashrc add the following (git is required for this to work):
function prompt_command {
# Check if we are inside a git repository
if git status > /dev/null 2>&a...
If you know the format of the string you are converting (parsing) you should use DateTime.ParseExact
Dim dateString As String = "12.07.2003"
Dim dateFormat As String = "dd.MM.yyyy"
Dim dateValue As Date
dateValue = DateTime.ParseExact(dateString, dateFormat, Globalization.C...
The following uses a variable with a for loop to rename a group of files.
SetLocal EnableDelayedExpansion
for %%j in (*.*) do (
set filename=%%~nj
set filename=!filename:old=new!
set filename=Prefix !filename!
set filename=!filename! Suffix
ren "%%j" "!filename!%%~x...
CSS
div {
width: 200px;
height: 200px;
background: url(http://lorempixel.com/200/200/abstract/6);
mask-image: radial-gradient(circle farthest-side at center, transparent 49%, white 50%); /* check remarks before using */
}
HTML
In the above example, a transparent circle is created...