NodeMCU default access point name (AI Thinkerxxx) - esp8266

NodeMCU shows a default network as "AI-Thinkerxxx" when it's powered up.
How can I change the default access point name (AI thinker xxx to some other name)?
Where should I make changes to achieve it?

You can use the function wifi.ap.config(). The sole parameter is a table of configuration details. An example:
local cfg = { ssid = 'MySSID', pwd = 'MySecurePwd', save = true }
wifi.api.config(cfg)
Full documentation can be found at https://nodemcu.readthedocs.io/en/master/en/modules/wifi/#wifiapconfig

Related

OSRM Configure blocking hours for a specific road

i'm working with OSRM(Open Source Routing Machine) and ran into some problems.
I want configure blocking hours for a specific road(like Grab)
Ex: The street called Cau Giay block taxis from 4.00pm to 7.00pm
code detail:
function restrict(way, result)
-- Check if the way is named contain Cau Giay
local name = way:get_value_by_key('name')
if name and string.find(name, 'Cau Giay') then
-- Add a restriction to the way
result.restriction = '* # (Mo-Fr 16:00-19:00)'
end
end
function way_function(way)
local result = {
-- Other routing rules and restrictions go here
}
restrict(way, result)
return result
end
but nothing changed.
please tell me where the above code is wrong and suggest some ways you have done it!
Thanks and best regards!
https://github.com/Project-OSRM/osrm-backend/issues/33 and
https://github.com/Project-OSRM/osrm-backend/issues/735

freeradius 3 mac auth user group (for configuration simplicity)

