Skip to content

Instantly share code, notes, and snippets.

@Kamilnaja
Kamilnaja / Angular 2 - get data from json file and display
Last active November 6, 2018 19:17
Angular 2 - get data from json file and display
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class HerbsService {
private _url= 'assets/herbs.json';
constructor(private _http: Http) {}
getHerbs () {
return this._http.get(this._url)
.map((response: Response) => response.json());
@dhunmoon
dhunmoon / jsCSVFileCreationBlob.js
Created March 22, 2017 09:57
JS: CSV File Creation Using BLOB
function exportToCsv(filename, rows) {
var processRow = function (row) {
var finalVal = '';
for (var j = 0; j < row.length; j++) {
var innerValue = row[j] === null ? '' : row[j].toString();
if (row[j] instanceof Date) {
innerValue = row[j].toLocaleString();
};
var result = innerValue.replace(/"/g, '""');
if (result.search(/("|,|\n)/g) >= 0)
@cmatskas
cmatskas / csvUploadTest.js
Last active January 11, 2023 19:42
csvUploadTest.js
<!DOCTYPE html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.71/jquery.csv-0.71.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// The event listener for the file upload
document.getElementById('txtFileUpload').addEventListener('change', upload, false);
@kanwarujjaval
kanwarujjaval / form.ejs
Created February 23, 2014 13:54
Creating multiple forms with a single ejs file in node.js
<form action="<%= action %>" method="post">
<% if (fields.length) { %>
<% fields.forEach(function(field){ %>
<label><%= field.name %></label>
<input type="<%= field.type %>" name="<%= field.name %>" <% if (field.property) { %> <%= field.property %> <% } %> >
<% }) %>
<% } %>
<button type="submit"><%= title %></button> <!--Title for button is same as that of the page-->
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var assert = require('assert')
console.log('\n===========');
console.log(' mongoose version: %s', mongoose.version);
console.log('========\n\n');
var dbname = 'testing_geojsonPoint';