This lists the root folder, which is identified by the empty string "" for Dropbox API v2, using curl, using /files/list_folder:
curl -X POST https://api.dropboxapi.com/2/files/list_folder \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--header "Content...
Dropbox.authorizedClient!.files.listFolder(path: "").response { response, error in
print("*** List folder ***")
if let result = response {
print("Folder contents:")
for entry in result.entries {
print(entry.name)
if ...
// List folder
Dropbox.authorizedClient!.files.listFolder(path: "/nonexistantpath").response { response, error in
print("*** List folder ***")
if let result = response {
print("Folder contents:")
for entry in result.entries {
pr...
Dropbox.authorizedClient!.files.getMetadata(path: "/test.jpg", includeMediaInfo: true).response { response, error in
if let result = response as? Files.FileMetadata {
print(result.name)
if result.mediaInfo != nil {
switch result.mediaInfo! as Files.Med...
This uses the Dropbox Python SDK to create a shared link for a folder:
import dropbox
dbx = dropbox.Dropbox("<ACCESS_TOKEN>")
shared_link_metadata = dbx.sharing_create_shared_link_with_settings("/Testing")
print shared_link_metadata.url
<ACCESS_TOKEN> should be...
Dropbox.authorizedClient!.sharing.createSharedLink(path: "/test.txt").response({ response, error in
if let link = response {
print(link.url)
} else {
print(error!)
}
})
A rebase switches the meaning of "ours" and "theirs":
git checkout topic
git rebase master # rebase topic branch on top of master branch
Whatever HEAD's pointing to is "ours"
The first thing a rebase does is resetting the HEAD to master; before cherry-picking...
We can make an AJAX request to Stack Exchange's API to retrieve a list of the top JavaScript questions for the month, then present them as a list of links. If the request fails or the returns an API error, our promise error handling displays the error instead.
6
View live results on HyperWeb.
c...
cat file.txt
will print the contents of a file.
If the file contains non-ASCII characters, you can display those characters symbolically with cat -v. This can be quite useful for situations where control characters would otherwise be invisible.
cat -v unicode.txt
Very often, for interactive ...
man <command>
This will show the manual page for the specified command.
For example, man ping will show:
PING(8) BSD System Manager's Manual PING(8)
NAME
ping -- send ICMP ECHO_REQUEST packets to network hosts
SYNOPSIS
ping [-AaCDdfno...
The !important declaration is used to override the usual specificity in a style sheet by giving a higher priority to a rule. Its usage is: property : value !important;
#mydiv {
font-weight: bold !important; /* This property won't be overridden
by the ...
Data Manipulation Language (DML for short) includes operations such as INSERT, UPDATE and DELETE:
-- Create a table HelloWorld
CREATE TABLE HelloWorld (
Id INT IDENTITY,
Description VARCHAR(1000)
)
-- DML Operation INSERT, inserting a row into the table
INSERT INTO HelloWorld (D...
do './config.pl';
This will read in the contents of the config.pl file and execute it. (See also: perldoc -f do.)
N.B.: Avoid do unless golfing or something as there is no error checking. For including library modules, use require or use.
If you need to use the ^ character in a character class (Character classes ), either put it somewhere other than the beginning of the class:
[12^3]
Or escape the ^ using a backslash \:
[\^123]
If you want to match the caret character itself outside a character class, you need to escape it:
...
func doSomething1(value: Double) { /* ... */ }
func doSomething2(value: UInt) { /* ... */ }
let x = 42 // x is an Int
doSomething1(Double(x)) // convert x to a Double
doSomething2(UInt(x)) // convert x to a UInt
Integer initializers produce a runtime error if the value ove...
Counting the keys of a Mapping isn't possible with collections.Counter but we can count the values:
from collections import Counter
adict = {'a': 5, 'b': 3, 'c': 5, 'd': 2, 'e':2, 'q': 5}
Counter(adict.values())
# Out: Counter({2: 2, 3: 1, 5: 3})
The most common elements are avaiable by the m...