I have implemented Radius MAC authentication with Unifi AP and freeradius. I am using Radius primarily to set the vlan that the device should sent to allowing a consolidated SSID to handle multiple vlans. (This is a home network, not an enterprise so I am not concerned with the mac spoofing situation). Any MAC connecting will get a vlan (but non-radius users will go to a guest vlan by default)
The freeradius question is how I can go about assigning a group value to each MAC user definition and then post-auth use that group name to define the specific attributes such as Tunnel-Type, Tunnel-Medium-Type, and Tunnel-Private-Group-Id. I simply want to do this to avoid having to repeat all these tunnel values for each device.
Example (not sure if syntax is right)
authorize file
AABBCCDDEEFFGG Group := "iot", Cleartext-Password := "AABBCCDDEEFFGG"
site-enabled/default (I think it might go here)
if (group == "iot) { #update reply, set Tunnel-* values }
Any guidance someone could provide would be great. All the examples I have found seem to be using the mysql backend and I don't have a need for the additional complexity.
I was able to figure this out using control variables. Here is the solution.
Create a custom attribute in the dictionary file.
ATTRIBUTE VLAN-Group-Name 3000 string
Add users to the authorize file like so
AA-BB-CC-DD-EE-FF Cleartext-Password := "AA-BB-CC-DD-EE-FF", VLAN-Group-Name := "iot"
In your virtual server, in my case it was sites-enabled/default, look for the post-auth section and add code similar to this. You will replace the group-id XXX with your vlan # you want sent back to the AP to be assigned. I placed the code right above the -sql portion.
switch "&control:VLAN-Group-Name" {
case "iot" {
update reply {
Tunnel-Type = 13,
Tunnel-Medium-Type = 6,
Tunnel-Private-Group-Id = XXX
}
}
case "general" {
update reply {
Tunnel-Type = 13,
Tunnel-Medium-Type = 6,
Tunnel-Private-Group-Id = XXX
}
}
}
This allows you to keep the authorize file clean with just users and assign them a group and keep the group values simplified in the post-auth. If you ever needed to change the vlan # of any group just one update and restart.
Cheers!

Hyperlinking a folder stored on iManage

I'm looking for a way to create a hyperlink to a particular folder in Worksite.
So far, I've only come up with a macro linking files on the basis of their database numbers but folders do not have database numbers (I think).
Another thing is that I wanted the folders to be opened in Outlook (Worksite is connected with Outlook and we access folders through it)
What I try to accomplish is creating hyperlinks in Excel for easy folder access (just like hyperlinks to files).
Does anybody have a clue if it's even possible? If yes, I'd appreciate an example of a code for this.
Thanks in advance.
Yes it's possible.
You don't mention which version of the iManage client you're working with however I'm going to assume FileSite 9.x. Installed with that client is a custom protocol handler which supports a custom URI scheme.
In effect this allows you to compose a hyperlink with plain text which you can then embed in your web page, or just start a new process in Windows to let the default browser load it up.
The custom protocol handler will parse it and then start up whatever iManage client it can (FileSite in your case) and then navigate to the correct folder.
Format is iwl:dms=[ServerName]&&lib=[DatabaseName]&&page=[FolderID]
Here's some C# that builds out such a string
var serverName = "MYSERVERNAME";
var databaseName = "MYDBNAME";
var serverName = "1234"; // internal numeric ID of folder (MHGROUP.PROJECTS.PRJ_ID in database, or IManFolder.FolderID via iManage COM API object model
var sb = new StringBuilder("iwl:");
sb.Append($"dms={serverName}");
sb.Append("&&");
sb.Append($"lib={databaseName}");
sb.Append("&&");
sb.Append($"page={serverName}");
// sb.ToString() will now output the hyperlink reference to your folder which you can pass to your web browser..
Sub Folder_link
Dim dmsIM As IManDMS
Dim dmsS As IManSession
Dim dmsD As IManDatabase
Dim FdR As IManFolder
Dim FdrLoc As String
Dim FdrID As Long
Const ServerName As String = <DMS name>
Const DatabaseName As String = <DatabaseName>
FdrLoc = "\\{DMS name}\{DatabaseName}\Main Folder\SubFolder\SubSubFolder\TargetFolderName"
Set dmsIM = New ManDMS
Set dmsS = dmsIM.Sessions.Add(ServerName)
dmsS.TrustedLogin
Set dmsD = dmsS.Databases.ItemByName(DatabaseName)
Set Fdr = Imanage.ImanFolder.Location (FdrLoc)
FdrID = Fdr.FolderID
With ThisWorkBook.WorkSheets(1).Range("A1")
.Hyperlinks.Add _
Anchor:=Selection, _
Address:="iwl:dms={serverName}&&lib={databaseName}&&page=" & FdrID, _
TextToDisplay:="link"
End With
End Sub

How can I find the current language in a Laravel view?

I'm using the Laravel Lang class for localization of my web app. I've added two languages to the languages array in application/config/application.php. This changes the default language it uses for localization to whatever the first part of the URI indicates (e.g. bla.com/en/bla and bla.com/co/bla). Now I need to be able to check what the current default language is in my view. However, the Lang class provides no way of checking this as far as I've been able to figure out, as the Lang::$language variable is protected. Is there any way of checking this apart from manually parsing the URI?
The cleanest way to know the current language of your website in Laravel appears to be :
Lang::locale();
https://laravel.com/api/5.8/Illuminate/Translation/Translator.html#method_locale
It's different than this command that will return the default language of your website :
Config::get('app.locale');
An alternative, a bit shorter way could be using something like this:
app()->getLocale()
The advantage of this is that IDEs such as PHPStorm recognize this function and can help you develop much faster.
BenjaminRH's answer is very good, and his suggested approach works perfectly. I've improved the snippet a bit. Now it detects the browser language and checks if that language is supported according to the application's config file.
It's a quick hack, but it works on my app. Note that the application language is also set now. Feel free to use ore improve it.
Route::filter('before', function()
{
// current uri language ($lang_uri)
$lang_uri = URI::segment(1);
// Set default session language if none is set
if(!Session::has('language'))
{
// use lang in uri, if provided
if(in_array($lang_uri, Config::get('application.languages')))
{
$lang = $lang_uri;
}
// detect browser language
elseif(isset(Request::server('http_accept_language')))
{
$headerlang = substr(Request::server('http_accept_language'), 0, 2);
if(in_array($headerlang, Config::get('application.languages')))
{
// browser lang is supported, use it
$lang = $headerlang;
}
// use default application lang
else
{
$lang = Config::get('application.language');
}
}
// no lang in uri nor in browser. use default
else
{
// use default application lang
$lang = Config::get('application.language');
}
// set application language for that user
Session::put('language', $lang);
Config::set('application.language', $lang);
}
// session is available
else
{
// set application to session lang
Config::set('application.language', Session::get('language'));
}
// prefix is missing? add it
if(!in_array($lang_uri, Config::get('application.languages')))
{
return Redirect::to(URI::current());
}
// a valid prefix is there, but not the correct lang? change app lang
elseif(in_array($lang_uri, Config::get('application.languages')) AND $lang_uri != Config::get('application.language'))
{
Session::put('language', $lang_uri);
Config::set('application.language', $lang_uri);
}
});
In the newer Laravel versions, you can get the current language with:
Config::get('app.locale');
This would work fine
lang="{{ app()->getLocale() }}"
I've figured out a solution to the language problem (thanks to nickstr on the IRC and the accepted answer to this question). It involves storing the current language as a session variable, which is updated when the language uri segment is changed.
Route::filter('before', function()
{
// Do stuff before every request to your application...
// Default language ($lang) & current uri language ($lang_uri)
$lang = 'he';
$lang_uri = URI::segment(1);
// Set default session language if none is set
if(!Session::has('language'))
{
Session::put('language', $lang);
}
// Route language path if needed
if($lang_uri !== 'en' && $lang_uri !== 'he')
{
Return Redirect::to($lang.'/'.URI::current());
}
// Set session language to uri
elseif($lang_uri !== Session::get('language'))
{
Session::put('language', $lang_uri);
}
});
This might help.
Config::get('application.language')
You can use
https://github.com/mcamara/laravel-localization
Laravel Localization uses the URL given for the request. In order to achieve this purpose, a group should be added into the routes.php file. It will filter all pages that must be localized.
// app/routes.php
Route::group(array('prefix' => LaravelLocalization::setLanguage()), function()
{
/** ADD ALL LOCALIZED ROUTES INSIDE THIS GROUP **/
Route::get('/', function()
{
return View::make('hello');
});
Route::get('test',function(){
return View::make('test');
});
});
/** OTHER PAGES THAT SHOULD NOT BE LOCALIZED **/
Once this group is added to the routes file, an user can access to all languages added into the 'languagesAllowed' ('en' and 'es' for default, look at the config section to change that option). For example, an user can now access to two different languages, using the following addresses:
http://laravel.com/en
http://laravel.com/es
http://laravel.com
I use App::getLocale() which is probably the most supported way as the App::setLocale('EN') method is used in the documentation.
You can use this method everywhere. If it throughs an error somewhere, you can use \App::... to make it work.
I'm using Laravel 5.0.
Your can get current language in laravel blade by:
{{Lang::locale()}}
The Lang class is specifically for outputting the correct language and as you say manages the language internally.
Looking through the API there is no method to help you directly with this and parsing the URI to get the language would seem the appropriate course of action.
You can always just do this to retrieve the language string in the URI:
$language = URI::segment(1);
Examining Laravel Requests

Wireshark Lua Dissector - How to set source and destination

I'm working on a Wireshark Dissector in Lua.
I try to provide wireshark as much information about my custom protocol as possible to make use of the available analysis tools. Therefore I'm trying to set the correct source and destination address for my protocol.
My protocol can be on top of different other protocols such as UDP or IEEE 802.15.4. So it might even be that the package source/destination is already set (UDP).
However I want wireshark to show my addresses, so I tried the following:
myproto = Proto("myproto"), "My Protocol")
myproto_source = ProtoField.uint16("myproto.src", "Source Address", base.HEX)
myproto.fields = { myproto_source }
function myproto.dissector(buffer, pinfo, tree)
local subtree = tree:add(myproto, buffer(), "My Proto")
subtree:add(myproto_source, buffer(0,2)
-- does not work with error:
-- bad argument #1 to '?' (Address expected, got userdata)
pinfo.src = myproto_source
-- does work, but only adds text, wireshark tools rely on pinfo.src
pinfo.cols.src = tostring(buffer(0,2):uint())
end
udp_table = DissectorTable.get("udp.port")
udp_table:add( 12345, myproto )
wtap_encap_table = DissectorTable.get("wtap_encap")
wtap_encap_table:add(wtap["IEEE802_15_4"], myproto)
So is there maybe a datatype/class "address" that is necessary to set pinfo.src? Or is there a totally different way to set the packet information?
Thanks in advance!
pinfo.src takes an Address object (which is an IP address; not a 16-bit integer). Example usage:
pinfo.src = Address.ip('1.2.3.4')
Note that this only sets the text of the "Source" column shown in Wireshark. The underlying packet info cannot be modified, and the IP packet details will continue to show the actual IP address.
Just a suggestion - I'm not an LUA wiz:
pinfo:col.src = buffer(0,2):uint()
maybe??

Resources