Posts

Showing posts from 2018

AWS : how to play a video file from s3 bucket in browser

URI all you have to do is to sign a request like: https://s3.amazonaws.com/yourbucket/key? response-content-disposition=inline& X-Amz-Algorithm=AWS4-HMAC-SHA256& X-Amz-Credential=AKIAJWWH7EGSUBWE34IQ/20181228/us-east-1/s3/aws4_request& X-Amz-Date=20181228T074135Z& X-Amz-Expires=86400&X-Amz-SignedHeaders=host& X-Amz-Signature=b3143f8442812e176fd61838813a33f53cfd7e198e1c6e68fab5d03d4a642403   and set it as src attribue to a video element. Player component import React, { Component } from 'react'; import PropTypes from 'prop-types'; const AWS_SERVICE = 's3'; const crypto = require('crypto'); Date.prototype.toYMDString = function() { let year = this.getFullYear().toString(); let month = this.getUTCMonth() + 1; if (month < 10) month = "0" + month; let day = this.getUTCDate(); if (day < 10) day = "0" + day; return String(year) + String(month) + S

WebRTC recording via Kurento media server

Official guide I encountered some errors while following the Official guide. Lucky, I fixed all the errors and make it work finally. Notes my workaround here, hope it work for you if you have the same problem. gpg: keyserver receive failed: keyserver error local install guide solution from stackoverflow sudo apt-key adv --keyserver hkp://keys.gnupg.net:80 --recv-keys 5AFA7A83 WebSocket connection to 'wss://<local_ip>:8433/kurento' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED cause the application server is started with https if you follow the guide: http-server -p 8443 -S -C keys/server.crt -K keys/server.key but kurento media server start without ssl by default config. You can get from the config and the default port is 8888 . /etc/kurento/kurento.conf.json solution modify kurento media server config to enable ssl and use the same cert that used for your application server. it is a little complex. but we have a easy solution, j

AWS: how to upload file to your s3 bucket via EvaporateJS in browser

Image
Evaporate and config s3 bucket and IAM user EvaporateJS Config AWS s3 bucket Managing Access Permissions to Your Amazon S3 Resources User Access Key In summary, create a s3 bucket, set up CORS settings and bucket policy. <CORSConfiguration> <CORSRule> <AllowedOrigin>https://*.yourdomain.com</AllowedOrigin> <AllowedOrigin>http://*.yourdomain.com</AllowedOrigin> <AllowedMethod>PUT</AllowedMethod> <AllowedMethod>POST</AllowedMethod> <AllowedMethod>DELETE</AllowedMethod> <AllowedMethod>GET</AllowedMethod> <ExposeHeader>ETag</ExposeHeader> <AllowedHeader>*</AllowedHeader> </CORSRule> </CORSConfiguration> { "Version": "2012-10-17", "Id": "Policy145337ddwd", "Statement": [ { "Sid": "&quo

AWS : how to get cognito user attributes in Lambda/cloud logic

