logo
down
shadow

Two action buttons, but only the first one, that is written in the server file, works?


Two action buttons, but only the first one, that is written in the server file, works?

By : Pirates
Date : November 21 2020, 03:00 PM
this one helps. output is to display.
Here the insert and delete are more like side effects. Then you should use observeEvent
code :
shinyServer(

function(input, output) {

    pool <- dbPool(
      drv = dbDriver("PostgreSQL", max.con = 100),
      dbname = "postgres",
      host = "localhost",
      user = "postgres",
      password = "123",
      idleTimeout = 36000
    )

    # Show table in the ui #
    output$view <- renderDataTable({

      dbTable<-dbGetQuery(pool, "SELECT * FROM Table")
      dbTable <- select(dbTable, name, lastname)
      names(dbTable)<-c('Name', 'Lastname')
      dbTable

    }) 

    # show droplist in the ui #
    output$selector <- renderUI({

      droplist  <- dbGetQuery(pool, "SELECT name FROM Table")
      selectInput("paria",  "Delete row", droplist$name) 

    }) 

    # Delete function
    delete <- function(paria) {
        queryDelete <- sprintf(
            "DELETE FROM %s WHERE %s = '%s'",
            "Table",
            "name",
            paria
        )
        dbGetQuery(pool, queryDelete) 
        print("Deletion Successful")
    }

    # Insert function
    insert <- function(name, lastname) {
        queryInsert <- sprintf(
            "INSERT INTO %s (%s, %s) VALUES ('%s', '%s')",
            "Table", 
            "name",
            "lastname",
            name,
            lastname
        )
        dbGetQuery(pool, queryInsert) 
        print("Insert Successful")
    }

    # when delete
    observeEvent(input$delete, {
        delete(paria = input$paria)
    })

    # When insert 
    observeEvent(input$insert, {
        insert(name = input$name, lastname = input$lastname)
    })


})
shinyUI(pageWithSidebar(

  headerPanel("Little Program"),

  sidebarPanel(
    conditionalPanel(condition="input.conditionedPanels==1",
                     textInput("name", "Name"),
                     textInput("lastname", "Lastname"),
                     actionButton("action", "Save new person"),
                     actionButton("delete", "DELETE !"),
                     actionButton("insert", "INSERT !")
                     br(),br(),
                     uiOutput("selector")
    ),
    conditionalPanel(condition="input.conditionedPanels==2",
                     helpText("Content Panel 2")
    ) 
  ),
  mainPanel(
    tabsetPanel(
      tabPanel("Table"
        ,dataTableOutput('view')
      ), 
      tabPanel("Panel 2", value=2)
      , id = "conditionedPanels"
    )
  )
))


Share : facebook icon twitter icon
How do I get action buttons with custom layouts to be styled like standard action buttons in Android 3.0+

How do I get action buttons with custom layouts to be styled like standard action buttons in Android 3.0+


By : user3718592
Date : March 29 2020, 07:55 AM
wish helps you Ah, sorry to answer my own question but I have just stumbled upon a way to do this. I was halfway there - you need your custom layout's style to inherit from ActionButton:
code :
@android:style/Widget.ActionButton
android:clickable="true"
iOS action:@selector issue when UIButton is added to another UIButton. Action only works where buttons intersect

iOS action:@selector issue when UIButton is added to another UIButton. Action only works where buttons intersect


By : Alex Otañez
Date : March 29 2020, 07:55 AM
wish help you to fix your issue First of all, adding a button as a subview of another button isn't really common design and I would avoid doing that. Simply create a container UIView that holds both buttons.
The problem you're seeing is because while your button may be displayed beyond the bounds of its superview (the other button), actions on the outside of button1's bounds won't be registered. The only reason you can see button2, is because clipsToBounds is set to NO on button1, which allows its subviews to be drawn outside of its bounds.
plist file gets written in swift 1.2 but its not get written or works in swift 2.0, what should i do?

plist file gets written in swift 1.2 but its not get written or works in swift 2.0, what should i do?


