ngx.escape_uri() didn't work on '/'? - lua

I'm trying to encode a url as an arg value like this
url = "http://test.com?a=1&b=2"
encode_url = "http://domain?url="..ngx.escape_uri(url)
then it became
http://domain?url=http%3A//test.com%3Fa%3D1%26b%3D2
but i want to this
http://domain?url=http%3a%2f%2ftest.com%3fa%3d1%26b%3d2
and I also try ngx.encode_args(), it's the same
Does anyone know why? And how should I do?

host = "http://test.com"
uri = "?a=1&b=2"
encode_host = ngx.encode_args({[host]=true})
encode_args = ngx.escape_uri(uri)
encode_url = "http://domain?url=" .. encode_host .. encode_args

Related

Upload Offline Conversion migration to V9

I used to upload offline conversion using following code in v201809 version as provided at
https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201809/Remarketing/UploadOfflineConversions.php
$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
$session = (new AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->withClientCustomerId($customerid)->enablePartialFailure()->build();
$adWordsServices = new AdWordsServices();
$offlineConversionService = $adWordsServices->get($session, OfflineConversionFeedService::class);
$conversionName="OfflineConv";
$feed = new OfflineConversionFeed();
$feed->setConversionName($conversionName);
$feed->setConversionTime($conversionTime);
$feed->setConversionValue($conversionValue);
$feed->setGoogleClickId($gclid);
$offlineConversionOperation = new OfflineConversionFeedOperation();
$offlineConversionOperation->setOperator(Operator::ADD);
$offlineConversionOperation->setOperand($feed);
$offlineConversionOperations = [$offlineConversionOperation];
$result = $offlineConversionService->mutate($offlineConversionOperations);
Now I am upgrading to V9, I have used the code as provided at
https://github.com/googleads/google-ads-php/blob/main/examples/Remarketing/UploadOfflineConversion.php
$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
$googleAdsClient = (new GoogleAdsClientBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->build();
//$conversionName="OfflineConv";
$conversionName = ConversionActionType::WEBPAGE;
$clickConversion = new ClickConversion([
'conversion_action' => ResourceNames::forConversionAction($customerId, $conversionName),
'gclid' => $gclid,
'conversion_value' => $conversionValue,
'conversion_date_time' => $conversionTime,
'currency_code' => 'USD'
]);
$conversionUploadServiceClient = $googleAdsClient->getConversionUploadServiceClient();
$result = $conversionUploadServiceClient->uploadClickConversions($customerid, [$clickConversion], true);
The problem is when we set $conversionName="OfflineConv"; we get following error.
Resource name 'customers/9025381111/conversionActions/OfflineConv' is malformed: expected 'customers/{customer_id}/conversionActions/{ConversionType.conversion_type_id}'., at conversions[0].conversion_action
and when we set $conversionName = ConversionActionType::WEBPAGE; we get following error.
This customer does not have an import conversion action that matches the conversion action provided., at conversions[0].conversion_action
Can someone help me?
Conversion Name must match the conversion action that you've already set up in your account. You're passing the enum value for the type.
It should be something like $conversionName = "OfflineConversions"
where "OfflineConversions" is exactly the name of the conversion in the conversions section of the web UI.
ConversionName has been removed from V9, use $conversionActionId as in example on github.
You need to try use parameter ctId from url your "OfflineConversions" in Google Ads UI as $conversionActionId.
Or try the solution from here.
For your example, replace this
$conversionName = ConversionActionType::WEBPAGE;
on this
$conversionName = {ctId from url};
You need to first create a click conversion
click_conversion = adwords_client.get_type("ClickConversion")
conversion_action_service = adwords_client.get_service('ConversionActionService')
click_conversion.conversion_action = (
conversion_action_service.conversion_action_path(
customer_id, conversion_action_id
)
)
The conversion_action_id is equivalent to conversion_name of previous version.
You can find the id using following snippet
ads: GoogleAdsServiceClient = self.adwords_client.get_service('GoogleAdsService')
pages = ads.search(query="SELECT conversion_action.id, conversion_action.name FROM conversion_action where conversion_action.name={conversion_name}", customer_id={customer_id})
for page in pages:
print(page.conversion_action)
Then you upload the conversion
click_conversion.gclid = gclid
click_conversion.conversion_value = conversion_value
click_conversion.conversion_date_time = conversion_time
click_conversion.currency_code = currency_code
conversion_upload_service = self.adwords_client.get_service("ConversionUploadService")
request = self.adwords_client.get_type("UploadClickConversionsRequest")
request.customer_id = customer_id
request.conversions.append(click_conversion)
request.partial_failure = True
conversion_upload_response = (
conversion_upload_service.upload_click_conversions(
request=request,
)
)
uploaded_click_conversion = conversion_upload_response.results[0]
print(
f"Uploaded conversion that occurred at "
f'"{uploaded_click_conversion.conversion_date_time}" from '
f'Google Click ID "{uploaded_click_conversion.gclid}" '
f'to "{uploaded_click_conversion.conversion_action}"'
)

GMap.Net cache only mode doesn't really care about the cache path I specify

This is my code:
gMapControl1.MapProvider = GMapProviders.GoogleTerrainMap;
gMapControl1.Manager.Mode = GMap.NET.AccessMode.CacheOnly;
var filePath = #"C:\Users\User\Documents\Projects\Data.gmdb";
var fileExists = File.Exists(filePath); //this is true
var outcome = gMapControl1.Manager.ImportFromGMDB(filePath); //this is true as well
gMapControl1.MinZoom = 0;
gMapControl1.MaxZoom = 24;
gMapControl1.Zoom = 9;
gMapControl1.ShowCenter = false;
However, when I step through the code via a debugger, I see that gMapControl1.Manager.PrimaryCache.CacheLocation is still %appdata%Local\GMap.NET ( I think this is the default cache location), and gMapControl1.Manager.SecondaryCache is null.
I cannot find my cache path registered anywhere in GMap.net. Any idea why?
It seems that ImportFromGMDB isn't really functioning as it should.
To use the CacheOnly Mode you have to set the CacheLocation property which is the directory that GMap will Read\Write Cached\New tiles.
gMapControl1.MapProvider = GMapProviders.GoogleTerrainMap;
gMapControl1.Manager.Mode = GMap.NET.AccessMode.CacheOnly;
gMapControl1.CacheLocation = "[Cache_Directory]";
*[Cache_Directory]: can be any directory you want, like: C:\Tiles
Try this approach and the CacheOnly mode will work.

Coffeescript loop simplifying

Sended data is Ruby format:
mob = {id: 1, xpos:100, ypos:150, xposDest:150, yposDest:100, attacked:0}
WebsocketRails[:channel_name].trigger(:event_name, mob)
How could i make this loop simpler? (it's coffeescript)
get_all_mobs: (mob) -> // getting "mob" with Websockets
mob_list[mob.id].id = mob.id
mob_list[mob.id].xpos = mob.xpos if mob.xpos?
mob_list[mob.id].ypos = mob.ypos if mob.ypos?
mob_list[mob.id].xposDest = mob.xposDest if mob.xposDest?
mob_list[mob.id].yposDest = mob.yposDest if mob.yposDest?
mob_list[mob.id].health = mob.health if mob.health?
mob_list[mob.id].level = mob.level if mob.level?
mob_list[mob.id].max_health = mob.max_health if mob.max_health?
mob_list[mob.id].attacked = mob.attacked if mob.attacked?
mob_list[mob.id].steps = mob.steps if mob.steps?
Was tryed something like this, but its wrong:
get_all_mobs: (mob) -> // getting "mob" with Websockets
for attribute in mob
mob_list[mob.id].attribute = mob.attribute
This should do:
get_all_mobs: (mob) -> // getting "mob" with Websockets
for own key, value of mob
mob_list[mob.id][key] = value if value?

RightFax 10.0 Integration With C#

If I insert the values into the corresponding tables of RightFax, does it FAX automatically or do i need to write the following code for that?
RFCOMAPILib.FaxServerClass faxserver = new RFCOMAPILib.FaxServerClass();
faxserver.ServerName = "ServerName";
faxserver.Protocol = RFCOMAPILib.CommunicationProtocolType.cpNamedPipes;
faxserver.UseNTAuthentication = RFCOMAPILib.BoolType.True;
faxserver.OpenServer();
RFCOMAPILib.Fax fax = (RFCOMAPILib.Fax) faxserver.get_CreateObject(RFCOMAPILib.CreateObjectType.coFax);
// set up your 'fax' object the way you want it, below is just some sample options
fax.ToName = "John Doe";
fax.ToFaxNumber = "4255551111";
fax.ToVoiceNumber = "4255550000";
fax.ToCompany = "ACME";
fax.FromName = "My Company";
fax.FromVoiceNumber = "4255552222";
fax.Send();
Can you please provide me sample code for attachments? If RightFax sends the FAX automatically then which tables do I need to fill-in in order to do that?
Thanks
the below code is vb.net but will show you how to send a fax and add attachment as well, hope this helps. I've written a post about this here but here's the code below ....
Dim FaxAPI As RFCOMAPILib.FaxServer
Dim fFax As RFCOMAPILib.Fax
FaxAPI = New RFCOMAPILib.FaxServer
FaxAPI.ServerName =something
FaxAPI.Protocol = RFCOMAPILib.CommunicationProtocolType.cpTCPIP
FaxAPI.UseNTAuthentication = RFCOMAPILib.BoolType.False
FaxAPI.AuthorizationUserID = something
FaxAPI.AuthorizationUserPassword = something
FaxAPI.OpenServer()
fFax = FaxAPI.CreateObject(RFCOMAPILib.CreateObjectType.coFax)
fFax.Attachments.Add(“D:\FilePickupIn\2222222222-20110322142718-01.tif”)
fFax.HasCoversheet = RFCOMAPILib.BoolType.False
fFax.ToFaxNumber = something
fFax.ToName = something
fFax.Send()
FaxAPI.CloseServer()
FaxAPI = Nothing
fFax = Nothing
happy to help if you get stuck with anything...

str_replace - with the replacement of the figures

Hello,
Is there a solution to this problem?
$vowels_1 = array("1","12","11");
$vowels_2 = array("One","Twelve","Eleven");
$onlyconsonants = str_replace($vowels_1, $vowels_2, "11");
echo $onlyconsonants;
Result = OneOne
It is supposed to be = Eleven
Is there a solution?
Thanks
Simple, Just swap you $vowels
$vowels_1 = array("11","12","1");
$vowels_2 = array("Eleven","Twelve","One")

Resources