Tuesday, December 12, 2017
Vues JS - POI - JSX
POI is a nice tool to create VueJS app without worrying about webpack configuration
Simply add this code in index.js file and run poi index.js
Simply add this code in index.js file and run poi index.js
import Vue from "vue" let data = { nom: 'Paul', age: 12 }; function mycomp (m) { return ( Vue.component('m-c', { render() { return <div>Hello {m}</div> } }) ) } let template = (h, { nom, age }) => <div style='color:red;'> <m-c></m-c> <div>Hello { nom } you are { parseInt(age) * 2 }</div> </div> new Vue({ el: "#app", render(h) { return template(h, data) }, components: [mycomp('hal')] })
Thursday, November 9, 2017
Read Connection String in .Net Core
In appsettings.json :
"ConnectionStrings": {
"Annuaire": "Server=SORA11\\MSSQL_APP;Database=Annuaire;User ID=****;Password=*****;Persist Security Info=False"
}
https://stackoverflow.com/questions/39083372/how-to-read-connection-string-in-net-core
In Startup.cs
public void ConfigureServices(IServiceCollection services)
{
...
// Add the whole configuration object here.
services.AddSingleton(Configuration);
}
In your controller add a field for the configuration and a parameter for it on a constructor
private readonly IConfiguration configuration;
public HomeController(IConfiguration config)
{
configuration = config;
}
Now later in your view code you can access it like:
connectionString = configuration.GetConnectionString("DefaultConnection");
"ConnectionStrings": {
"Annuaire": "Server=SORA11\\MSSQL_APP;Database=Annuaire;User ID=****;Password=*****;Persist Security Info=False"
}
https://stackoverflow.com/questions/39083372/how-to-read-connection-string-in-net-core
In Startup.cs
public void ConfigureServices(IServiceCollection services)
{
...
// Add the whole configuration object here.
services.AddSingleton
}
In your controller add a field for the configuration and a parameter for it on a constructor
private readonly IConfiguration configuration;
public HomeController(IConfiguration config)
{
configuration = config;
}
Now later in your view code you can access it like:
connectionString = configuration.GetConnectionString("DefaultConnection");
Tuesday, October 31, 2017
Monday, October 30, 2017
Monday, October 23, 2017
Votre premier container Docker
Friday, October 20, 2017
Friday, October 13, 2017
Rethinkdb -Listen to multiple feeds with asyncio
From :
https://gist.github.com/shivekkhurana/1de00e1e54c36d250a7f19905fe133b9
import rethinkdb as r import asyncio from typing import Callable, Dict r.set_loop_type('asyncio') async def get_connection(): return await r.connect( db='test', host='localhost' ) async def set_change_handler(table_name: str, handler: Callable) -> None: print('Listening for changes on {}'.format(table_name)) connection = await get_connection() feed = await r.table(table_name).changes().run(connection) while (await feed.fetch_next()): change = await feed.next() handler(change) print('Got a change on table: {}; {}'.format(table_name, change)) def get_handler_map(): # add any table_name: handler_func here return { 'events': print, 'actions_status': print, 'triggers_status': print } def main(): loop = asyncio.get_event_loop() for table_name, handler in get_handler_map().items(): loop.create_task(set_change_handler(table_name, handler)) loop.run_forever() if __name__ == '__main__': main()
Thursday, October 12, 2017
Wednesday, October 11, 2017
Monday, October 2, 2017
Saturday, September 30, 2017
Tuesday, September 19, 2017
Tuesday, July 4, 2017
Développer un chat temps-réel avec Socket.io
File watchers and Web browser reload with NodeJS
This tips avod to manualy refresh the browser on file changes
var express = require('express'); var app = express(); app.get([/\/$/, /.*\.html$/], function (req, res) { var filename = __dirname + req.path; filename += filename.endsWith('/')? 'index.html': ''; fs.readFile(filename, function (_, data) { res.send(data + '<script src="/node_modules/socket.io-client/socket.io.js"></script>' + '<script>' + ' var socket = io();' + ' socket.on("file-change-event", function () {' + ' window.location.reload();' + ' });' + '</script>' ); }); }); app.use(express.static(__dirname)); var http = require('http').Server(app); http.listen(8080); var fs = require('fs'); var io = require('socket.io')(http); fs.watch(__dirname, { recursive:true }, function () { io.emit('file-change-event'); });
Thursday, June 29, 2017
Friday, April 21, 2017
Thursday, April 20, 2017
RiotJS compiled tag inside post...
Waiting riot message....
Subscribe to:
Posts (Atom)