anonymous

Why is anonymous class required in “super type token” pattern in java

天涯浪子 提交于 2019-12-03 17:09:07
问题 In Neal Gafter's "super type token" pattern (http://gafter.blogspot.com/2006/12/super-type-tokens.html), an anonymous object was used to pass in the parameterized type : class ReferenceType<T>{} /* anonymous subclass of "ReferenceType" */ ReferenceType<List<Integer>> referenceType = new ReferenceType<List<Integer>>(){ }; Type superClass = b.getClass().getGenericSuperclass(); System.out.println("super type : " + superClass); Type genericType = ((ParameterizedType)superClass)

Passing an anonymous variable by reference

蓝咒 提交于 2019-12-03 14:16:06
Standard C++ types such as int or char have ctors, so you can have expressions like: int a = int(67); // create anonymous variable and assing it to variable a int b(13); // initialize variable b int(77); // create anonymous variable User defined types (structures or classes) are able to do the same: struct STRUCT { STRUCT(int a){} }; STRUCT c = STRUCT(67); STRUCT d(13); STRUCT(77); The question is: why can we pass by a reference anonymous structure or class instances, but can not pass standard types? struct STRUCT { STRUCT(int a){} }; void func1(int& i){} void func2(STRUCT& s){} void func3(int

Anonymous Classes语法

浪尽此生 提交于 2019-12-03 14:15:10
anonymous classes可以让你的代码更加简洁,使你在同一时间声明和实例化一个类,类似于一个没有名字的内部类,若你只需要一次使用一个内部类 1、声明Anonymous Classes 内部类是类声明,匿名类是表达式,意味这你在另一个表达式中定义该类,如下面例子,在初始化本地变量 frenchGreeting和 spanishGreeting使用anonymous classes,但初始化 englishGreeting使用一个内部类: public class HelloWorldAnonymousClasses { interface HelloWorld { public void greet(); public void greetSomeone(String someone); } public void sayHello(){ class EnglishGreeting implements HelloWorld { String name = "world"; @Override public void greet() { greetSomeone("world"); } @Override public void greetSomeone(String someone) { name = someone; System.out.println("Hello

Best way to send anonymous email like craigslist

我的梦境 提交于 2019-12-03 12:05:55
Craigslist has a nice feature where when you respond to a poster you respond to an email such as job-fepsd-1120347193@craigslist.org . The email is then in turn directed to the real email. I am looking for a couple pointers on how to do this with PHP. Thanks, Levi ceejayoz This is usually done by piping an e-mail address (often, a catch-all address) to PHP. Here's a tutorial on doing it that should get you started in the right direction. The most probable solution is that they do email piping. They insert the ad with an identifier like "job-fepsd-1120347193" alongside the real email. Then they

Send anonymous mail from local machine

耗尽温柔 提交于 2019-12-03 09:00:34
问题 I was using Python for sending an email using an external SMTP server. In the code below, I tried using smtp.gmail.com to send an email from a gmail id to some other id. I was able to produce the output with the code below. import smtplib from email.MIMEText import MIMEText import socket socket.setdefaulttimeout(None) HOST = "smtp.gmail.com" PORT = "587" sender= "somemail@gmail.com" password = "pass" receiver= "receiver@somedomain.com" msg = MIMEText("Hello World") msg['Subject'] = 'Subject -

Why is anonymous class required in “super type token” pattern in java

江枫思渺然 提交于 2019-12-03 06:50:46
In Neal Gafter's "super type token" pattern ( http://gafter.blogspot.com/2006/12/super-type-tokens.html ), an anonymous object was used to pass in the parameterized type : class ReferenceType<T>{} /* anonymous subclass of "ReferenceType" */ ReferenceType<List<Integer>> referenceType = new ReferenceType<List<Integer>>(){ }; Type superClass = b.getClass().getGenericSuperclass(); System.out.println("super type : " + superClass); Type genericType = ((ParameterizedType)superClass).getActualTypeArguments()[0]; System.out.println("actual parameterized type : " + genericType); Then result is : super

Office documents prompt for login in anonymous SharePoint site

寵の児 提交于 2019-12-03 05:25:26
I have a MOSS 07 site that is configured for anonymous access. There is a document library within this site that also has anonymous access enabled. When an anonymous user clicks on a PDF file in this library, he or she can read or download it with no problem. When a user clicks on an Office document, he or she is prompted with a login box. The user can cancel out of this box without entering a log in, and will be taken to the document. This happens in IE but not FireFox. I see some references to this question on the web but no clear solutions: http://www.microsoft.com/communities/newsgroups/en

Send anonymous mail from local machine

穿精又带淫゛_ 提交于 2019-12-02 23:01:59
I was using Python for sending an email using an external SMTP server. In the code below, I tried using smtp.gmail.com to send an email from a gmail id to some other id. I was able to produce the output with the code below. import smtplib from email.MIMEText import MIMEText import socket socket.setdefaulttimeout(None) HOST = "smtp.gmail.com" PORT = "587" sender= "somemail@gmail.com" password = "pass" receiver= "receiver@somedomain.com" msg = MIMEText("Hello World") msg['Subject'] = 'Subject - Hello World' msg['From'] = sender msg['To'] = receiver server = smtplib.SMTP() server.connect(HOST,

S3 - Anonymous Upload - Key prefix

与世无争的帅哥 提交于 2019-12-02 18:19:35
I am trying to understand exactly how to setup a bucket that is generally private but allows anonymous uploads with restrictions. The specific criteria are: The bucket is mostly private and requires my key/secret to add/remove/update/list files. There is a "directory" (i.e. key prefix) called "incoming" that will allow anonymous users to upload content to but not list. The bucket has a one day expiration on all content. As a bonus I would like the "incoming" directory to have a 30 minute expiration although if that is not possible a one day expiration for the whole bucket will do. Files with

Convert anonymous function in PHP 5.3 into PHP 5.2 equivalent

家住魔仙堡 提交于 2019-12-02 12:14:32
问题 I have error in line 2 and 13 in PHP 5.2, I have no idea to make the correction, I tried using create_function but not working, can anyone help with this? function _process_special_keyword($str){ $callback = function($match){ $ret = $match[1] . '[' . $match[2] . ']'; if(!empty($match[3])){ $ret .= '.[' . $match[3] . ']'; } $ret .= $match[4]; return $ret; }; $strSQL = preg_replace_callback('/([\s\(\.,])(' . SPECIAL_KEYWORDS . ')(?:\.(' . SPECIAL_KEYWORDS . '))?([\s\)\.,])/i', $callback, $str);