This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component} from 'react'; | |
import download from 'downloadjs'; | |
import mime from 'mime-types'; | |
class App extends Component { | |
handleClick = () => { | |
let file = '/testfile.txt'; //file url (local or remote) | |
let filename = 'testfile.txt'; | |
let mimetype = mime.lookup(filename); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let options = { | |
panEnabled: true, | |
dragEnabled: true, | |
controlIconsEnabled: false, | |
zoomEnabled: true, | |
zoomScaleSensitivity: 0.2, | |
minZoom: 0.8, | |
maxZoom: 100000 | |
}; | |
let map = svgPanZoom('#svg-id', options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let width = 850, height = 345; | |
let projection = d3.geoMercator(); | |
let path = d3.geoPath().projection(projection); | |
let svg = d3.select("#map-wrapper").append("svg") | |
.attr('id', 'map') | |
.attr("width", '100%') | |
.attr("height", height) | |
let g = svg.append('g'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Scroll to the top | |
$parent.scrollTop($parent.scrollTop() + $child.offset().top); | |
// Scroll to the center | |
$parent.scrollTop($parent.scrollTop() + $child.offset().top | |
- $parent.height()/2 + $child.height()/2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Get Nearest word of cursor</title> | |
</head> | |
<body> | |
<input id="textArea" type="text"/> | |
<br /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$filename = 'filepath.html'; | |
$path = __DIR__ . '/web/uploads/'; | |
$download_file = $path . $filename; | |
if (file_exists($download_file)) { | |
$extension = explode('.', $filename); | |
$extension = $extension[count($extension) - 1]; | |
header('Content-Transfer-Encoding: binary'); | |
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($path)) . ' GMT'); | |
header('Accept-Ranges: bytes'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Node JS File Upload</title> | |
</head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
root projectDirectory; | |
# example root /var/www/html/myAwesomeProject/public; | |
index index.html; | |
server_name domain_name; | |
location /chat/socket { | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Node JS WebSocket Upload</title> | |
</head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const https = require('https') | |
const app = require('express')() | |
var privateKey = fs.readFileSync('./privatekey.pem', 'utf8') | |
var certificate = fs.readFileSync('./certificate.pem', 'utf8') | |
const credentials = {key: privateKey, cert: certificate} | |
const httpsServer = https.createServer(credentials, app) |
OlderNewer