By : Amir Harith Amnabas
Date : March 29 2020, 07:55 AM
may help you . Problem is you are reading from Main bundle while writing into Documents directly.
Reading Path: NSBundle.mainBundle().pathForResource("GameData", ofType: "plist")!
code :
func loadGameData() {
   let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true) as NSArray
   let documentsDirectory = paths.objectAtIndex(0) as! NSString
   let path = documentsDirectory.stringByAppendingPathComponent("GameData.plist")

   let myDict = NSDictionary(contentsOfFile: path)

   if let dict = myDict {
      highscore = dict.objectForKey("highscore")!
   } else {
      print("WARNING: Couldn't create dictionary from GameData.plist! Default values will be used!")
   }
}
How to read and echo file size of uploaded file being written at server in real time without blocking at both server and

How to read and echo file size of uploaded file being written at server in real time without blocking at both server and


By : amy
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You need to clearstatcache to get real file size. With few other bits fixed, your stream.php may look like following:
code :
<?php

header("Content-Type: text/event-stream");
header("Cache-Control: no-cache");
header("Connection: keep-alive");
// Check if the header's been sent to avoid `PHP Notice:  Undefined index: HTTP_LAST_EVENT_ID in stream.php on line `
// php 7+
//$lastId = $_SERVER["HTTP_LAST_EVENT_ID"] ?? 0;
// php < 7
$lastId = isset($_SERVER["HTTP_LAST_EVENT_ID"]) ? intval($_SERVER["HTTP_LAST_EVENT_ID"]) : 0;

$upload = $_GET["filename"];
$data = 0;
// if file already exists, its initial size can be bigger than the new one, so we need to ignore it
$wasLess = $lastId != 0;
while ($data < $_GET["filesize"] || !$wasLess) {
    // system calls are expensive and are being cached with assumption that in most cases file stats do not change often
    // so we clear cache to get most up to date data
    clearstatcache(true, $upload);
    $data = filesize($upload);
    $wasLess |= $data <  $_GET["filesize"];
    // don't send stale filesize
    if ($wasLess) {
        sendMessage($lastId, $data);
        $lastId++;
    }
    // not necessary here, though without thousands of `message` events will be dispatched
    //sleep(1);
    // millions on poor connection and large files. 1 second might be too much, but 50 messages a second must be okay
    usleep(20000);
}

function sendMessage($id, $data)
{
    echo "id: $id\n";
    echo "data: $data\n\n";
    ob_flush();
    // no need to flush(). It adds content length of the chunk to the stream
    // flush();
}
const fileId = Math.random().toString(36).substr(2); // or anything more unique
...

const [request, source] = [
    new Request(`${url}?fileId=${fileId}&size=${filesize}`, {
        method:"POST", headers:headers, body:file
    })
    , new EventSource(`${stream}?fileId=${fileId}`)
];
....
....

$fileId = $_GET['fileId'];
$fileSize = $_GET['size'];

setUnique($fileId, 0, $fileSize);

while ($uploaded = stream_copy_to_stream($input, $file, 1024)) {
    updateProgress($id, $uploaded);
}
....


/**
 * Check if Id is unique, and store processed as 0, and full_size as $size 
 * Set reasonable TTL for the key, e.g. 1hr 
 *
 * @param string $id
 * @param int $size
 * @throws Exception if id is not unique
 */
function setUnique($id, $size) {
    // implement with your storage of choice
}

/**
 * Updates uploaded size for the given file
 *
 * @param string $id
 * @param int $processed
 */
function updateProgress($id, $processed) {
    // implement with your storage of choice
}
....
list($progress, $size) = getProgress('non_existing_key_to_init_default_values');
$lastId = 0;

while ($progress < $size) {
    list($progress, $size) = getProgress($_GET["fileId"]);
    sendMessage($lastId, $progress);
    $lastId++;
    sleep(1);
}
.....


/**
 * Get progress of the file upload.
 * If id is not there yet, returns [0, PHP_INT_MAX]
 *
 * @param $id
 * @return array $bytesUploaded, $fileSize
 */
