1666941420
The Goods
Introducing datapasta
datapasta
is about reducing resistance associated with copying and pasting data to and from R. It is a response to the realisation that I often found myself using intermediate programs like Sublime to munge text into suitable formats. Addins and functions in datapasta
support a wide variety of input and output situations, so it (probably) "just works". Hopefully tools in this package will remove such intermediate steps and associated frustrations from our data slinging workflows.
Prerequisites
xsel
or xclip
. These applications provide an interface to X selections (clipboard-like).sudo apt-get install xsel
- it's 72kb...Installation
install with R universe repo:
install.packages(
"datapasta",
repos = c(mm = "https://milesmcbain.r-universe.dev", getOption("repos")))
Set the keyboard shortcuts using Tools -> Addins -> Browse Addins, then click Keyboard Shortcuts...
For now, no further versions of datapasta
will be going to CRAN. There are some known bugs in the CRAN version that have been fixed in 3.1.1
.
install.packages("datapasta")
Usage
At the moment this package contains these RStudio addins that paste data to the cursor:
tribble_paste
which pastes a table as a nicely formatted call to tibble::tribble()
vector_paste
which will paste delimited data as a vector definition, e.g. c("a", "b")
etc.vector_paste_vertical
which will paste delimited data as a vertically formatted vector definition.c("Mint",
"Fedora",
"Debian",
"Ubuntu",
"OpenSUSE")
df_paste
which pastes a table on the clipboard as a standard data.frame
definition rather than a tribble
call. This has certain advantages in the context of reproducible examples and educational posts. Many thanks to Jonathan Carroll for getting this rolling and coding the bulk of the feature.dt_paste
which is the same as df_paste
, but for data.table
.There are two Addins that can help with creating and aligning data in your editor:
Fiddle Selection
will perform magic on a selection. It can be used to:
c()
expressionc()
expr between horizontal and vertical layout.tribble()
and data.frame()
exprs.Toggle Vector Quotes
will toggle a c()
expr between all elements wrapped in ""
and all bare unquoted form. Handy in combination with above to save mucho keystrokes.
There are two R functions available that accept R objects and output formatted text for pasting to a reprex or other application:
dpasta
accepts tibbles, data.frames, and vectors. Data is output in a format that matches in input class. Formatted text is pasted at the cursor.
dmdclip
accepts the same inputs as dpasta
but inserts the formatted text onto the clipboard, preceded by 4 spaces so that is can be as pasted as a preformatted block to Github, Stackoverflow etc.
The only hard dependency of datapasta
is readr
for type guessing. All the above *paste
functions can be called directly instead of as an addin, and will fall back to console output if the rstudioapi
is not available.
On system without access to the clipboard (or without clipr
installed) datapasta
can still be used to output R objects from an R session. dpasta
is probably the only function you care about in this scenario.
datapasta
imports clipr
and rstudioapi
so as to make installation smooth and easy for most users. If you wish to avoid installing an rstudioapi
you will never use you can use:
install.packages("datapasta", dependencies = "Depends")
.install.packages("clipr")
to enable clipboard features.Pitfalls
tribble_paste
works well with CSVs, excel files, and html tables, but is currently brittle with respect to irregular table structures like merged cells or multi-line column headings. For some reason Wikipedia seems chock full of these. :(tribble_paste()
/dpasta()
. Nested lists of length 1 fail unless all are length 1 - It's complicated. You still get some output so it might be viable to fix and reflow with Fiddle Selection
. Tread with caution.Prior art
This package is made possible by mdlincon's clipr, and Hadley's packages tibble and readr (for data-type guessing). I especially appreciate clipr's
thoughtful approach to the clipboard on Linux, which pretty much every other R clipboard package just nope'd out on.
Future developments
I am interested in expanding the types of objects supported by the output functions dpasta
. I would also like to eventually have Fiddle Selection
to pivot function calls and named vectors. Feel free to contribute your ideas to the open issues.
Bonus
0 to datapasta
in 64 seconds via a video vignette:
Author: MilesMcBain
Source Code: https://github.com/MilesMcBain/datapasta
License: View license
1665945660
Clipy is a Clipboard extension app for macOS.
Requirement: macOS 10.10 Yosemite or higher
Distribution Site : https://clipy-app.com
Clipy.xcworkspace
on Xcode.v1.1.2 is the final version of Mavericks support.
Download v1.1.2 release
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Clipy is looking for localization contributors.
If you can cooperate, please see CONTRIBUTING.md
If you distribute derived work, especially in the Mac App Store, I ask you to follow two rules:
Clipy
and ClipMenu
as your product name.Thank you for your cooperation.
Author: Clipy
Source Code: https://github.com/Clipy/Clipy
License: MIT license
1662532699
In today's post we will learn about 5 Best React Clipboard Libraries.
The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.
$ npm install --save ag-grid-community
<div id="myGrid" style="height: 150px; width: 600px" class="ag-theme-alpine"></div>
import { Grid } from 'ag-grid-community';
import 'ag-grid-community/styles//ag-grid.css';
import 'ag-grid-community/styles//ag-theme-alpine.css';
var gridOptions = {
columnDefs: [
{ headerName: 'Make', field: 'make' },
{ headerName: 'Model', field: 'model' },
{ headerName: 'Price', field: 'price' }
],
rowData: [
{ make: 'Toyota', model: 'Celica', price: 35000 },
{ make: 'Ford', model: 'Mondeo', price: 32000 },
{ make: 'Porsche', model: 'Boxster', price: 72000 }
]
};
var eGridDiv = document.querySelector('#myGrid');
new Grid(eGridDiv, this.gridOptions);
Copy-to-clipboard React component
npm install --save react-copy-to-clipboard
Don't forget to manually install peer dependencies (react
) if you use npm@3.
<script src="https://unpkg.com/react@16.0.0/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-copy-to-clipboard/build/react-copy-to-clipboard.js"></script>
(Module exposed as `CopyToClipboard`)
import React from 'react';
import ReactDOM from 'react-dom';
import {CopyToClipboard} from 'react-copy-to-clipboard';
class App extends React.Component {
state = {
value: '',
copied: false,
};
render() {
return (
<div>
<input value={this.state.value}
onChange={({target: {value}}) => this.setState({value, copied: false})} />
<CopyToClipboard text={this.state.value}
onCopy={() => this.setState({copied: true})}>
<span>Copy to clipboard with span</span>
</CopyToClipboard>
<CopyToClipboard text={this.state.value}
onCopy={() => this.setState({copied: true})}>
<button>Copy to clipboard with button</button>
</CopyToClipboard>
{this.state.copied ? <span style={{color: 'red'}}>Copied.</span> : null}
</div>
);
}
}
const appRoot = document.createElement('div');
document.body.appendChild(appRoot);
ReactDOM.render(<App />, appRoot);
React hook that provides copy to clipboard functionality.
You can install react-use-clipboard
with NPM or Yarn.
npm install react-use-clipboard
yarn add react-use-clipboard
Here's how to use react-use-clipboard
:
import useClipboard from "react-use-clipboard";
function App() {
const [isCopied, setCopied] = useClipboard("Text to copy");
return (
<button onClick={setCopied}>
Was it copied? {isCopied ? "Yes! 👍" : "Nope! 👎"}
</button>
);
}
You can reset the isCopied
value after a certain amount of time with the successDuration
option.
import useClipboard from "react-use-clipboard";
function App() {
const [isCopied, setCopied] = useClipboard("Text to copy", {
// `isCopied` will go back to `false` after 1000ms.
successDuration: 1000,
});
return (
<button onClick={setCopied}>
Was it copied? {isCopied ? "Yes! 👍" : "Nope! 👎"}
</button>
);
}
This package only works in versions of React that support Hooks.
Here you'll find all the core components you need to create a delightful webapp. Customizable design system from Welcome to the jungle (@WTTJ) with react, typescript, styled-components, reakit and a lot of love 💛
1 - Install the peer dependencies listed below:
yarn add @xstyled/styled-components react styled-components
2 - Install the the core component and any other components you need for your webapp e.g. if you need just a button…
yarn add @welcome-ui/core @welcome-ui/button
Getting started
import React from 'react'
import { createTheme, WuiProvider } from '@welcome-ui/core'
import { Button } from '@welcome-ui/button'
// Add theme options (if you want)
const options = {
defaultFontFamily: 'Helvetica',
headingFontFamily: 'Georgia',
colors: {
primary: {
500: '#124C80',
},
success: {
500: '#32CD32',
},
},
}
// Create your theme
const theme = createTheme(options)
export default function Root() {
return (
// Wrap your components with <WuiProvider /> with your theme
<WuiProvider
theme={theme}
// Will inject a CSS reset with normalizer
hasGlobalStyle
// Will show the focus ring on keyboard navigation only
shouldHideFocusRingOnClick
>
<Button>Welcome!</Button>
</WuiProvider>
)
}
A React hook for copying text to the clipboard
import useCopy from '@react-hook/copy'
const Component = (props) => {
const {copied, copy, reset} = useCopy(
'This text will be copied to the clipboard'
)
return <a onClick={copy}>{copied === false ? 'Copy' : 'Copied'}</a>
}
Thank you for following this article.
1661558160
clipboard.js is a super light javascript framework, which provides copy-to-clipboard functionality using HTML5. The simple rclipboard
R package is simple and leverages clipboard.js
functionality to provide a reactive copy-to-clipboard UI button component, called rclipButton
, and a reactive copy-to-clipboard UI link component, called rclipLink
, for Shiny R applications.
This example works when deployed on a Shiny server or when it is run from RStudio. However, because of limitations in the web engine of RStudio versions prior to 1.2, the rclipButton does not work natively when the application is run locally. A workaround must be implemented in the form of an observeEvent associated to the rclipButton and using the clipr function from the clipr package.
This workaround is not required if you run your applications in RStudio versions >= 1.2.
library(rclipboard)
library(shiny)
# The UI
ui <- bootstrapPage(
rclipboardSetup(),
# Add a text input
textInput("copytext", "Copy this:", "Zlika!"),
# UI ouputs for the copy-to-clipboard buttons
uiOutput("clip"),
# A text input for testing the clipboard content.
textInput("paste", "Paste here:")
)
# The server
server <- function(input, output) {
# Add clipboard buttons
output$clip <- renderUI({
output$clip <- renderUI({
rclipButton(
inputId = "clipbtn",
label = "rclipButton Copy",
clipText = input$copytext,
icon = icon("clipboard")
)
})
})
# Workaround for execution within RStudio version < 1.2
if (interactive()){
observeEvent(input$clipbtn, clipr::write_clip(input$copytext))
}
}
shinyApp(ui = ui, server = server)
Author: Sbihorel
Source Code: https://github.com/sbihorel/rclipboard
License: View license
1661095800
copydat
lets you copy a data.frame
to the clipboard using the ...
... RStudio GUI. Just highlight (in your source console) the name of the data.frame
you want to copy. (Examples: iris
; mtcars
). Click Addins > Copy data
, and you're done.
... R console. Like this: mtcars %>% Copy(dat2tsv) # or dat2rtf
. Paste away!
Supported formats:
It's a work in progress. TODO:
clipboard()
. Easy! :-Dcomment()
--> table caption?)Thanks to @Rstudio and @kevinushey for RStudio Addins and the great examples. And thanks to @schaffman5 for the rtf package!
if (!requireNamespace("devtools", quietly = TRUE))
install.packages("devtools")
devtools::install_github("BAAQMD/copydat")
Author: BAAQMD
Source Code: https://github.com/BAAQMD/copydat
1661076300
The Goods
Introducing datapasta
datapasta
is about reducing resistance associated with copying and pasting data to and from R. It is a response to the realisation that I often found myself using intermediate programs like Sublime to munge text into suitable formats. Addins and functions in datapasta
support a wide variety of input and output situations, so it (probably) "just works". Hopefully tools in this package will remove such intermediate steps and associated frustrations from our data slinging workflows.
Prerequisites
xsel
or xclip
. These applications provide an interface to X selections (clipboard-like).sudo apt-get install xsel
- it's 72kb...Installation
install.packages(
"datapasta",
repos = c(mm = "https://milesmcbain.r-universe.dev", getOption("repos")))
For now, no further versions of datapasta
will be going to CRAN. There are some known bugs in the CRAN version that have been fixed in 3.1.1
.
install.packages("datapasta")
Usage
At the moment this package contains these RStudio addins that paste data to the cursor:
tribble_paste
which pastes a table as a nicely formatted call to tibble::tribble()
vector_paste
which will paste delimited data as a vector definition, e.g. c("a", "b")
etc.vector_paste_vertical
which will paste delimited data as a vertically formatted vector definition.c("Mint",
"Fedora",
"Debian",
"Ubuntu",
"OpenSUSE")
df_paste
which pastes a table on the clipboard as a standard data.frame
definition rather than a tribble
call. This has certain advantages in the context of reproducible examples and educational posts. Many thanks to Jonathan Carroll for getting this rolling and coding the bulk of the feature.dt_paste
which is the same as df_paste
, but for data.table
.There are two Addins that can help with creating and aligning data in your editor:
Fiddle Selection
will perform magic on a selection. It can be used to:
c()
expressionc()
expr between horizontal and vertical layout.tribble()
and data.frame()
exprs.Toggle Vector Quotes
will toggle a c()
expr between all elements wrapped in ""
and all bare unquoted form. Handy in combination with above to save mucho keystrokes.
There are two R functions available that accept R objects and output formatted text for pasting to a reprex or other application:
dpasta
accepts tibbles, data.frames, and vectors. Data is output in a format that matches in input class. Formatted text is pasted at the cursor.
dmdclip
accepts the same inputs as dpasta
but inserts the formatted text onto the clipboard, preceded by 4 spaces so that is can be as pasted as a preformatted block to Github, Stackoverflow etc.
The only hard dependency of datapasta
is readr
for type guessing. All the above *paste
functions can be called directly instead of as an addin, and will fall back to console output if the rstudioapi
is not available.
On system without access to the clipboard (or without clipr
installed) datapasta
can still be used to output R objects from an R session. dpasta
is probably the only function you care about in this scenario.
datapasta
imports clipr
and rstudioapi
so as to make installation smooth and easy for most users. If you wish to avoid installing an rstudioapi
you will never use you can use:
install.packages("datapasta", dependencies = "Depends")
.install.packages("clipr")
to enable clipboard features.Pitfalls
tribble_paste
works well with CSVs, excel files, and html tables, but is currently brittle with respect to irregular table structures like merged cells or multi-line column headings. For some reason Wikipedia seems chock full of these. :(tribble_paste()
/dpasta()
. Nested lists of length 1 fail unless all are length 1 - It's complicated. You still get some output so it might be viable to fix and reflow with Fiddle Selection
. Tread with caution.Prior art
This package is made possible by mdlincon's clipr, and Hadley's packages tibble and readr (for data-type guessing). I especially appreciate clipr's
thoughtful approach to the clipboard on Linux, which pretty much every other R clipboard package just nope'd out on.
Future developments
I am interested in expanding the types of objects supported by the output functions dpasta
. I would also like to eventually have Fiddle Selection
to pivot function calls and named vectors. Feel free to contribute your ideas to the open issues.
Bonus
0 to datapasta
in 64 seconds via a video vignette:
Author: Milesmcbain
Source Code: https://github.com/milesmcbain/datapasta
License: View license
1661064300
Simple utility functions to read and write from the system clipboards of Windows, OS X, and Unix-like systems (which require either xclip or xsel.)
Install from CRAN
install.packages("clipr")
Or try the development version
remotes::install_github("mdlincoln/clipr")
clipr is pipe-friendly, and will default to returning the same object that was passed in.
library("clipr")
#> Welcome to clipr. See ?write_clip for advisories on writing to the clipboard in R.
res <- write_clip(c("Text", "for", "clipboard"))
res
#> [1] "Text" "for" "clipboard"
cb <- read_clip()
cb
#> [1] "Text" "for" "clipboard"
To capture the string that clipr writes to the clipboard, specify return_new = TRUE
. Character vectors with length > 1 will be collapsed with system-appropriate line breaks, unless otherwise specified
cb <- write_clip(c("Text", "for", "clipboard"), return_new = TRUE)
cb
#> [1] "Text\nfor\nclipboard"
cb <- write_clip(c("Text", "for", "clipboard"), breaks = ", ", return_new = TRUE)
cb
#> [1] "Text, for, clipboard"
write_clip
also tries to intelligently handle data.frames and matrices, rendering them with write.table
so that they can be pasted into a spreadsheet like Excel.
tbl <- data.frame(a = c(1, 2, 3), b = c(4, 5, 6))
cb <- write_clip(tbl, return_new = TRUE)
cb
#> [1] "a\tb\n1\t4\n2\t5\n3\t6"
read_clip_tbl
will try to parse clipboard contents from spreadsheets into data frames directly.
See the “Developing with clipr” vignette included with this package for advisories on writing code that calls clipr functions.
(a non-comprehensive list)
Author: mdlincoln
Source Code: https://github.com/mdlincoln/clipr
1661010300
RStudio Addin: Copy images from clipboard into RMarkdown .Rmd files.
devtools::install_github('Timag/imageclipr')
R packages library(rstudioapi)
, (library(rmarkdown)
for markdown files)
For linux xclip is required. For debian, ubuntu,... install it with:
sudo apt-get install xclip
-- copy and paste image and text together
-- copy and paste an image by copying the file in the explorer
(highlevel): https://stackoverflow.com/questions/55541345/copy-and-paste-an-image-from-clipboard-to-rmarkdown-rmd-code
Note: You will see "Paste Img to Rmd file" instead of "Insert Image".
In RStudio go to Tools - Modify Keyboard Shortcuts...
Note: You will see "Paste Img to Rmd file" instead of "Insert Image".
(This project is part of my life long application to RStudio :))
Author: Toniiiio
Source Code: https://github.com/Toniiiio/imageclipr
License: View license
1661006340
RStudio add-in to add some code snippets, or help with code editing. It is aimed to be used on Windows. It requires RStudio (>= 0.99.1111) and rstudioapi (>= 0.5-1).
This functionality inserts pipes at the current position(s) of the cursor(s) or replaces all selections. It reformats pipe(s) surroundings to achieve following format:
sub <- data %>%
select(column.1, column.2) %>%
filter(column.1 > x) %>%
group_by(column.1) %>%
summarise(n=n_distinct(column.2)) %>%
ungroup
This functionality is especially useful, when copying paths in Windows.
It will reverse all slashes either in the selected block(s) of code, or if there is no selection (or only whitespace is selected), it will reverse all slashes in the clipboard and paste it to the current cursor(s) position(s).
At the moment this is Windows only function.
Function will copy the content of the variable 'under the cursor' into the clipboard. It will be represented as a tab separated value for an easy paste to MS Excel.
There is no need to precisely select the name of the variable. Cursor can be placed anywhere in the name, or variable name needs to be first valid name in the code selection. Add-in will adjust the selection. In the case that it is not possible to generate tsv, message will be written to the console. Otherwise tsv will be 'silently' copied to clipboard without any messages.
At the moment following data structures are supported:
Vectors are represented in a horizontal fashion. If they are named, then first row will contain names and second values. If they are unnamed then only one row with values is copied into the clipboard.
Value copied to clipboard will either have M x N or (M+1) x N, M x (N+1) or (M+1) x (N+1) cells, where M and N are matrix dimensions. If matrix has specified columns names and/or rows names than they will be displayed in the first column and/or row.
In the case that both columns' names and rows' names are specified, the content of the top left cell will be constructed from dimensions' names, if they exist; in the following format: Rows names dimension name, backslash, columns names dimension name. Examples below shows all cases. If dimensions are not named, then variable name will be used.
mat.1 <- matrix( 1:9
, nrow=3
, dimnames=list( rows=letters[1:3]
, columns=letters[24:26]
)
)
rows\columns | x | y | z |
---|---|---|---|
a | 1 | 4 | 7 |
b | 2 | 5 | 8 |
c | 3 | 6 | 9 |
mat.2 <- matrix( 1:9
, nrow=3
, dimnames=list( letters[1:3]
, columns=letters[24:26]
)
)
\columns | x | y | z |
---|---|---|---|
a | 1 | 4 | 7 |
b | 2 | 5 | 8 |
c | 3 | 6 | 9 |
mat.3 <- matrix( 1:9
, nrow=3
, dimnames=list( rows=letters[1:3]
, letters[24:26]
)
)
rows\ | x | y | z |
---|---|---|---|
a | 1 | 4 | 7 |
b | 2 | 5 | 8 |
c | 3 | 6 | 9 |
mat.4 <- matrix( 1:9
, nrow=3
, dimnames=list( letters[1:3]
, letters[24:26]
)
)
mat.4 | x | y | z |
---|---|---|---|
a | 1 | 4 | 7 |
b | 2 | 5 | 8 |
c | 3 | 6 | 9 |
Data frames act as matrices.
1D arrays act as vectors.
2D arrays act as matrices.
3+D arrays will be flatten into a matrix. Matrix will have N+1 columns where N is a number of dimensions and M or M+1 rows, where M is a product of array dimensions. E.g. if array has following dimensions dim=c(2, 4, 2)
, then the output table will have N=3+1=4 columns and M=242=16 rows. If array dimensions are named, then header row will be added. First N columns will be take names from dimensions' names and the last column will be named after variable. Missing names will stay empty.
See examples below.
Example 1
3D array with defined dimension names. One of the dimension names is missing.
(arr.3d <- array( 1:24
, dim=c(3, 4, 2)
, dimnames=list( x=c('a', 'b', 'c')
, c('k', 'l', 'm', 'n')
, z=c('x', 'y')
)
)
)
Print out:
, , z = x
x k l m n
a 1 4 7 10
b 2 5 8 11
c 3 6 9 12
, , z = y
x k l m n
a 13 16 19 22
b 14 17 20 23
c 15 18 21 24
In clipboard:
x | z | arr.3d | |
---|---|---|---|
a | k | x | 1 |
b | k | x | 2 |
c | k | x | 3 |
a | l | x | 4 |
b | l | x | 5 |
c | l | x | 6 |
a | m | x | 7 |
b | m | x | 8 |
c | m | x | 9 |
a | n | x | 10 |
b | n | x | 11 |
c | n | x | 12 |
a | k | y | 13 |
b | k | y | 14 |
c | k | y | 15 |
a | l | y | 16 |
b | l | y | 17 |
c | l | y | 18 |
a | m | y | 19 |
b | m | y | 20 |
c | m | y | 21 |
a | n | y | 22 |
b | n | y | 23 |
c | n | y | 24 |
Example 2
3D array without named dimensions.
(arr.3d <- array( 1:24
, dim=c(3, 4, 2)
, dimnames=list( c('a', 'b', 'c')
, c('k', 'l', 'm', 'n')
, c('x', 'y')
)
)
)
Print out:
, , x
k l m n
a 1 4 7 10
b 2 5 8 11
c 3 6 9 12
, , y
k l m n
a 13 16 19 22
b 14 17 20 23
c 15 18 21 24
In clipboard:
a | k | x | 1 |
b | k | x | 2 |
c | k | x | 3 |
a | l | x | 4 |
b | l | x | 5 |
c | l | x | 6 |
a | m | x | 7 |
b | m | x | 8 |
c | m | x | 9 |
a | n | x | 10 |
b | n | x | 11 |
c | n | x | 12 |
a | k | y | 13 |
b | k | y | 14 |
c | k | y | 15 |
a | l | y | 16 |
b | l | y | 17 |
c | l | y | 18 |
a | m | y | 19 |
b | m | y | 20 |
c | m | y | 21 |
a | n | y | 22 |
b | n | y | 23 |
c | n | y | 24 |
Example 3
Bare 3D array.
(arr.3d <- array(1:24, dim=c(3, 4, 2)))
Print out:
, , 1
[,1] [,2] [,3] [,4]
[1,] 1 4 7 10
[2,] 2 5 8 11
[3,] 3 6 9 12
, , 2
[,1] [,2] [,3] [,4]
[1,] 13 16 19 22
[2,] 14 17 20 23
[3,] 15 18 21 24
In clipboard:
A | A | A | 1 |
B | A | A | 2 |
C | A | A | 3 |
A | B | A | 4 |
B | B | A | 5 |
C | B | A | 6 |
A | C | A | 7 |
B | C | A | 8 |
C | C | A | 9 |
A | D | A | 10 |
B | D | A | 11 |
C | D | A | 12 |
A | A | B | 13 |
B | A | B | 14 |
C | A | B | 15 |
A | B | B | 16 |
B | B | B | 17 |
C | B | B | 18 |
A | C | B | 19 |
B | C | B | 20 |
C | C | B | 21 |
A | D | B | 22 |
B | D | B | 23 |
C | D | B | 24 |
"1D" tables act as vectors.
"2D" tables act as matrices.
"3+D" tables act as 3+D arrays.
Collection of badges
Author: sfr
Source Code: https://github.com/sfr/RStudio-Addin-Snippets
License: GPL-2.0 license
1660893480
RStudio Addin: Copy images from clipboard into .Rmd files or a blogdown post.
devtools::install_github('xiaoa6435/RmdImgPaste')
in macos, exec script like this:
osascript -e '
set theFile to (open for access POSIX file "test.png" with write permission)
try
write (the clipboard as «class PNGf») to theFile
end try
close access theFile'
in window
powershell -sta '
Add-Type -AssemblyName System.Windows.Forms;,
if ($([System.Windows.Forms.Clipboard]::ContainsImage())) {
[System.Drawing.Bitmap][System.Windows.Forms.Clipboard]::GetDataObject(
).getimage().Save("test.png", [System.Drawing.Imaging.ImageFormat]::Png)
}'
in linux (not test):
xclip -selection clipboard -t image/png -o > "test.png"
if this Addin not work, you can test if this scipt can can generate test.png file when you have a image on clipboard
for a general Rmd files, all paste image in curr_path/.assets/, named like rmd-img-paste-%Y%m%d%H%M%s.png. If you don't like it, you can specify a subfloder by options(rmarkdown.paste_image_dir = 'you_floder')
.
for a blogdown post(.Rproj have attr like 'BuildType: Website' and in content/../.., you can override it by options(rmarkdown.is_blogdown_post = FALSE
), all paste image in static/post/postname_files/, and insert code like 
.
you can specify a baseurl by options(rmarkdown.blogdown_baseurl = 'you_baseurl')
.
Tools -> Modify Keyboard Shortcuts -> RmdImgPaste,Customize a shortcut (for example, cmd + v), then you can just use 'cmd + v' paste image into a blogdown post or a Rmd file
this code is based on https://github.com/Timag/imageclipr and make some changes:
Author: Xiaoa6435
Source Code: https://github.com/xiaoa6435/RmdImgPaste
1660674960
XClipboard.jl: Copy and paste in Julia on XWindows systems
This is a partial translation of Ed Rosten's [x_clipboard] (https://github.com/edrosten/x_clipboard), a nearly complete demonstration of how to use the clipboard and drag and drop in X11.
(See also here for a nice overview.)
At this point, only pasting into Julia is implemented.
Copy-and-paste in general (and on X11 in particular) is actually a rather tedious experience. It would be great if there were a higher level, preferably cross-platform library which took care of this, but as of mid-2013, I couldn't find one.
Note that Julia Base has a clipboard()
command that already works for text-based copying. xclipboard()
is meant to allow any kind of data to be pasted, but currently, the parsing of non-text data is up to the individual.
Functions
xclipboard([t1, [t2, ...]]) Get the current contents of the X11
clipboard, optionally specifying target
types.
xclipboard_targets() Get a list of possible target types
for the current selection
decodemime(::MIME{mime}, x) Used to decode a particular target
type. Currently handles text, and
returns other target types as raw
byte arrays.
Example
julia> using XClipboard
julia> xclipboard_targets()
10-element Array{MIME{mime},1}:
MIME type TIMESTAMP
MIME type TARGETS
MIME type MULTIPLE
MIME type SAVE_TARGETS
MIME type UTF8_STRING
MIME type COMPOUND_TEXT
MIME type TEXT
MIME type STRING
MIME type text/plain;charset=utf-8
MIME type text/plain
julia> xclipboard()
"Julia: A fresh approach to technical computing"
julia> xclipboard("UTF8_STRING")
"Julia: A fresh approach to technical computing"
julia> xclipboard("text/plain")
"Julia: A fresh approach to technical computing"
julia> xclipboard("text")
ERROR: Requested clipboard target(s) not found.
in xclipboard at /home/kmsquire/.julia/v0.3/XClipboard/src/XClipboard.jl:37
in xclipboard at /home/kmsquire/.julia/v0.3/XClipboard/src/XClipboard.jl:45
Misc
Binary data (such as images) can be received from the clipboard. However, decoding is currently left up to the individual.
Images, in particular, seem to (almost?) always be available as image/bmp
; however, there is currently no bmp
decoder in Julia.
Author: Kmsquire
Source Code: https://github.com/kmsquire/XClipboard.jl
License: View license
1653049500
Go-clip
A minimalistic clipboard manager for Mac.
This application is intended to help you manage multiple short-lived clippings, it is not meant as a password store or a place to save important data for later use.
The application DOES NOT SAVE YOUR TEXT anywhere on your computer. It is all in-memory, you lose all your data if you quit the application. So do not worry about your copied passwords being saved in plain-text anywhere.
The application has NO connectivity to the internet, so do not worry about your copied text being used for nefarious purposes. Feel free to go through the code to make sure of that.
Pinning clipping will prevent them from being over-written once all existing clippings are used up.
In case you copy a password and want to keep it in the tool for sometime, you can obfuscate it. It will mark it with ****
. You can still copy the whole password once you click on it, it just won't show up on the application.
This is useful in case you don't want your password to be displayed as whole while you are sharing your screen with someone.
Download the latest go-clip.app.zip
from the releases page, unzip it, and copy the .app to your Applications
folder like any other application.
Since the application is not notarized, you will need to right click on the go-clip.app
and choose Open
.
You will see a scary message that warns you about all the bad things that the app can do to your computer. If you are paranoid (fair enough, you don't really know me that well) then you can skip to the section which builds the app from source. That way you can see what exactly the app does (You can check that the application makes no connections to the internet whatsoever).
In case you do trust me, once you click on Open
, you should see the clipboard icon on your system tray. Copy a piece of text to see it on the app!
Make sure you have go
installed. Once that is done, clone this repo and run Make
, it should create the go-clip.app
and open the folder where it was built for you. Copy the .app to your Applications
folder like any other application.
Double click on the app, and the clipboard icon should start displaying on your system tray. Copy a piece of text to see it on the app!
Thanks to github.com/getlantern/systray
, I am able to provide a system tray functionality. I am waiting for fyne.io
to release their integration with systray, so that I can offer a pop-out clipboard experience along with systray. Right now both systray and external app can't exist simultaneously, since both need to be executed on the main thread. (Ref https://github.com/fyne-io/fyne/issues/283)
Author: Prashantgupta24
Source Code: https://github.com/prashantgupta24/go-clip
License: MIT license
1650474120
clipboard.js
Modern copy to clipboard. No Flash. Just 3kb gzipped.
Copying text to the clipboard shouldn't be hard. It shouldn't require dozens of steps to configure or hundreds of KBs to load. But most of all, it shouldn't depend on Flash or any bloated framework.
That's why clipboard.js exists.
You can get it on npm.
npm install clipboard --save
Or if you're not into package management, just download a ZIP file.
First, include the script located on the dist
folder or load it from a third-party CDN provider.
<script src="dist/clipboard.min.js"></script>
Now, you need to instantiate it by passing a DOM selector, HTML element, or list of HTML elements.
new ClipboardJS('.btn');
Internally, we need to fetch all elements that matches with your selector and attach event listeners for each one. But guess what? If you have hundreds of matches, this operation can consume a lot of memory.
For this reason we use event delegation which replaces multiple event listeners with just a single listener. After all, #perfmatters.
Usage
We're living a declarative renaissance, that's why we decided to take advantage of HTML5 data attributes for better usability.
A pretty common use case is to copy content from another element. You can do that by adding a data-clipboard-target
attribute in your trigger element.
The value you include on this attribute needs to match another's element selector.
<!-- Target -->
<input id="foo" value="https://github.com/zenorocha/clipboard.js.git" />
<!-- Trigger -->
<button class="btn" data-clipboard-target="#foo">
<img src="assets/clippy.svg" alt="Copy to clipboard" />
</button>
Additionally, you can define a data-clipboard-action
attribute to specify if you want to either copy
or cut
content.
If you omit this attribute, copy
will be used by default.
<!-- Target -->
<textarea id="bar">Mussum ipsum cacilds...</textarea>
<!-- Trigger -->
<button class="btn" data-clipboard-action="cut" data-clipboard-target="#bar">
Cut to clipboard
</button>
As you may expect, the cut
action only works on <input>
or <textarea>
elements.
Truth is, you don't even need another element to copy its content from. You can just include a data-clipboard-text
attribute in your trigger element.
<!-- Trigger -->
<button
class="btn"
data-clipboard-text="Just because you can doesn't mean you should — clipboard.js"
>
Copy to clipboard
</button>
There are cases where you'd like to show some user feedback or capture what has been selected after a copy/cut operation.
That's why we fire custom events such as success
and error
for you to listen and implement your custom logic.
var clipboard = new ClipboardJS('.btn');
clipboard.on('success', function (e) {
console.info('Action:', e.action);
console.info('Text:', e.text);
console.info('Trigger:', e.trigger);
e.clearSelection();
});
clipboard.on('error', function (e) {
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
});
For a live demonstration, go to this site and open your console.
Each application has different design needs, that's why clipboard.js does not include any CSS or built-in tooltip solution.
The tooltips you see on the demo site were built using GitHub's Primer. You may want to check that out if you're looking for a similar look and feel.
If you don't want to modify your HTML, there's a pretty handy imperative API for you to use. All you need to do is declare a function, do your thing, and return a value.
For instance, if you want to dynamically set a target
, you'll need to return a Node.
new ClipboardJS('.btn', {
target: function (trigger) {
return trigger.nextElementSibling;
},
});
If you want to dynamically set a text
, you'll return a String.
new ClipboardJS('.btn', {
text: function (trigger) {
return trigger.getAttribute('aria-label');
},
});
For use in Bootstrap Modals or with any other library that changes the focus you'll want to set the focused element as the container
value.
new ClipboardJS('.btn', {
container: document.getElementById('modal'),
});
Also, if you are working with single page apps, you may want to manage the lifecycle of the DOM more precisely. Here's how you clean up the events and objects that we create.
var clipboard = new ClipboardJS('.btn');
clipboard.destroy();
This library relies on both Selection and execCommand APIs. The first one is supported by all browsers while the second one is supported in the following browsers.
42+ ✔ | 12+ ✔ | 41+ ✔ | 9+ ✔ | 29+ ✔ | 10+ ✔ |
The good news is that clipboard.js gracefully degrades if you need to support older browsers. All you have to do is show a tooltip saying Copied!
when success
event is called and Press Ctrl+C to copy
when error
event is called because the text is already selected.
You can also check if clipboard.js is supported or not by running ClipboardJS.isSupported()
, that way you can hide copy/cut buttons from the UI.
A browser extension that adds a "copy to clipboard" button to every code block on GitHub, MDN, Gist, StackOverflow, StackExchange, npm, and even Medium.
Install for Chrome and Firefox.
Author: Zenorocha
Source Code: https://github.com/zenorocha/clipboard.js
License: MIT License
1630404061
Explained about
How to copy text to clipboard using Javascript.
Explained 2 easy ways to do it.
https://youtu.be/vlVBSUn6x2o
#javascript #beginners #clipboard
1627095600
Clipboard in Flutter.
GitHub - https://github.com/theindianinnovation/Flutter_clipboard
#flutter tutorials #flutter #clipboard