Image
Lambda function(js) const AWS = require('aws-sdk'); const cognito = new AWS.CognitoIdentityServiceProvider(); function getUser(Username) { return new Promise((resolve, reject) => { cognito.adminGetUser({ UserPoolId: process.env.COGNITO_USER_POOL_ID, Username: Username }, (err, data) => { if (err) reject(err.stack); else resolve(data.UserAttributes[2].Value); }); }); } async function getEmail(Username) { return await getUser(Username); } exports.handler = async (event) => { console.log(await getEmail('abcdef')); console.log(await getEmail('hijklmn')); console.log('done'); return 'ok'; }; set Execution role with correct policy as below descripted. set an environment 'COGNITO_USER_POOL_ID' with the user pool id. Role policy { "Version": "2012-10-17", "Statement&

node.js download file from aws s3 bucket via http request with AWS Signature Version 4

Image
Main codes function getYMD(d) { let r = d.getFullYear().toString(); let m = d.getUTCMonth() + 1; if (m < 10) m = "0" + m.toString(); else m = m.toString(); r = r + m; let day = d.getUTCDate(); if (day < 10) day = "0" + day.toString(); else day = day.toString(); r = r + day; return r; } function getTZ(d) { let r = d.getFullYear().toString(); let m = d.getUTCMonth() + 1; if (m < 10) m = "0" + m.toString(); else m = m.toString(); r = r + m; let day = d.getUTCDate(); if (day < 10) day = "0" + day.toString(); else day = day.toString(); r = r + day + "T"; let h = d.getUTCHours(); if (h < 10) h = "0" + h.toString(); else h = h.toString(); r = r + h; let min = d.getUTCMinutes(); if (min < 10) min = "0" + min.toString(); else min =

easy tab component, pure js + css, without react

This is tab example 1 Passion Organization Content Engagement this is passion pannel this is organization pannel this is engagement pannel This is tab example 2 Passion Organization Content Engagement this is passion pannel 2 this is organization pannel 2 this is engagement pannel 2 end test This is haha node styles <style> .container { padding-right: 15px; padding-left: 15px; margin-right: auto; margin-left: auto; } .tabs { padding-left: 0; margin-bottom: 0; list-style: none; } ol, ul { margin-top: 0; margin-bottom: 10px; } .tabs > li { margin-bottom: -1px; position: relative; display: inline-block; padding: 6px 12px; border-radius: 5px 5px 0 0; background-color: #aac4bd; border: 2px solid #7ea299; margin-right: 2px; color: #fff; cursor: pointer; } .tabs > li.active { background-color: #fbfbfc; border-bottom: 0; padding-bottom: 8px; color: #7ea

How to Record video use getUserMedia and MediaRecorder API

example sample codes <div> <video id='camera'></video> </div> <script type='text/javascript'> var p = navigator.mediaDevices.getUserMedia({ audio: true, video: true }); p.then(function(mediaStream) { var video = document.querySelector('video'); video.src = window.URL.createObjectURL(mediaStream); video.onloadedmetadata = function() { video.muted = true; video.play(); } var mediaRecorder = new MediaRecorder(mediaStream); var chunks = []; mediaRecorder.ondataavailable = function(e) { chunks.push(e.data); } mediaRecorder.onstop = function() { var blob = new Blob(chunks, {'type' : 'video/webm'}); chunks = []; var hyperlink = document.createElement('a'); hyperlink.href = URL.createObjectURL(blob); video.src = hyperlink.href; video.muted = false; video.c

Ghost publishing platform sources: how hbs template engine is set to its site app

core js codes in core/server/services/themes/active.js: // Set the views and engine siteApp.set('views', this.path); siteApp.engine('hbs', engine.configure(this.partialsPath)); Refers https://expressjs.com/en/guide/using-template-engines.html https://docs.ghost.org/api/handlebars-themes/

sqlite3 show all tables of a database

show all tables of a database open database file via sqlite3 sqlite3 content/data/ghost-dev.db command to list all tables .tables || .table $sqlite3 content/data/ghost-dev.db SQLite version 3.11.0 2016-02-15 17:29:24 Enter ".help" for usage hints. sqlite> .tables accesstokens migrations refreshtokens api_keys migrations_lock roles app_fields mobiledoc_revisions roles_users app_settings permissions sessions apps permissions_apps settings brute permissions_roles subscribers client_trusted_domains permissions_users tags clients posts users integrations posts_authors webhooks invites posts_tags show table structure se

coca top 20000 words: TOP 20000 words from Corpus of Contemporary American English

TOP 20000 words Here you are! https://coca.errong.win

Hack to ghost core: mount/add new apps/sites on your ghost server

Image
Install ghost from source First, you should know how to develop with ghost . create a new react app under core/server folder simple example core/server$ mkdir newapp core/server$ cd newapp core/server/newapp$ Ghost/core/server/web/newapp$ ls app.js controller.js index.js Ghost/core/server/web/newapp$ cat index.js module.exports = require('./app'); Ghost/core/server/web/newapp$ cat app.js const express = require('express'); module.exports = function setupNewApp() { const newApp = express(); newApp.get('*', require('./controller')); return newApp; }; Ghost/core/server/web/newapp$ cat controller.js const path = require('path'); module.exports = function newAppController(req, res) { res.send('Welcome to new App!'); }; Add route for your new site/app ./core/server/app.js // Mount the apps on the parentApp // ADMIN parentApp.use('/ghost', require('./admin')()); // import new

A simple web audio player, bind to <span/>, one click, audio play, click again, audio stop

example All you have to is to write below html code: a span with class name of word-audio and attribute of data-src pointed to a audio stream resource   <span class='word-audio audio' style='display:inline-block'  data-src='https://cdn.mp3xa.pw/proxy/cs1-43v4.vkuseraudio.net/ p17/fe6d95af2cee33.mp3'></span>    Bertie Higgins — Casablanca word.js function startAnimation(e) { if (e.className == 'word-audio audio') e.className = 'word-audio audio-light'; else if (e.className == 'word-audio audio-light') e.className = 'word-audio audio-playing'; else e.className = 'word-audio audio' console.log(e.className); } function play(e, context, audioBuffer) { if (e.state == 1) { e.source.stop(); e.source.onended(); e.source = null; } else { e.state = 1; const source = context.createBufferSource(); e.source = source;

How to extract media files from a anki flashcard package(*.apkg)

Image
*.apkg The .apkg file is a zip file (as you know). Inside, you'll find the collection (an sqlite3 database of notes/cards), the media file which you were trying to open, and a bunch of numbered files 0-whatever number(these are media files). Just use 7zip tool open the apkg file and extract into a folder. open the "media" file via a text editor tool to find the media file extension. example of "media" {"16486": "COCA_16486.mp3", } rename "16486" file to a mp3 file, then you got the media file. how media used in flash card Export your flash cards into a plain text. [sound:COCA_16486.mp3] spatially <div style=''>英['speɪʃəlɪ] 美['speɪʃəlɪ]</div> <div style=''>adv.空间地,存在于空间地;</div> "<div><br /></div><div style='color:RosyBrown'>ADJ</div><div style='color:OrangeRed'>空间的;与空间有关的</div><div style=""font-weigh

fix up chromium m47 build error: unsupported reloc 42 against global symbol gmon_start

Error: ld.gold: error: /usr/lib/gcc/x86_64-linux-gnu/5.3.1/../../../x86_64-linux-gnu/crti.o: unsupported reloc 42 against global symbol gmon_start Solution: export GYP_DEFINES="linux_use_bundled_gold=0"

bizcharts example: Line Chart

Image
Chart UI Codes ChartComponent.js import React, { Component } from 'react'; import {Chart, Axis, Tooltip, Geom, Coord, Label} from 'bizcharts'; import DataSet from '@antv/data-set'; const { DataView } = DataSet; export class LineChart extends Component { render() { const { data, width, height } = this.props; if (!data || data.length <= 0) return null; const ytitle = { autoRotate: true, offset: -10, textStyle: { fontSize: '22', textAlign: 'left', fill: 'rgb(75,83,87)', rotate: 0 }, position: 'end', }; const xtitle = { autoRotate: true, offset: -20, textStyle: { fontSize: '22', textAlign: 'center', fill: 'rgb(75,83,87)', rotate: 0 }, position: 'end', }; const line = { stroke: 'rgb(197,197,200)', lineWidth: 2

bizcharts example : Doughnut Chart

Image
Chart UI key codes explaintion: <Coord type='theta' innerRadius={0.45} /> without 'innerRadius={0.45}', UI will looks like: without below codes, UI will looks like: <Geom select={[false,{}]} type='intervalStack' position='percent'  color={['type', ['rgba(255, 255, 255, 0)']]}  style={{stroke: 'rgba(152,191,182,1)', lineWidth: 1}}>  </Geom> Codes ChartComponent.js import React, { Component } from 'react'; import {Chart, Axis, Tooltip, Geom, Coord, Label} from 'bizcharts'; import DataSet from '@antv/data-set'; const { DataView } = DataSet; export class ScoreChart extends Component { render() { const { width, height, score } = this.props; const scoreData = [ { type: 'Score', value: score }, { type: '', value: 10 - score }, ]; const scoreDv = new DataView(); scoreDv.source(scoreData) .transform({ type: 'pe

sed replace shell variable which include slash ('/')

Test content cat test-sed.txt aaa/bbb/ccc/ddd/eee fff/ggg/ss replace "ccc/ddd" to "CCC/DDD" via sed NEW_STRING="CCC/DDD" sed -i "s:ccc/ddd:${NEW_STRING}:" test-sed.txt Notes: use ':' as seperate char rather than '/', which is default use "" include the replace command

Await is a reserved word error

Solution: In order to use await, the function directly enclosing it needs to be async. example codes: async tryGetUserName() { let session = await Auth.currentSession(); ...... } async should be there, otherwise you will get the error.

Fix up: Can't Load URL: The domain of this URL isn't included in the app's domains.

Image
Issue Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings. Scenario create a facebook app to get an appid use that appid in website to initialized the facebook javascript SDK use FB.ui to share content to facebook full source codes <!-- init facebook js sdk via your appid --> <script> window.fbAsyncInit = function() { FB.init({ appId : 'yourappid', autoLogAppEvents : true, xfbml : true, version : 'v3.1' }); }; (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "https://connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'

connect shadowsocks server on ubuntu via ss-local

#Server config [Set up your own shadowsocks server](https://errong.win/2018/06/05/setup-shadowsocks-on-ubuntu-16-04/) or found/buy one. You should have a shadowsocks server with below informations: * server ip * server port * password * method #install ~~~ sudo apt-get install software-properties-common -y sudo add-apt-repository ppa:max-c-lv/shadowsocks-libev -y sudo apt-get update sudo apt install shadowsocks-libev ~~~ #configure match to the server's info. ~~~ sudo vim /etc/shadowsocks-libev/config.json {     "server":"xx.xx.xx.xx", // server IP     "server_port":8911,     "local_port":1008, // local port     "password":"jesuslove",     "timeout":60,     "method":"chacha20-ietf-poly1305" } ~~~ #run ss-local ```sudo ss-local -c  /etc/shadowsocks-libev/config.json``` #export socks proxy system wide ~~~ export http_proxy=socks5://127.0.0.1:1008 export https_proxy=socks5://127.0.0.1:1008 ~~~ #u

c++: Max Heap Template

https://en.wikipedia.org/wiki/Min-max_heap My simple implementation of max heap. Change the compare from > to < in below codes, you will get a min heap. template<typename T> class MaxHeap { public: MaxHeap() { size_ = 0; capacity_ = 2; heap_ = new T[capacity_]; } MaxHeap(int capacity) { if (capacity >= 2) { heap_ = new T[capacity]; capacity_ = capacity; size_ = 0; } else { size_ = 0; capacity_ = 2; heap_ = new T[capacity_]; } } ~MaxHeap() { if (heap_) delete[] heap_; } public: int size() { return size_; } void insert(const T& t) { if ((size_+1) >= capacity_) { capacity_ *= 2; T* tmp = new T[capacity_]; for (int i = 0; i <= size_; i++) tmp[i] = heap_[i]; delete[] heap_; heap_ = tmp; } size_++; heap_[size_] = t; int i = size_; int tmp = heap_[i]; while (i > 1 && tmp > heap_[i / 2]) { heap_[i] = heap_[i / 2]; heap_[i / 2] = tmp; tmp = heap_[i / 2]; i /= 2;

Ember.js : Custom "index" route's path and Custom "/" path's route

Image
"index" Route The index route, which will handle requests to the root URI (/) of our site. How to generate a new route called index: ember g route index The index route is special: it does NOT require an entry in the router's mapping. a Nested "index" Route An index nested route works similarly to the base index route. It is the default route that renders when no route is provided. Use 'rentals' as example, when we navigate to /rentals, Ember will attempt to load the rentals index route as a nested route. To create an index nested route, run the following command: ember g route rentals/index If you open up your Router (app/router.js) you may notice that the rentals line has changed. This extra function() {} is required because it needs a child route, the this.route('index', { path: '/'}); is implied. Router.map(function() { this.route('about'); this.route('contact'); this.route('rentals', functi

Set up gitweb server on nginx

Image
Precondition please setup your git server via git-http-backend on nginx. Setup gitweb conf sudo apt-get install gitweb /etc/gitweb.conf is Gitweb (Git web interface) configuration file The default project root is /usr/lib/git. Here, I changed to my own path. our $projectroot = "/home/errong_leng/www/git"; Change nginx conf cat /etc/nginx/sites-enabled/git.errong.win.conf server { listen 80; listen [::]:80; server_name git.errong.win; auth_basic "Restricted"; auth_basic_user_file /home/errong_leng/.gitpasswd; location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ { root /home/errong_leng/www/git; fastcgi_pass unix:/var/run/fcgiwrap.socket; fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; fastcgi_param PATH_INFO $uri; fastcgi_param GIT_PROJECT_ROOT /home/errong_leng/www/git; fastcgi_param GIT_HTTP_EXPORT_ALL ""; fastcgi_param REMOTE_USER $remote_user; in

Install Perl module on ubuntu

Install by cpan cpan -i foo Replace foo with the module name you want to install. Install from source Search the module on cpan.org Download the source. Let's use HTML::Entities for example. You will get your search url: http://search.cpan.org/~gaas/HTML-Parser-3.72/lib/HTML/Entities.pm The source url will be: http://www.cpan.org/authors/id/G/GA/GAAS/HTML-Parser-3.72.tar.gz Make and install perl module tar -xvf HTML-Parser-3.72.tar.gz cd HTML-Parser-3.72/ perl Makefile.PL make sudo make install

setup http/https git server on nginx via git-http-backend

Precondition sudo apt-get install nginx fcgiwrap git apache2-utils Set up https server First, please setup your https server by your self. You can refer to my guide git-http-backend git-http-backend is a Server side implementation of Git over HTTP. /usr/lib/git-core/git-http-backend Set Up Password Authentication file for your git server We can get a password with MD5-based password algorithm, Apache variant via openssl passwd command. You can add a username to the file using this command. We are using sammy as our username, but you can use whatever name you'd like: sudo sh -c "echo -n 'sammy:' >> .gitpasswd" Next, add an encrypted password entry for the username by typing: sudo sh -c "openssl passwd -apr1 >> .gitpasswd" You can repeat this process for additional usernames. You can see how the usernames and encrypted passwords are stored within the file by typing: cat .gitpasswd Output sammy:$apr1$wI1/T0nB$jEKuTJHkTOOWk

setup https server via An ACME Shell script on nginx

I will give every detail steps when I setup https server for https://git.errong.win . You can refer as a guide. acme.sh acme.sh is probably the easiest & smartest shell script toautomatically issue & renew the free certificates from Let's Encrypt . Install the shell script via guide http server nginx conf First, let's setup a http server first via nginx. After you installed nginx, the simple way to setup a http server is to add a conf file under /etc/nginx/sites-enabled/ folder. cat /etc/nginx/sites-enabled/git.errong.com.conf server { listen 80; listen [::]:80; server_name git.errong.com; location / { root html; index index.html index.htm; } } Reload nginx via sudo nginx -s reload issue free certificates sudo acme.sh --issue --home /etc/letsencrypt --domain example.com --webroot /home/errong_leng/www/git --reloadcmd "nginx -s reload" --accountemail errong.leng@gmail.com [Wed Jun 13 01:51:07

Samba add user for share

add user sudo smbpasswd -a USER sudo smbpasswd -e USER set up share path /etc/samba/smb.conf [USER]  comment = USER home  path = /home/USER  writeable = yes  public=yes  browseable = yes  create mode = 776  force directory mode = 776 restart samba service sudo systemctl restart smbd.service sudo systemctl restart nmbd.service if still can't access, then check below config /etc/samba/smb.conf [global] hosts allow = #add your IP here restart samba service again, it should work now.

Fix issue : grunt init failed with error Couldn't find match for "

Issue PS D:\Ghost> grunt init Running "update_submodules:pinned" (update_submodules) task Running "subgrunt:init" (subgrunt) task yarn install v1.7.0 [1/5] Validating package.json... [2/5] Resolving packages... [3/5] Fetching packages... warning Pattern ["glob@latest"] is trying to unpack in the same destination "C:\\Users\\lenger\\AppData\\Local\\Yarn\\Ca che\\v1\\npm-glob-7.1.2-c19c9df9a028702d678612384a6552404c636d15" as pattern ["glob@^7.0.5","glob@^7.0.5","glob@^7.1.0", "glob@^7.0.4","glob@^7.1.2","glob@^7.0.3","glob@^7.0.3","glob@^7.0.0","glob@7.1.2","glob@^7.0.3"]. This could result in non-deterministic behavior, skipping. error Couldn't find match for "8dc6b689903c9363ade94e2e4d21c94813bbbe98" in "refs/heads/master,refs/heads/node-4-compat, refs/tags/v0.0.1,refs/tags/v0.0.2,refs/tags/v0.0.3,refs/tags/v0.1.0,refs/ta

Transfer your ghost server between hosts

Assume you have a ghost server ran at a host machine. Oneday the host machine maybe out of space or you find a new cheap host, or you have a new host that have power memory and performance. Then you may need to transfer your ghost server to another new host. tar your ghost server to a *.tar.gz //blog is my ghost server root directory $cd www/blog $tar -zcvf blog.tar.gz blog copy the blog.tar.gz to the new host preinstall on new host nginx sudo apt-get install nginx node.js https://nodejs.org/en/download/ extract and add node bin path to env ghost npm i -g ghost-cli acme.sh https://github.com/Neilpang/acme.sh configure on new host tar cvf blog.tar.gz nginx conf sudo ln -sf blog/system/files/blog.conf /etc/nginx/sites-available/blog.conf sudo ln -sf /etc/nginx/sites-available/blog.conf /etc/nginx/sites-enabled/blog.conf start http server ghost start if you encounter systemd error, just follow the hint command(ghost linuxuser systemd) by ghost and run ghost

setup shadowsocks server on ubuntu 16.04

install sudo apt-get install software-properties-common -y sudo add-apt-repository ppa:max-c-lv/shadowsocks-libev -y sudo apt-get update sudo apt install shadowsocks-libev configure sudo vim /etc/shadowsocks-libev/config.json { "server":"10.128.0.2", "server_port":8911, "local_port":1008, "password":"jesusislove", "timeout":60, "method":"chacha20-ietf-poly1305" } start server sudo systemctl start shadowsocks-libev google compute engine If the server are running on a google compute engine, You need to setup a firewall rules for the server port(8911, written in config.json). shadowsocks Apply to all IP ranges: 0.0.0.0/0 tcp:8911, udp:8911 Allow client configuration iOS Android Shadowsocks for Android / iOS also accepts BASE64 encoded URI format configs: ss://BASE64-ENCODED-STRING-WITHOUT-PADDING#TAG Where the plain URI should be: ss://method:passwo

他的力量若不够

Image
利未记五7、11 7「他的力量若不够献一只羊羔,就要因所犯的罪,把两只斑鸠或是两只雏鸽带到耶和华面前为赎愆祭:一只作赎罪祭,一只作燔祭。 11「他的力量若不够献两只斑鸠或是两只雏鸽,就要因所犯的罪带供物来,就是细面伊法十分之一为赎罪祭;不可加上油,也不可加上乳香,因为是赎罪祭。 Photo by Brooke Lark / Unsplash

expressjs : implement http file download

Express helper, res.download Express has a helper for this: app.get('/xxx', function(req, res){  var file = __dirname + '/xxx';  res.download(file); // Set disposition and send it.  }); http file download header https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition res.setHeader('Content-disposition', 'attachment; filename=xxx');

iptables, clean all rules

command sudo iptables -P INPUT ACCEPT sudo iptables -F list all rules sudo iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy DROP) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination

node.js : file upload via express and multer

Image
Form-based File Upload in HTML https://tools.ietf.org/html/rfc1867 Express Fast, unopinionated, minimalist web framework for node. Multer Multer is a node.js middleware for handling multipart/form-data, which is primarily used for uploading files. It is written on top of busboy for maximum efficiency. NOTE: Multer will not process any form which is not multipart (multipart/form-data). Client Codes(index.html) <script type="text/javascript"> function upload(postUrl, fieldName, files) { var formData = new FormData(); formData.append(fieldName, files); var req = new XMLHttpRequest(); req.open("POST", postUrl); req.onload = function(event) { console.log(event.target.responseText); }; req.send(formData); } function onchange() { for (let i = 0; i < this.files.length; i++) { upload('/uploads', 'uploadfile', this.files[i]); } } window.onload = function () { var input = document.getElementById('file'); inpu

Print all combination of that select n elements from 1,2,3,...,m.

"C" is for "combination". A combination is an un-ordered collection of distinct elements, usually of a prescribed size and taken from a given set. C(n, r) = n!/[r!(n-r)!]    #include <stdio.h> #include <sys/time.h> int a[1001]; // selected n numbers stored in array a // a[1], a[2], ... , a[n] // a[i+1] > a[i] // a[i] - i <= m - n + 1 void comos(int n, int m) { int i,j; if (n > m) return; for (i = 1; i <= n; i++) { a[i] = i; } int cur = n; do { if (a[cur]-cur <= m - n) { for (i = 1; i <= n; i++) printf("%d ", a[i]); printf("\n"); a[cur]++; continue; } else { if (cur == 1) { break; } a[--cur]++; for (i = 1; i <= (n-cur); i++) a[cur+i] = a[cur] + i; if (a[cur] - cur < m - n + 1) cur=n; } } while(1); } int main() { int N, M; while (scanf("%d %d", &N, &M) != EOF) {

all learning is understanding relationships

James Comer says that no significant learning can occur without a significant relationship. George Washington Carver says all learning is understanding relationships. "You were chosen to be in my class because I am the best teacher and you are the best students, they put us all together so we could show everybody else how to do it." "Really?" "Really. We have to show the other classes how to do it, so when we walk down the hall, people will notice us, so you can't make noise. You just have to strut." "I am somebody. I was somebody when I came. I'll be a better somebody when I leave. I am powerful, and I am strong. I deserve the education that I get here. I have things to do, people to impress, and places to go." "Yeah!" You say it long enough, it starts to be a part of you.