function getProgress($id) {
    // implement with your storage of choice
}
Serilog SQL Server - Nothing written to the log when in release, works fine in development

Serilog SQL Server - Nothing written to the log when in release, works fine in development


By : user2895922
Date : March 29 2020, 07:55 AM
like below fixes the issue Make sure that you use [dbo] schema in your database. If you have a different schema, update your configuration like this:
code :
"Name": "MSSqlServer",
"Args": {
      "connectionString": "Your connection string",
      "schemaName": "your schema name",
      "tableName": "Logs"
 }
Related Posts Related Posts :
  • R 'cowplot' neatly produce gridded plot with shared (common) legends and unique legends
  • Repeat R script for many times and save results to text file
  • How to negative lookbehind for special characters
  • data.table inner join produces error when no match is found
  • Create a new column base on existing column, but row above
  • Is there a way to visualize the process of source() in RStudio?
  • google places api consumes 10 request but I am doing only 1
  • Statistical mode of a categorical variable in R (using mlv)
  • Using for-loop to mutate a data.frame in r
  • Make plot with regression line for mixed model
  • Shortcut to select matces cases in R studio
  • vectoriced norm/matrix multiplication
  • Negative log10 transformation in R
  • Plot data with duplicate points
  • Visualizing crosstab tables with a plot in R - changing colours
  • How to manually modify automated numbers and labels in plot
  • How can I follow any redirections of a url in R?
  • Add jitter to box plot using markers in plotly
  • Adding an extra item to the legend
  • ggplot fills in data in the wrong order
  • Convert list to data frame
  • R: filtering by list(s) of strings and returning all results that start with the content of the lists
  • R:How to attach parts of a data frame with different headers and/or an overflowing piece of the dat frame
  • How to use 'par' for manipulating plot margins?
  • Can dplyr::case_when return mix of NAs and non-NAs?
  • Text preprocessing and topic modelling using text2vec package
  • Uploading multiple files in Shiny, process the files, rbind the results and return a download
  • R levelplot: color green-white-red (white on 0) according to one variable, but show the values of another variable
  • Why [i] doesn't point to the starting point in a vector
  • In R after generating a mvrnorm distribution, Y, what does Y[,1] do?
  • expand a data frame to have as many rows as range of two columns in original row
  • Getting started with R and CFA
  • Re order x-axis in ggplot so time goes from 12AM to 11PM in R
  • R - Automatically stack every nth column of a data frame and save them as new objects
  • How to format dplyr output in R into doubles (or other workable format)?
  • Dataframe to matrix conversion using tapply turns zeros to NAs
  • Smallest multiple of 1:20 - How can I make it quicker?
  • How to specify the size of a graph in ggplot2 independent of axis labels
  • How can I find the number of a vector's elements in another vector?
  • ROC curve from train/test set in caret R package
  • Random Forest for a mixture of categorical,numeric and "unwanted" variables which include missing values
  • extract certain data from multiple excel files with R
  • Matrix with counts of wins and losses between methods in R
  • Grouping string variables from a dataframe by best string match to make subsets
  • Reorder does not work after adding second geom_points
  • cover POS data formate to the one can apply Arules (Apriori)
  • Matching values between data frames based on overlapping dates
  • Grouped bar chart turns into stacked bar chart ggplot
  • R: How to fill in NA Values within a Column based on grouping?
  • Barchart grouped by variable both count up to 100 percent
  • Converting time in R to 24 hours
  • R - Web scrapping and downloading multiple zip files and save the files without overwriting
  • Find month and year inside string
  • Append multiple csv files into one file using R
  • Use `purrr::map` with k-means
  • R - 'data' is not an exported object from 'namespace:my_package'
  • Sum vector with number by dinamic intervals without looping
  • Issues with ave function in R: error "cannot allocate vector of size 419 kb."
  • Shiny system call with continuous updates
  • Unable to un-nest some fields using google bigquery (standard)
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org