Skip to content

Instantly share code, notes, and snippets.

@saurfang
saurfang / app.R
Last active May 8, 2019 22:53
Selectize Plugins in Shiny
library(htmltools)
addUIDep <- function(x) {
jqueryUIDep <- htmlDependency("jqueryui", "1.10.4", c(href="shared/jqueryui/1.10.4"),
script = "jquery-ui.min.js",
stylesheet = "jquery-ui.min.css")
attachDependencies(x, c(htmlDependencies(x), list(jqueryUIDep)))
}
@saurfang
saurfang / app.R
Last active August 29, 2015 14:06
Shiny Sortable CheckboxGroupInput with Update on Change
sortableCheckboxGroupInput <- function(inputId, ...) {
# build jquery-ui dependency for sortable
jqueryUIDep <- htmlDependency("jqueryui", "1.10.4", c(href="shared/jqueryui/1.10.4"),
script = "jquery-ui.min.js",
stylesheet = "jquery-ui.min.css")
# sortable enabler
sortableScript <- "
function makeSortable(el) {
el.sortable({
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='//code.jquery.com/jquery-1.9.1.min.js' type='text/javascript'></script>
<script src='//code.highcharts.com/highcharts.js' type='text/javascript'></script>
<script src='//code.highcharts.com/highcharts-more.js"' type='text/javascript'></script>
<script src='//code.highcharts.com/modules/exporting.js' type='text/javascript'></script>
library(rCharts)
library(httr)
library(RJSONIO)
Sys.setlocale(locale = "Chinese")
paresed_data <- read.csv("D:/Downloads/gb2312.csv",header = TRUE,sep = ",",quote="\"", stringsAsFactors = FALSE)
# rawcsv <- tempfile()
# write.csv(paresed_data, rawcsv, row.names = FALSE, fileEncoding = "utf-8")
# paresed_data <- read.csv(rawcsv, fileEncoding = "utf-8", encoding = "UTF-8", stringsAsFactors = FALSE)
# unlink(rawcsv)
@saurfang
saurfang / README.md
Last active August 29, 2015 14:14 — forked from mbostock/.block

The tree layout implements the Reingold-Tilford algorithm for efficient, tidy arrangement of layered nodes. The depth of nodes is computed by distance from the root, leading to a ragged appearance. Cartesian orientations are also supported. Implementation based on work by Jeff Heer and Jason Davies using Buchheim et al.'s linear-time variant of the Reingold-Tilford algorithm. Data shows the Flare class hierarchy, also courtesy Jeff Heer.

Compare to this Cartesian layout.

@saurfang
saurfang / index.html
Last active August 29, 2015 14:15 — forked from mbostock/.block
Superformula Explorer
<!DOCTYPE html>
<meta charset="utf-8">
<title>Superformula</title>
<style>
path {
stroke-width: 1.5px;
stroke: #666;
fill: #ddd;
}
@saurfang
saurfang / s3.Rmd
Created December 11, 2015 18:31
S3 example
```{r}
area <- function(x) UseMethod("area", x)
rectangle <- function(a, b) {
structure(list(a = a, b = b), class = "rectangle")
}
area.rectangle <- function(x) {
x$a * x$b
}
Verifying my Blockstack ID is secured with the address 1BQroEmkps4bRv2Z5bwhamsDAwjTVo4tJW https://explorer.blockstack.org/address/1BQroEmkps4bRv2Z5bwhamsDAwjTVo4tJW
// get accounts managed by Metamask
var account;
web3.eth.getAccounts((err, acc) => {account = acc[0]});
console.log(account);
// get balance
web3.eth.getBalance(account, (err, balance) => {
console.log(web3.fromWei(web3.toDecimal(balance), 'ether'))
});
# install solidity on Mac
brew update
brew upgrade
brew tap ethereum/ethereum
brew install solidity
brew linkapps solidity
# compile solidity contract
cat << EOF | solc - --abi
pragma solidity ^0.4.21;