Skip to content

Instantly share code, notes, and snippets.

View lastday154's full-sized avatar

Steve Hoang lastday154

  • NIT Warangal, India
View GitHub Profile
@lastday154
lastday154 / s3.xml
Created April 18, 2018 02:42
s3 configuration
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
@lastday154
lastday154 / csv.php
Created April 25, 2018 09:06
Export to csv
<?php
https://www.yiiframework.com/extension/csvexport
Yii::import('ext.ECSVExport');
// for use with array of arrays
$data = array(
array('key1'=>'value1', 'key2'=>'value2')
....
)
@lastday154
lastday154 / compass.js
Created May 10, 2018 03:39
compass setup
sudo gem install compass -n /usr/local/bin
cd public
compass create styleSheets
ls
css styleSheets
cd styleSheets
/Applications/MAMP/htdocs/elasticsearch/public/styleSheets
https://balsamiq.com/
@lastday154
lastday154 / upload_demo_html.html
Created May 15, 2018 08:49 — forked from paambaati/upload_demo_html.html
Uploading files using NodeJS and Express 4
<html>
<body>
<form action="/upload" enctype="multipart/form-data" method="post">
<input type="text" name="title">
<input type="file" name="file">
<input type="submit" value="Upload">
</form>
</body>
</html>
{
"extends": "airbnb-base",
"env": {
"browser": true,
"node": true,
"commonjs": true,
"es6": true
},
"rules": {
"max-len": [
@lastday154
lastday154 / upload.js
Created May 17, 2018 02:59
upload file nodejs
const form = new formidable.IncomingForm();
form.parse(req, (err, fields, files) => {
const oldPath = files.file.path;
const newPath = path.join(process.cwd(), '/uploads/', files.file.name);
fs.rename(oldPath, newPath, (errRn) => {
if (errRn) {
res.status(500);
res.json({ success: false });
return;
}
@lastday154
lastday154 / setting.js
Created May 17, 2018 07:19
elasticsearch mapping
POST movies
{
"settings": {
"index": {
"analysis": {
"filter": {},
"analyzer": {
"keyword_analyzer": {
"filter": [
"lowercase",
@lastday154
lastday154 / ifelse.js
Created May 25, 2018 03:22
if-else flow in promise (bluebird)
(conditionA
? fs.writeFileAsync(file, jsonData)
: Promise.resolve())
.then(functionA);
var waitFor;
if (conditionA)
waitFor = fs.writeFileAsync(file, jsonData);
else
waitFor = Promise.resolve(undefined); // wait for nothing,
@lastday154
lastday154 / ifelse.js
Created May 25, 2018 03:22
if-else flow in promise (bluebird)
(conditionA
? fs.writeFileAsync(file, jsonData)
: Promise.resolve())
.then(functionA);
var waitFor;
if (conditionA)
waitFor = fs.writeFileAsync(file, jsonData);
else
waitFor = Promise.resolve(undefined); // wait for nothing,